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

Unified Diff: tools/lexer_generator/generator.py

Issue 209473005: Experimental parser: dfa path iteration test (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 months 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 | « tools/lexer_generator/dfa_path_writer.py ('k') | tools/lexer_generator/transition_key.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer_generator/generator.py
diff --git a/tools/lexer_generator/generator.py b/tools/lexer_generator/generator.py
index e18e2d981184ae9efac6884a7a8f94e738e7dbe4..e07643a54cb16ba06b4830ab2177d80def98f404 100644
--- a/tools/lexer_generator/generator.py
+++ b/tools/lexer_generator/generator.py
@@ -34,6 +34,7 @@ from dfa import Dfa
from dfa_minimizer import DfaMinimizer
from rule_parser import RuleParser, RuleParserState, RuleProcessor
from code_generator import CodeGenerator
+from dfa_path_writer import DfaPathWriter
file_template = '''
<html>
@@ -141,6 +142,7 @@ if __name__ == '__main__':
parser.add_argument('--verbose', action='store_true')
parser.add_argument('--debug-code', action='store_true')
parser.add_argument('--profile', action='store_true')
+ parser.add_argument('--lexer-shell-test-file')
parser.add_argument('--rule-html')
args = parser.parse_args()
@@ -168,35 +170,40 @@ if __name__ == '__main__':
dfa.node_count(), mdfa.node_count()))
DfaMinimizer.set_verify(True)
- html_file = args.html
- if html_file:
+ if args.lexer_shell_test_file:
+ dfa = rule_processor.default_automata().dfa()
+ if minimize_default:
+ dfa = rule_processor.default_automata().minimal_dfa()
+ path_writer = DfaPathWriter(dfa)
+ with open(args.lexer_shell_test_file, 'w') as f:
+ path_writer.write_lexer_shell_test_file(f)
+ logging.info("wrote lexer_shell file to %s" % args.lexer_shell_test_file)
+
+ if args.html:
html = generate_html(
rule_processor, minimize_default, not args.no_merge_html)
with open(args.html, 'w') as f:
f.write(html)
- logging.info("wrote html to %s" % html_file)
+ logging.info("wrote html to %s" % args.html)
- rule_html_file = args.rule_html
- if rule_html_file:
+ if args.rule_html:
html = generate_rule_tree_html(rule_processor)
- with open(rule_html_file, 'w') as f:
+ with open(args.rule_html, 'w') as f:
f.write(html)
- logging.info("wrote html to %s" % rule_html_file)
+ logging.info("wrote rule html to %s" % args.rule_html)
- code_file = args.code
- if code_file:
+ if args.code:
code_generator = CodeGenerator(rule_processor,
minimize_default = minimize_default,
inline = not args.no_inline,
debug_print = args.debug_code)
code = code_generator.process()
- with open(code_file, 'w') as f:
+ with open(args.code, 'w') as f:
f.write(code)
- logging.info("wrote code to %s" % code_file)
+ logging.info("wrote code to %s" % args.code)
- input_file = args.input
- if input_file:
- with open(input_file, 'r') as f:
+ if args.input:
+ with open(args.input, 'r') as f:
lex(rule_processor, f.read())
if args.profile:
« no previous file with comments | « tools/lexer_generator/dfa_path_writer.py ('k') | tools/lexer_generator/transition_key.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698