ghorwin / FMICodeGenerator

A Code Generator that creates native C/C++ code to build Functional Mock-Up Units (FMU) with support for FMI version 2.0 (rollback)
BSD 3-Clause "New" or "Revised" License
51 stars 25 forks source link

Allow variable names with _ and numbers #46

Closed ghorwin closed 1 year ago

ghorwin commented 1 year ago

reported by MathiasMalandain

A-Z, a-z only

When declaring variables, I got a message warning me that only ASCII characters A-Z and a-z could be used in variable names. I had to rename variables T_limit and k_P accordingly. Was it unobserved behavior so far? I would not expect so, as the warning message makes it really clear which characters can be used. The ability to use underscores in variable names would be hugely convenient.

Generally, allow all variable names that generated proper variable defines in C++ code.

ghorwin commented 1 year ago

Az/az issue: in a previous version I didn't have a check at all and people tried to use all kinds of characters in names that did not compile in C (like / or \ or & or | ...). I didn't have the time to do a proper syntax check for variable names that yield valid C++ variable names, so I restricted the variables to use letters only. Of course, _ is a very frequently used character in variables, so I should add this; same as numbers, unless the variable starts with a number (forbidden in C/C++).