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

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

Issue 158823002: Experimental parser: refactor TransitionKey to use Term (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/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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 def p_maybe_modifier(self, p): 223 def p_maybe_modifier(self, p):
224 '''maybe_modifier : ONE_OR_MORE 224 '''maybe_modifier : ONE_OR_MORE
225 | ZERO_OR_ONE 225 | ZERO_OR_ONE
226 | ZERO_OR_MORE 226 | ZERO_OR_MORE
227 | REPEAT_BEGIN NUMBER REPEAT_END 227 | REPEAT_BEGIN NUMBER REPEAT_END
228 | REPEAT_BEGIN NUMBER COMMA NUMBER REPEAT_END 228 | REPEAT_BEGIN NUMBER COMMA NUMBER REPEAT_END
229 | empty''' 229 | empty'''
230 if len(p) == 4: 230 if len(p) == 4:
231 p[0] = ("REPEAT", p[2], p[2]) 231 p[0] = ("REPEAT", p[2], p[2])
232 elif len(p) == 5: 232 elif len(p) == 6:
233 p[0] = ("REPEAT", p[2], p[4]) 233 p[0] = ("REPEAT", p[2], p[4])
234 elif p[1]: 234 elif p[1]:
235 p[0] = (self.token_map[p[1]],) 235 p[0] = (self.token_map[p[1]],)
236 else: 236 else:
237 p[0] = None 237 p[0] = None
238 238
239 def p_literal(self, p): 239 def p_literal(self, p):
240 '''literal : LITERAL''' 240 '''literal : LITERAL'''
241 p[0] = Term('LITERAL', p[1]) 241 p[0] = Term('LITERAL', p[1])
242 242
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 @staticmethod 284 @staticmethod
285 def __cat(left, right): 285 def __cat(left, right):
286 assert left 286 assert left
287 return NfaBuilder.cat_terms([left] if not right else [left, right]) 287 return NfaBuilder.cat_terms([left] if not right else [left, right])
288 288
289 @staticmethod 289 @staticmethod
290 def parse(string): 290 def parse(string):
291 new_lexer = lambda: RegexLexer() 291 new_lexer = lambda: RegexLexer()
292 new_parser = lambda: RegexParser() 292 new_parser = lambda: RegexParser()
293 return ParserBuilder.parse(string, "RegexParser", new_lexer, new_parser) 293 return ParserBuilder.parse(string, "RegexParser", new_lexer, new_parser)
OLDNEW
« no previous file with comments | « tools/lexer_generator/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