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

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

Issue 78713002: Experimental lexer generator: generate code for utf-16 character classes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Code review (dcarney) 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.py ('k') | tools/lexer_generator/transition_key_test.py » ('j') | 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 for t in rule_processor.default_automata().dfa().lex(string + '\0'): 90 for t in rule_processor.default_automata().dfa().lex(string + '\0'):
91 print t 91 print t
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('--char-type') 100 parser.add_argument('--encoding', default='latin1')
101 parser.add_argument('--no-minimize-default', action='store_true') 101 parser.add_argument('--no-minimize-default', action='store_true')
102 parser.add_argument('--no-verify-default', action='store_true') 102 parser.add_argument('--no-verify-default', action='store_true')
103 parser.add_argument('--no-inline', action='store_true') 103 parser.add_argument('--no-inline', action='store_true')
104 parser.add_argument('--verbose', action='store_true') 104 parser.add_argument('--verbose', action='store_true')
105 parser.add_argument('--debug-code', action='store_true') 105 parser.add_argument('--debug-code', action='store_true')
106 args = parser.parse_args() 106 args = parser.parse_args()
107 107
108 minimize_default = not args.no_minimize_default 108 minimize_default = not args.no_minimize_default
109 verbose = args.verbose 109 verbose = args.verbose
110 110
(...skipping 15 matching lines...) Expand all
126 126
127 html_file = args.html 127 html_file = args.html
128 if html_file: 128 if html_file:
129 html = generate_html(rule_processor, minimize_default) 129 html = generate_html(rule_processor, minimize_default)
130 with open(args.html, 'w') as f: 130 with open(args.html, 'w') as f:
131 f.write(html) 131 f.write(html)
132 if verbose: 132 if verbose:
133 print "wrote html to %s" % html_file 133 print "wrote html to %s" % html_file
134 134
135 code_file = args.code 135 code_file = args.code
136 char_type = args.char_type
137 if not char_type:
138 char_type = 'uint8_t'
139
140 if code_file: 136 if code_file:
141 code_generator = CodeGenerator(rule_processor, 137 code_generator = CodeGenerator(rule_processor,
142 char_type, 138 encoding = args.encoding,
143 minimize_default = minimize_default, 139 minimize_default = minimize_default,
144 log = verbose, 140 log = verbose,
145 inline = not args.no_inline, 141 inline = not args.no_inline,
146 debug_print = args.debug_code) 142 debug_print = args.debug_code)
147 code = code_generator.process() 143 code = code_generator.process()
148 with open(code_file, 'w') as f: 144 with open(code_file, 'w') as f:
149 f.write(code) 145 f.write(code)
150 if verbose: 146 if verbose:
151 print "wrote code to %s" % code_file 147 print "wrote code to %s" % code_file
152 148
153 input_file = args.input 149 input_file = args.input
154 if input_file: 150 if input_file:
155 with open(input_file, 'r') as f: 151 with open(input_file, 'r') as f:
156 lex(rule_processor, f.read()) 152 lex(rule_processor, f.read())
OLDNEW
« no previous file with comments | « tools/lexer_generator/code_generator.py ('k') | tools/lexer_generator/transition_key_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698