Revision: 17793
Author: [email protected]
Date: Fri Nov 15 14:36:55 2013 UTC
Log: Experimental lexer generator: Add an option to add debug prints.
[email protected]
BUG=
Review URL: https://codereview.chromium.org/65643005
http://code.google.com/p/v8/source/detail?r=17793
Modified:
/branches/experimental/parser/tools/lexer_generator/code_generator.py
=======================================
--- /branches/experimental/parser/tools/lexer_generator/code_generator.py
Fri Nov 15 12:23:19 2013 UTC
+++ /branches/experimental/parser/tools/lexer_generator/code_generator.py
Fri Nov 15 14:36:55 2013 UTC
@@ -28,6 +28,7 @@
from dfa import Dfa
class CodeGenerator:
+ debug = False
@staticmethod
def key_to_code(key):
@@ -109,11 +110,15 @@
code += '''
code_start:
'''
+
code += '''
code_%s:
- //fprintf(stderr, "state %s\\n");
-''' % (state.node_number(),
- state.node_number())
+''' % state.node_number()
+
+ if CodeGenerator.debug:
+ code += '''
+ fprintf(stderr, "state %s\\n");
+''' % state.node_number()
entry_action = state.action().entry_action() if state.action() else
None
match_action = state.action().match_action() if state.action() else
None
@@ -121,8 +126,10 @@
if entry_action:
code += self.__action_code_map[entry_action[0]](entry_action[1])
- code += '''
- //fprintf(stderr, "char at hand is %c (%d)\\n", yych, yych);\n'''
+ if CodeGenerator.debug:
+ code += '''
+ fprintf(stderr, "char at hand is %c (%d)\\n", yych, yych);
+'''
for key, s in state.transitions().items():
code += CodeGenerator.key_to_code(key)
@@ -162,8 +169,12 @@
default_action_code = self.__action_code_map[action[0]](action[1])
code += '''
CHECK(false); goto code_start;
-default_action:
- //fprintf(stderr, "default action\\n");
+default_action:'''
+ if CodeGenerator.debug:
+ code += '''
+fprintf(stderr, "default action\\n");
+'''
+ code += '''
%s
FORWARD();
goto code_%s;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.