Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Unified Diff: tools/lexer_generator/dfa.py

Issue 68843002: Experimental lexer generator: More code generation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/lexer/lexer_py.re ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer_generator/dfa.py
diff --git a/tools/lexer_generator/dfa.py b/tools/lexer_generator/dfa.py
index 73e8eb4c26c35c1a564cd37b410e4828d8b59e27..03b9b05afd9d5607ba3cf4d258f12ec3c5feb468 100644
--- a/tools/lexer_generator/dfa.py
+++ b/tools/lexer_generator/dfa.py
@@ -59,7 +59,7 @@ class DfaState(AutomatonState):
# FIXME: add default action
code = '''
code_%s:
-fprintf(stderr, "state %s, char at hand is %%c\\n", c);
+fprintf(stderr, "state %s, char at hand is %%c (%%d)\\n", c, c);
''' % (self.node_number(), self.node_number())
for key, state in self.__transitions.items():
@@ -67,7 +67,18 @@ fprintf(stderr, "state %s, char at hand is %%c\\n", c);
code += ''' {
c = *(++cursor);
goto code_%s;
-}''' % state.node_number()
+}
+''' % state.node_number()
+
+ action = self.action()
+ if action:
+ if action[1] == 'terminate':
+ code += 'return 0;'
+ elif action[1] == 'terminate_illegal':
+ code += 'return 1;'
+ else:
+ code += self.action()[1];
+
return code
class Dfa(Automaton):
« no previous file with comments | « src/lexer/lexer_py.re ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698