• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Syntax Error, Unexpected:

Status
Not open for further replies.

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
I think i have seen this error before from beginners. If you give me a good error message i can special-case this in pjass.
This is what i currently have:
Code:
$ cat test.j
type unit extends handle

function foo takes nothing returns nothing
    local unit u
    local unit v
    set unit u = null
    set u unit = null
    set v u = null
endfunction

$ ./pjass test.j
test.j:6: >unit< u is an error here. The type only needs to be stated at declartion time
test.j:7: u >unit< is an error here. The type only needs to be stated at declartion time
test.j:8: Unexpected 'u'
test.j failed with 3 errors
Parse failed: 3 errors total
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
"variable u type respecified/restated"? It's not redeclared but there has to be a good word for it.
The assignment statement is not valid. Nowhere in an assignement statement is a type expected or even allowed.

JASS:
// local declaration with optional definition
local {type} *varname* (= [expression of {type}])

// local assignment
set *varname* = [expression of {type}]
where...
  • {} represent a previously declared type name
  • ## represent a declared variable name that is not a key word or a type name.
  • () represent the enclosed is optional
  • [] represent an expression governed by other syntax rules not covered here
I am sure there is a better and more clear way to describe the syntax. Just I am not experienced with such.
 
Last edited:
Status
Not open for further replies.
Top