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

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

Issue 59903027: Experimental parser: more escaping (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_lexer.py ('k') | tools/lexer_generator/rule_parser.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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 __special_identifiers = set(map(lambda s: s.lower(), 73 __special_identifiers = set(map(lambda s: s.lower(),
74 ['DEFAULT', 'DEFAULT_ACTION', 'CATCH_ALL', 'PUSH_TOKEN'])) 74 ['DEFAULT', 'DEFAULT_ACTION', 'CATCH_ALL', 'PUSH_TOKEN']))
75 75
76 def t_IDENTIFIER(self, t): 76 def t_IDENTIFIER(self, t):
77 r'[a-zA-Z][a-zA-Z0-9_]*' 77 r'[a-zA-Z][a-zA-Z0-9_]*'
78 if t.value in self.__special_identifiers: 78 if t.value in self.__special_identifiers:
79 t.type = t.value.upper() 79 t.type = t.value.upper()
80 return t 80 return t
81 81
82 t_STRING = r'"((\\("|\w|\\))|[^\\"])+"' 82 t_STRING = r'"((\\("|\w|\\))|[^\\"])+"'
83 t_REGEX = r'/[^\/]+/' 83 t_REGEX = r'/(\\/|[^/])+/'
84 t_CHARACTER_CLASS_REGEX = r'\[([^\]]|\\\])+\]' 84 t_CHARACTER_CLASS_REGEX = r'\[([^\]]|\\\])+\]'
85 85
86 t_PLUS = r'\+' 86 t_PLUS = r'\+'
87 t_QUESTION_MARK = r'\?' 87 t_QUESTION_MARK = r'\?'
88 t_STAR = r'\*' 88 t_STAR = r'\*'
89 t_OR = r'\|' 89 t_OR = r'\|'
90 t_EQUALS = '=' 90 t_EQUALS = '='
91 t_LEFT_PARENTHESIS = r'\(' 91 t_LEFT_PARENTHESIS = r'\('
92 t_RIGHT_PARENTHESIS = r'\)' 92 t_RIGHT_PARENTHESIS = r'\)'
93 t_LESS_THAN = '<' 93 t_LESS_THAN = '<'
(...skipping 23 matching lines...) Expand all
117 t.type = 'CODE_FRAGMENT' 117 t.type = 'CODE_FRAGMENT'
118 else: 118 else:
119 self.lexer.pop_state() 119 self.lexer.pop_state()
120 return t 120 return t
121 121
122 def t_ANY_error(self, t): 122 def t_ANY_error(self, t):
123 raise Exception("Illegal character '%s'" % t.value[0]) 123 raise Exception("Illegal character '%s'" % t.value[0])
124 124
125 def build(self, **kwargs): 125 def build(self, **kwargs):
126 self.lexer = lex.lex(module=self, **kwargs) 126 self.lexer = lex.lex(module=self, **kwargs)
OLDNEW
« no previous file with comments | « tools/lexer_generator/regex_lexer.py ('k') | tools/lexer_generator/rule_parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698