Restriction on special characters in variable names? #383
-
I've tried to use special characters like I entirely get why this error is thrown, (issues with operators like >, =, -, +, etc.) but is there any way to work around non-operator characters? I really want to have my variables marked with some indicator that they're variables. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi, variable names must start with a letter or an underscore. So the underscore is the only special character that is allowed for a variable: Expression expression = new Expression("_a + _b");
expression.with("_a", 2).and("_b", 3).evaluate(); With some changes, a feature could be added to allow configuring additional characters, e.g. the $ character is a common special character denoting variables, e.g. this could look like this: Expression expression = new Expression("$a + $b");
expression.with("$a", 2).and("$b", 3).evaluate(); If you want to contribute, then you are welcome. :-) |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick response! I could make a PR real quick to make this change for dollar signs, so I'll get work onto that now. A little off topic, but I was also wanting a couple changes for personal use(assuming that most of these changes are not ones you would want to have on the actual project) (eg. ability to use ' instead of " for string literals, possibly even some sort of token registry thing), so would I be allowed to fork this project? |
Beta Was this translation helpful? Give feedback.
Hi, variable names must start with a letter or an underscore. So the underscore is the only special character that is allowed for a variable:
With some changes, a feature could be added to allow configuring additional characters, e.g. the $ character is a common special character denoting variables, e.g. this could look like this:
If you want to contribute, then you are welcome. :-)