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

Unified Diff: tools/lexer_generator/rule_parser.py

Issue 132693018: Experimental parser: handling unique keys in merges (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 11 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/nfa_builder.py ('k') | tools/lexer_generator/transition_keys.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer_generator/rule_parser.py
diff --git a/tools/lexer_generator/rule_parser.py b/tools/lexer_generator/rule_parser.py
index 29cb0ee34f1b771fa9a6aa19281fa1fde9cad2a8..061c78be8390735db86a4b2f186e5b445e9f2ea5 100644
--- a/tools/lexer_generator/rule_parser.py
+++ b/tools/lexer_generator/rule_parser.py
@@ -87,7 +87,7 @@ class RuleParser:
if not state.current_state in state.rules:
state.rules[state.current_state] = {
'default_action': None,
- 'catch_all' : None,
+ 'uniques' : {},
'regex' : []
}
p[0] = state.current_state
@@ -113,8 +113,9 @@ class RuleParser:
assert not rules['default_action']
rules['default_action'] = action
elif p[1] == 'catch_all':
- assert not rules['catch_all']
- rules['catch_all'] = (precedence, action)
+ assert p[1] not in rules['uniques']
+ rules['uniques'][p[1]] = True
+ rules['regex'].append((NfaBuilder.unique_key(p[1]), precedence, action))
else:
regex = p[1]
rules['regex'].append((regex, precedence, action))
@@ -317,10 +318,6 @@ class RuleProcessor(object):
graph = NfaBuilder.join_subgraph(
graph, transition, rule_map[transition])
graphs.append(graph)
- if v['catch_all']:
- (precedence, catch_all) = v['catch_all']
- assert catch_all == (None, None, 'continue'), "unimplemented"
- graphs.append(NfaBuilder.add_continue(NfaBuilder.catch_all()))
graph = NfaBuilder.or_graphs(graphs)
rule_map[subgraph] = graph
# process first the subgraphs, then the default graph
« no previous file with comments | « tools/lexer_generator/nfa_builder.py ('k') | tools/lexer_generator/transition_keys.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698