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

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

Issue 59263003: Experimental lexer generator: parse \000 etc. inside char classes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: . 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/regex_parser.py ('k') | no next file » | 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 19 matching lines...) Expand all
30 from regex_parser import RegexParser 30 from regex_parser import RegexParser
31 from nfa import NfaBuilder 31 from nfa import NfaBuilder
32 from transition_keys import TransitionKey 32 from transition_keys import TransitionKey
33 33
34 class RuleParser: 34 class RuleParser:
35 35
36 tokens = RuleLexer.tokens 36 tokens = RuleLexer.tokens
37 37
38 def __init__(self): 38 def __init__(self):
39 self.aliases = { 39 self.aliases = {
40 'eof' : RegexParser.parse("eof"), #RegexParser.parse("[\0]"), 40 'eof' : RegexParser.parse("[\\0]"),
41 'any' : RegexParser.parse("."), 41 'any' : RegexParser.parse("."),
42 } 42 }
43 self.character_classes = {} 43 self.character_classes = {}
44 self.current_transition = None 44 self.current_transition = None
45 self.rules = {} 45 self.rules = {}
46 46
47 def p_statements(self, p): 47 def p_statements(self, p):
48 'statements : statement maybe_statements' 48 'statements : statement maybe_statements'
49 49
50 def p_maybe_statement(self, p): 50 def p_maybe_statement(self, p):
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 def p_error(self, p): 163 def p_error(self, p):
164 raise Exception("Syntax error in input '%s'" % p) 164 raise Exception("Syntax error in input '%s'" % p)
165 165
166 def build(self, **kwargs): 166 def build(self, **kwargs):
167 self.parser = yacc.yacc(module=self, debug=0, write_tables=0, **kwargs) 167 self.parser = yacc.yacc(module=self, debug=0, write_tables=0, **kwargs)
168 self.lexer = RuleLexer() 168 self.lexer = RuleLexer()
169 self.lexer.build(**kwargs) 169 self.lexer.build(**kwargs)
170 170
171 def parse(self, data): 171 def parse(self, data):
172 return self.parser.parse(data, lexer=self.lexer.lexer) 172 return self.parser.parse(data, lexer=self.lexer.lexer)
OLDNEW
« no previous file with comments | « tools/lexer_generator/regex_parser.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698