diff options
Diffstat (limited to 'devtools/tasmrecover/tasm/lex.py')
-rw-r--r-- | devtools/tasmrecover/tasm/lex.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/devtools/tasmrecover/tasm/lex.py b/devtools/tasmrecover/tasm/lex.py new file mode 100644 index 0000000000..cf7e6e19bf --- /dev/null +++ b/devtools/tasmrecover/tasm/lex.py @@ -0,0 +1,52 @@ +def parse_args(text): + #print "parsing: [%s]" %text + escape = False + string = False + result = [] + token = str() + value = 0; + for c in text: + #print "[%s]%s: %s: %s" %(token, c, escape, string) + if c == '\\': + escape = True + continue + + if escape: + if not string: + raise SyntaxError("escape found in no string: %s" %text); + + #print "escaping[%s]" %c + escape = False + token += c + continue + + if string: + if c == '\'' or c == '"': + string = False + + token += c + continue + + if c == '\'' or c == '"': + string = True + token += c + continue + + if c == ',': + result.append(token.strip()) + token = str() + continue + + if c == ';': #comment, bailing out + break + + token += c + #token = token.strip() + if len(token): + result.append(token) + #print result + return result + +def compile(width, data): + print data + return data |