aboutsummaryrefslogtreecommitdiff
path: root/devtools/tasmrecover/tasm/lex.py
diff options
context:
space:
mode:
authorVladimir2011-06-05 15:05:12 +0400
committerAlyssa Milburn2011-06-15 17:29:44 +0200
commit9cf2a7ba0e686b35a4f1041f67c51cb9ef2fa867 (patch)
tree6d7d41f4443878cb323717b2ef0a0ee246f1e40e /devtools/tasmrecover/tasm/lex.py
parent1f063c947b34ba9e56fabcbdf838094da80b3727 (diff)
downloadscummvm-rg350-9cf2a7ba0e686b35a4f1041f67c51cb9ef2fa867.tar.gz
scummvm-rg350-9cf2a7ba0e686b35a4f1041f67c51cb9ef2fa867.tar.bz2
scummvm-rg350-9cf2a7ba0e686b35a4f1041f67c51cb9ef2fa867.zip
DREAMWEB: added tasm-recover tool
Diffstat (limited to 'devtools/tasmrecover/tasm/lex.py')
-rw-r--r--devtools/tasmrecover/tasm/lex.py52
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..ba66611bce
--- /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