# ERROR: syntax: extra token "QRelaySym" after end of expression

**URL:** https://discourse.julialang.org/t/error-syntax-extra-token-qrelaysym-after-end-of-expression/17307
**Category:** New to Julia
**Tags:** question
**Created:** [November 8, 2018, 3:00pm UTC](https://discourse.julialang.org/t/error-syntax-extra-token-qrelaysym-after-end-of-expression/17307 "2018-11-08T15:00:38Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![marouane](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marouane/32/16267_2.png) [@marouane](https://discourse.julialang.org/u/marouane)
#### Post date: [November 8, 2018, 3:00pm UTC](https://discourse.julialang.org/t/error-syntax-extra-token-qrelaysym-after-end-of-expression/17307/1 "2018-11-08T15:00:38Z")

</div>

Hello everyone,  
im new in Julia i have version 1.0 and there is a code that i want to run but it doesn’t want to, actually it i only one code that i want to use in another file and maybe this code was written in 0.0.6  
this is the code:

```julia
type QRelaySym{T<:Tuple}
    aH::T
    bH::T
    aV::T
    bV::T
    apH::T
    bpH::T
    apV::T
    bpV::T
end

function trans(op, a, b, ap, bp, B)
    p = B * [ap; bp]
    op = subs(op, a, p[1])
    op = subs(op, b, p[2])
    return op
end

#2D rotation matrix
function rotmat(theta)
    c = cos(theta)
    s = sin(theta)
    return [c s; -s c]
end

function qrelay_op(n, phi, alpha, delta)
    #operators before BS
    aH = symbols(@sprintf("a_H1:%d", n+1))
    bH = symbols(@sprintf("b_H1:%d", n+1))
    aV = symbols(@sprintf("a_V1:%d", n+1))
    bV = symbols(@sprintf("b_V1:%d", n+1))
    
    op = 0
    for i=1:n
        op += phi[i] * (aH[i]*bH[i] + aV[i]*bV[i])
    end

  
    B = 1/sqrt(2)*[1 1;-1 1]
    

    apH = symbols(@sprintf("a'_H1:%d", n+1))
    bpH = symbols(@sprintf("b'_H1:%d", n+1))
    apV = symbols(@sprintf("a'_V1:%d", n+1))
    bpV = symbols(@sprintf("b'_V1:%d", n+1))

    for i=1:n-1
        op = trans(op, bH[i], aH[i+1], bpH[i], apH[i+1], B)
        op = trans(op, bV[i], aV[i+1], bpV[i], apV[i+1], B)
    end

    op = trans(op, aH[1], aV[1], apH[1], apV[1], rotmat(alpha))
    op = trans(op, bH[n], bV[n], bpH[n], bpV[n], rotmat(delta))
    

    syms = QRelaySym(aH, bH, aV, bV, apH, bpH, apV, bpV)

    return syms, op
end

function op_mat(op)
    op = op[:as_poly](domain="C")
    op_a = op.x[:gens]
    nab = op[:length]()
    op_ab = ones(SymPy.Sym, nab)
    coef = zeros(Complex, nab)
    mat = zeros(Int64, length(op_a), nab)
    for (i, (ps, c)) in enumerate(op[:as_dict]())
        for (j, p) in enumerate(ps)
            mat[j, i] = p
            op_ab[i] = op_a[j]^p * op_ab[i]
        end
        coef[i] = c
    end
 
    return op_a, op_ab, mat, coef
end
` ` `
and it shows always this message:
ERROR: syntax: extra token "QRelaySym" after end of expression
```

---

<div class="post-metadata">

### Author: ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)
#### Post date: [November 8, 2018, 3:06pm UTC](https://discourse.julialang.org/t/error-syntax-extra-token-qrelaysym-after-end-of-expression/17307/2 "2018-11-08T15:06:25Z")

</div>

`type` is `mutable struct` now.

> [@PSA: use Julia 0.7 if you are upgrading](https://discourse.julialang.org/t/psa-use-julia-0-7-if-you-are-upgrading/13321):
>
> A lot of people are posting issues where their old code doesn’t work anymore on 1.0 because some function has been renamed or removed. The 0.7 release exists exactly for this reason: your old code will work on 0.7 and give you a specific warning about how to fix your code. If you have any old code, you should use 0.7 to get these warnings before switching to 1.0; even if you just have work habits that may need changing, you should probably use 0.7 for a while. If someone posts an issue like thi…

Julia 0.7 prints this:

```julia-auto
julia> type X end
┌ Warning: Deprecated syntax `type` at REPL[1]:1.
│ Use `mutable struct` instead.
└ @ REPL[1]:1

```

Also, please quote your code:

> [@PSA: how to quote code with backticks](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530):
>
> This is a short post on how to use backticks (` and ```) to quote code, so it is easy to read. This post can be linked to new users who are confused by this feature. Why By quoting your code, you get a monospaced font (which preserves indentation) and syntax highlighting. This makes it easier to read your code and help you. Displayed code looks like this: function displayed\_code(x::Int, y::Int) if x \< y println("x is smaller") else println("or not") end end Inline…

---

<div class="post-metadata">

### Author: ![marouane](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marouane/32/16267_2.png) [@marouane](https://discourse.julialang.org/u/marouane)
#### Post date: [November 9, 2018, 2:46pm UTC](https://discourse.julialang.org/t/error-syntax-extra-token-qrelaysym-after-end-of-expression/17307/3 "2018-11-09T14:46:16Z")

</div>

Thank you, that solved the problem but i think that there is one more problem. i changed (@sprintf) to (@printf) in the version 0.7 and it shows me a warning like this  
‘’‘Base.@printf is deprecated: it has been moved to the standard library package `Printf` Add `using Printf` to your imports. in module Main’‘’

i have added the package but it is the same situation, always the same situation.

---

<div class="post-metadata">

### Author: ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)
#### Post date: [November 9, 2018, 3:23pm UTC](https://discourse.julialang.org/t/error-syntax-extra-token-qrelaysym-after-end-of-expression/17307/4 "2018-11-09T15:23:21Z")

</div>

```julia
using Printf

@printf "%f\n" pi

```

---

<div class="post-metadata">

### Author: ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)
#### Post date: [November 9, 2018, 3:55pm UTC](https://discourse.julialang.org/t/error-syntax-extra-token-qrelaysym-after-end-of-expression/17307/5 "2018-11-09T15:55:19Z")

</div>

[https://docs.julialang.org/en/v1/stdlib/Printf/#Printf.@sprintf](https://docs.julialang.org/en/v1/stdlib/Printf/#Printf.@sprintf)
