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

Unified Diff: tools/lexer_generator/code_generator.py

Issue 72613005: Experimental lexer generator: Force code actions. (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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer_generator/code_generator.py
diff --git a/tools/lexer_generator/code_generator.py b/tools/lexer_generator/code_generator.py
index eede23327a47128e84a29fdf6fd6d2efdd886316..e03ec1f58154567dd252057799be886975d1eefc 100644
--- a/tools/lexer_generator/code_generator.py
+++ b/tools/lexer_generator/code_generator.py
@@ -68,6 +68,11 @@ code_%s:
state.node_number())
action = state.action()
+ if (action and action.type() != 'terminate' and
+ action.type() != 'terminate_illegal' and action.type() != 'code' and
+ action.type() != 'push_token' and action.type() != 'skip'):
+ raise Exception("unknown type %s" % action.type())
+
if action:
if action.type() == 'terminate':
code += 'PUSH_TOKEN(Token::EOS); return 0;'
@@ -78,6 +83,8 @@ code_%s:
elif action.type() == 'skip':
code += 'SKIP(); goto code_start;'
return code
+ elif action.type() == 'code':
+ code += '%s\n' % action.data()
code += '''
//fprintf(stderr, "char at hand is %c (%d)\\n", yych, yych);\n'''
@@ -91,15 +98,12 @@ code_%s:
''' % s.node_number()
if action:
- if action.type() == 'code':
- code += '%s\n\ngoto code_%s;\n' % (action.data(),
- start_node_number)
- elif action.type() == 'push_token':
+ if action.type() == 'push_token':
content = 'PUSH_TOKEN(Token::%s);' % action.data()
code += '%s\ngoto code_%s;\n' % (content,
start_node_number)
- else:
- raise Exception("unknown type %s" % action.type())
+ elif action.type() == 'code':
+ code += 'goto code_start;'
else:
code += 'goto default_action;'
return code
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698