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

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

Issue 148283007: Experimental parser: remove bom handling (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/lexer_generator/code_generator.jinja ('k') | tools/lexer_generator/transition_keys.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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 'non_primary_letter' : 'IsLetter', 198 'non_primary_letter' : 'IsLetter',
199 'non_primary_identifier_part_not_letter' : 'IsIdentifierPartNotLetter', 199 'non_primary_identifier_part_not_letter' : 'IsIdentifierPartNotLetter',
200 'non_primary_line_terminator' : 'IsLineTerminator', 200 'non_primary_line_terminator' : 'IsLineTerminator',
201 } 201 }
202 202
203 def __rewrite_deferred_transitions(self, state): 203 def __rewrite_deferred_transitions(self, state):
204 transitions = state['deferred_transitions'] 204 transitions = state['deferred_transitions']
205 if not transitions: 205 if not transitions:
206 return 206 return
207 encoding = self.__dfa.encoding() 207 encoding = self.__dfa.encoding()
208 bom = 'byte_order_mark'
209 catch_all = 'non_primary_everything_else' 208 catch_all = 'non_primary_everything_else'
210 all_classes = set(encoding.class_name_iter()) 209 all_classes = set(encoding.class_name_iter())
211 call_classes = all_classes - set([bom, catch_all]) 210 call_classes = all_classes - set([catch_all])
212 def remap_transition(class_name): 211 def remap_transition(class_name):
213 if class_name in call_classes: 212 if class_name in call_classes:
214 return ('LONG_CHAR_CLASS', 'call', self.__call_map[class_name]) 213 return ('LONG_CHAR_CLASS', 'call', self.__call_map[class_name])
215 if class_name == bom:
216 return ('LONG_CHAR_CLASS', class_name)
217 raise Exception(class_name) 214 raise Exception(class_name)
218 long_class_transitions = [] 215 long_class_transitions = []
219 long_class_map = {} 216 long_class_map = {}
220 catchall_transition = None 217 catchall_transition = None
221 # loop through and remove catch_all_transitions 218 # loop through and remove catch_all_transitions
222 for (classes, transition_node_id) in transitions: 219 for (classes, transition_node_id) in transitions:
223 lct = [] 220 lct = []
224 has_catch_all = False 221 has_catch_all = False
225 for (class_type, class_name) in classes: 222 for (class_type, class_name) in classes:
226 assert not class_name in long_class_map 223 assert not class_name in long_class_map
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 422
426 return template.render( 423 return template.render(
427 start_node_number = 0, 424 start_node_number = 0,
428 debug_print = self.__debug_print, 425 debug_print = self.__debug_print,
429 default_action = default_action, 426 default_action = default_action,
430 dfa_states = dfa_states, 427 dfa_states = dfa_states,
431 jump_table = self.__jump_table, 428 jump_table = self.__jump_table,
432 encoding = encoding.name(), 429 encoding = encoding.name(),
433 char_type = char_type, 430 char_type = char_type,
434 upper_bound = encoding.primary_range()[1]) 431 upper_bound = encoding.primary_range()[1])
OLDNEW
« no previous file with comments | « tools/lexer_generator/code_generator.jinja ('k') | tools/lexer_generator/transition_keys.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698