OpenTTD / nml

NewGRF Meta Language
GNU General Public License v2.0
44 stars 36 forks source link

Bug: `const` keyword not working #332

Open WenSimEHRP opened 4 months ago

WenSimEHRP commented 4 months ago

030_house.nml log:

Running test 029_base_graphics
Running test 030_house
 nmlc ERROR: "030_house.nml", line 53: Syntax error, unexpected token "const"
Traceback (most recent call last):
  File "D:\Data\Documents\GitHub\__Developing\jppluswins\nml\nmlc", line 6, in <module>
    main.run()
  File "D:\Data\Documents\GitHub\__Developing\jppluswins\nml\nml\main.py", line 639, in run
    main(sys.argv[1:])
  File "D:\Data\Documents\GitHub\__Developing\jppluswins\nml\nml\main.py", line 346, in main
    ret = nml(
          ^^^^
  File "D:\Data\Documents\GitHub\__Developing\jppluswins\nml\nml\main.py", line 434, in nml
    result = nml_parser.parse(script, input_filename)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Data\Documents\GitHub\__Developing\jppluswins\nml\nml\parser.py", line 84, in parse
    return self.parser.parse(None, lexer=self.lexer.lexer)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jerry\scoop\apps\python\current\Lib\site-packages\ply\yacc.py", line 333, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jerry\scoop\apps\python\current\Lib\site-packages\ply\yacc.py", line 1201, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jerry\scoop\apps\python\current\Lib\site-packages\ply\yacc.py", line 192, in call_errorfunc
    r = errorfunc(token)
        ^^^^^^^^^^^^^^^^
  File "D:\Data\Documents\GitHub\__Developing\jppluswins\nml\nml\parser.py", line 106, in p_error
    raise generic.ScriptError('Syntax error, unexpected token "{}"'.format(t.value), t.lineno)
nml.generic.ScriptError: "030_house.nml", line 53: Syntax error, unexpected token "const"
make[1]: *** [Makefile:21: 030_house] Error 1
make[1]: Leaving directory 'D:/Data/Documents/GitHub/__Developing/jppluswins/nml/regression'
make: *** [Makefile:8: regression] Error 2
glx22 commented 4 months ago

Parser needs to be rebuilt, use -R for at least one nmlc run.

LordAro commented 1 month ago

Is there any particular reason why nmlc can't detect this itself?

glx22 commented 1 month ago

Nobody implemented the detection. Anyway looking at ply changelog, it seems they stopped distribution with pip 2 years ago in favour of vendoring, and latest version removed parser/lexer caching. So maybe we should just vendor latest version and drop the generated tables.