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

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

Issue 155573004: Experimental parser: Abstact state matching (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/automaton.py ('k') | tools/lexer_generator/dfa.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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 __jump_labels = ['state_entry', 'after_entry_code'] 58 __jump_labels = ['state_entry', 'after_entry_code']
59 59
60 @staticmethod 60 @staticmethod
61 def __transform_state(encoding, state): 61 def __transform_state(encoding, state):
62 # action data 62 # action data
63 action = state.action() 63 action = state.action()
64 entry_action = action.entry_action() 64 entry_action = action.entry_action()
65 match_action = action.match_action() 65 match_action = action.match_action()
66 # generate ordered transitions 66 # generate ordered transitions
67 transitions = map(lambda (k, v) : (k, v.node_number()), 67 transitions = map(lambda (k, v) : (k, v.node_number()),
68 state.transitions().items()) 68 state.key_state_iter())
69 def cmp(left, right): 69 def cmp(left, right):
70 return TransitionKey.canonical_compare(left[0], right[0]) 70 return TransitionKey.canonical_compare(left[0], right[0])
71 transitions = sorted(transitions, cmp) 71 transitions = sorted(transitions, cmp)
72 # map transition keys to disjoint ranges and collect stats 72 # map transition keys to disjoint ranges and collect stats
73 disjoint_keys = [] 73 disjoint_keys = []
74 unique_transitions = {} 74 unique_transitions = {}
75 old_transitions = transitions 75 old_transitions = transitions
76 transitions = [] 76 transitions = []
77 (class_keys, distinct_keys, ranges) = (0, 0, 0) 77 (class_keys, distinct_keys, ranges) = (0, 0, 0)
78 zero_transition = None 78 zero_transition = None
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 423
424 return template.render( 424 return template.render(
425 start_node_number = 0, 425 start_node_number = 0,
426 debug_print = self.__debug_print, 426 debug_print = self.__debug_print,
427 default_action = default_action, 427 default_action = default_action,
428 dfa_states = dfa_states, 428 dfa_states = dfa_states,
429 jump_table = self.__jump_table, 429 jump_table = self.__jump_table,
430 encoding = encoding.name(), 430 encoding = encoding.name(),
431 char_type = char_type, 431 char_type = char_type,
432 upper_bound = encoding.primary_range()[1]) 432 upper_bound = encoding.primary_range()[1])
OLDNEW
« no previous file with comments | « tools/lexer_generator/automaton.py ('k') | tools/lexer_generator/dfa.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698