public static final String INT = "[+-]?\\d+";\r
public static final String INT_G = "("+INT+")";\r
\r
+ // matches a basic character allowed in variable name\r
+ public static final String FORBIDDEN_VARIABLE_CHAR = "\\W";\r
+ \r
// matches a basic vensim name (starts with a letter, may contain any word \r
// characters and white space)\r
public static final String BASIC_NAME =\r
// result.append(variable.substring(1, variable.length() - 1));\r
// result.append('\'');\r
// try this: replace quoted variable names with normalized versions\r
- String foobar = variable.replace('"', ' ');\r
- foobar = foobar.replace('-', ' ');\r
+ variable = variable.replaceAll(FORBIDDEN_VARIABLE_CHAR, "_");\r
result.append(variable);\r
}\r
else {\r
// this would be to simply quote problematic variable names \r
// but quoted variable names are currently broken in sysdyn so \r
// that is not an option)\r
- \r
+ variable = variable.replaceAll(FORBIDDEN_VARIABLE_CHAR, "_");\r
// capitalize each part of the variable name to prevent \r
// collisions with reserved keywords (e.g. "public")\r
String[] parts = variable.split("\\s+");\r
offset = matcher.end();\r
}\r
if (offset < expression.length()) {\r
- result.append(expression.substring(offset));\r
+ String stuff = expression.substring(offset);\r
+ stuff = stuff.replaceAll("=", "==");\r
+ result.append(stuff);\r
}\r
\r
return result.toString();\r