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

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

Issue 61893023: Experimental parser: split out NfaBuilder (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/nfa_builder.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 10 matching lines...) Expand all
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 import ply.yacc as yacc 28 import ply.yacc as yacc
29 from rule_lexer import RuleLexer 29 from rule_lexer import RuleLexer
30 from regex_parser import RegexParser 30 from regex_parser import RegexParser
31 from nfa import NfaBuilder 31 from nfa_builder import NfaBuilder
32 from transition_keys import TransitionKey 32 from transition_keys import TransitionKey
33 33
34 class RuleParserState: 34 class RuleParserState:
35 35
36 def __init__(self): 36 def __init__(self):
37 self.aliases = { 37 self.aliases = {
38 'eof' : RegexParser.parse("[\\0]"), 38 'eof' : RegexParser.parse("[\\0]"),
39 } 39 }
40 self.character_classes = {} 40 self.character_classes = {}
41 self.current_state = None 41 self.current_state = None
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 parser.build() 205 parser.build()
206 RuleParser.__static_instance = parser 206 RuleParser.__static_instance = parser
207 parser.__state = parser_state 207 parser.__state = parser_state
208 try: 208 try:
209 parser.parser.parse(data, lexer=parser.lexer.lexer) 209 parser.parser.parse(data, lexer=parser.lexer.lexer)
210 except Exception: 210 except Exception:
211 RuleParser.__static_instance = None 211 RuleParser.__static_instance = None
212 raise 212 raise
213 parser.__state = None 213 parser.__state = None
214 assert parser_state.transitions <= set(parser_state.rules.keys()) 214 assert parser_state.transitions <= set(parser_state.rules.keys())
OLDNEW
« no previous file with comments | « tools/lexer_generator/nfa_builder.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698