Skip to content

Commit 3b83137

Browse files
committed
parse single quoted names correctly
1 parent 0215bb3 commit 3b83137

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

OMPython/OMTypedParser.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ def convertNumbers(s, l, toks):
6565
return float(n)
6666

6767

68+
def convertString2(s, s2):
69+
tmp = s2[0].replace("\\\"", "\"")
70+
tmp = tmp.replace("\"", "\\\"")
71+
tmp = tmp.replace("\'", "\\'")
72+
tmp = tmp.replace("\f", "\\f")
73+
tmp = tmp.replace("\n", "\\n")
74+
tmp = tmp.replace("\r", "\\r")
75+
tmp = tmp.replace("\t", "\\t")
76+
return "'"+tmp+"'";
77+
6878
def convertString(s, s2):
6979
return s2[0].replace("\\\"", '"')
7080

@@ -90,7 +100,8 @@ def convertTuple(t):
90100
Optional('.' + Word(nums)) +
91101
Optional(Word('eE', exact=1) + Word(nums + '+-', nums)))
92102

93-
ident = Word(alphas + "_", alphanums + "_") | Combine("'" + Word(alphanums + "!#$%&()*+,-./:;<>=?@[]^{}|~ ") + "'")
103+
#ident = Word(alphas + "_", alphanums + "_") | Combine("'" + Word(alphanums + "!#$%&()*+,-./:;<>=?@[]^{}|~ ") + "'")
104+
ident = Word(alphas + "_", alphanums + "_") | QuotedString(quoteChar='\'', escChar='\\').setParseAction(convertString2)
94105
fqident = Forward()
95106
fqident << ((ident + "." + fqident) | ident)
96107
omcValues = delimitedList(omcValue)

0 commit comments

Comments
 (0)