Parser error interpretation

Issue #170 resolved
William Shields created an issue

After writing a machine with a muspoiler named 'ms', the following message was displayed:

main> Using input file : test.gmad
parser> reading file /Users/williamshields/bdsim/medical/working_dir/testScripts/test_components.gmad
syntax error at line 6 of file /Users/williamshields/bdsim/medical/working_dir/testScripts/test_components.gmad
symbol ':' unexpected

The file test.gmad is attached.

Now I know that 'ms' is actually reserved for milliseconds, however I found that the error appearing as an unexpected ':' was somewhat misleading. Could this be changed to return an error stating that names such as 'ms' are reserved/protected names?

Comments (3)

  1. Jochem Snuverink

    Many thanks for the reporting. You are absolutely right that this is unclear (it is the default message for when the parser doesn't know what to do with the syntax), and that the message should be improved. I implemented it with the following error message:

    ERROR: ms is already defined or a reserved name or function
    

    I also added this when defining an element with an already defined variable or function.

  2. Log in to comment