Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend support for Unicode variable names #532

Closed
chrispcampbell opened this issue Sep 3, 2024 · 0 comments · Fixed by #533 or #535
Closed

Extend support for Unicode variable names #532

chrispcampbell opened this issue Sep 3, 2024 · 0 comments · Fixed by #533 or #535

Comments

@chrispcampbell
Copy link
Contributor

The antlr4-vensim package historically only allowed for ASCII / Latin characters when reading (Vensim) variable names. A request was submitted in the antlr4-vensim repo (see climateinteractive/antlr4-vensim#12) to extend the grammar to allow for non-Latin (e.g., Chinese) characters in variable names (identifiers).

Once the fix is merged and published in antlr4-vensim, we should update the parse package to use the latest. I will also add an integration test to verify that non-Latin characters can be used in mdl files and that they are accepted in the parse/compile and runtime packages without issue.

For the record, prior to this fix, the parse package would throw an error if it encounters non-Latin characters in identifier position:

Generating model...
  Error: Failed to parse Vensim model definition at line 15:
  中文变量名 X = TIME ~~|

  Detail:
    token recognition error at: '中'
      at parseVensimModel (file://.../sdeverywhere/packages/parse/dist/index.js:1408:13)
      at parseModel (file://.../sdeverywhere/packages/compile/src/parse-and-generate.js:166:16)
      at parseAndGenerate (file://.../sdeverywhere/packages/compile/src/parse-and-generate.js:70:21)
      at generate (file://.../sdeverywhere/packages/cli/src/sde-generate.js:97:9)

After the fix, the characters will be accepted without errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment