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

Side by Side Diff: tools/lexer_generator/generator.py

Issue 75513002: Experimental parser: inline rules (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/lexer_generator/code_generator_test.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 the V8 project authors. All rights reserved. 1 # Copyright 2013 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without 2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are 3 # modification, are permitted provided that the following conditions are
4 # met: 4 # met:
5 # 5 #
6 # * Redistributions of source code must retain the above copyright 6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above 8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following 9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided 10 # disclaimer in the documentation and/or other materials provided
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 if __name__ == '__main__': 93 if __name__ == '__main__':
94 94
95 parser = argparse.ArgumentParser() 95 parser = argparse.ArgumentParser()
96 parser.add_argument('--html') 96 parser.add_argument('--html')
97 parser.add_argument('--re', default='src/lexer/lexer_py.re') 97 parser.add_argument('--re', default='src/lexer/lexer_py.re')
98 parser.add_argument('--input') 98 parser.add_argument('--input')
99 parser.add_argument('--code') 99 parser.add_argument('--code')
100 parser.add_argument('--no-minimize-default', action='store_true') 100 parser.add_argument('--no-minimize-default', action='store_true')
101 parser.add_argument('--no-verify-default', action='store_true') 101 parser.add_argument('--no-verify-default', action='store_true')
102 parser.add_argument('--no-inline', action='store_true')
102 parser.add_argument('--verbose', action='store_true') 103 parser.add_argument('--verbose', action='store_true')
103 parser.add_argument('--debug-code', action='store_true') 104 parser.add_argument('--debug-code', action='store_true')
104 args = parser.parse_args() 105 args = parser.parse_args()
105 106
106 minimize_default = not args.no_minimize_default 107 minimize_default = not args.no_minimize_default
107 verbose = args.verbose 108 verbose = args.verbose
108 109
109 re_file = args.re 110 re_file = args.re
110 if verbose: 111 if verbose:
111 print "parsing %s" % re_file 112 print "parsing %s" % re_file
(...skipping 14 matching lines...) Expand all
126 if html_file: 127 if html_file:
127 html = generate_html(rule_processor, minimize_default) 128 html = generate_html(rule_processor, minimize_default)
128 with open(args.html, 'w') as f: 129 with open(args.html, 'w') as f:
129 f.write(html) 130 f.write(html)
130 if verbose: 131 if verbose:
131 print "wrote html to %s" % html_file 132 print "wrote html to %s" % html_file
132 133
133 code_file = args.code 134 code_file = args.code
134 if code_file: 135 if code_file:
135 code_generator = CodeGenerator(rule_processor, 136 code_generator = CodeGenerator(rule_processor,
136 minimize_default, 137 minimize_default = minimize_default,
137 args.debug_code) 138 log = verbose,
139 inline = not args.no_inline,
140 debug_print = args.debug_code)
138 code = code_generator.process() 141 code = code_generator.process()
139 with open(code_file, 'w') as f: 142 with open(code_file, 'w') as f:
140 f.write(code) 143 f.write(code)
141 if verbose: 144 if verbose:
142 print "wrote code to %s" % code_file 145 print "wrote code to %s" % code_file
143 146
144 input_file = args.input 147 input_file = args.input
145 if input_file: 148 if input_file:
146 with open(input_file, 'r') as f: 149 with open(input_file, 'r') as f:
147 lex(rule_processor, f.read()) 150 lex(rule_processor, f.read())
OLDNEW
« no previous file with comments | « tools/lexer_generator/code_generator_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698