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

Side by Side Diff: mojo/public/tools/bindings/pylib/mojom/parse/lexer.py

Issue 474063002: Mojo: add support for {double,float}.{INFINITY,NEGATIVE_INFINITY,NAN} (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import imp 5 import imp
6 import os.path 6 import os.path
7 import sys 7 import sys
8 8
9 def _GetDirAbove(dirname): 9 def _GetDirAbove(dirname):
10 """Returns the directory "above" this file containing |dirname| (which must 10 """Returns the directory "above" this file containing |dirname| (which must
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 # string literals (K&R2: A.2.6) 138 # string literals (K&R2: A.2.6)
139 string_char = r"""([^"\\\n]|"""+escape_sequence+')' 139 string_char = r"""([^"\\\n]|"""+escape_sequence+')'
140 string_literal = '"'+string_char+'*"' 140 string_literal = '"'+string_char+'*"'
141 bad_string_literal = '"'+string_char+'*'+bad_escape+string_char+'*"' 141 bad_string_literal = '"'+string_char+'*'+bad_escape+string_char+'*"'
142 142
143 # floating constants (K&R2: A.2.5.3) 143 # floating constants (K&R2: A.2.5.3)
144 exponent_part = r"""([eE][-+]?[0-9]+)""" 144 exponent_part = r"""([eE][-+]?[0-9]+)"""
145 fractional_constant = r"""([0-9]*\.[0-9]+)|([0-9]+\.)""" 145 fractional_constant = r"""([0-9]*\.[0-9]+)|([0-9]+\.)"""
146 floating_constant = \ 146 floating_constant = \
147 '(((('+fractional_constant+')'+ \ 147 '(((('+fractional_constant+')'+ \
148 exponent_part+'?)|([0-9]+'+exponent_part+')))' 148 exponent_part+'?)|([0-9]+'+exponent_part+'))|[-+]?Inf|NaN)'
viettrungluu 2014/08/14 22:32:25 Currently, for numbers, we use unary minus (and pl
149 149
150 # Ordinals 150 # Ordinals
151 ordinal = r'@[0-9]+' 151 ordinal = r'@[0-9]+'
152 missing_ordinal_value = r'@' 152 missing_ordinal_value = r'@'
153 # Don't allow ordinal values in octal (even invalid octal, like 09) or 153 # Don't allow ordinal values in octal (even invalid octal, like 09) or
154 # hexadecimal. 154 # hexadecimal.
155 octal_or_hex_ordinal_disallowed = r'@((0[0-9]+)|('+hex_prefix+hex_digits+'))' 155 octal_or_hex_ordinal_disallowed = r'@((0[0-9]+)|('+hex_prefix+hex_digits+'))'
156 156
157 ## 157 ##
158 ## Rules for the normal state 158 ## Rules for the normal state
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 return t 241 return t
242 242
243 # Ignore C and C++ style comments 243 # Ignore C and C++ style comments
244 def t_COMMENT(self, t): 244 def t_COMMENT(self, t):
245 r'(/\*(.|\n)*?\*/)|(//.*(\n[ \t]*//.*)*)' 245 r'(/\*(.|\n)*?\*/)|(//.*(\n[ \t]*//.*)*)'
246 t.lexer.lineno += t.value.count("\n") 246 t.lexer.lineno += t.value.count("\n")
247 247
248 def t_error(self, t): 248 def t_error(self, t):
249 msg = "Illegal character %s" % repr(t.value[0]) 249 msg = "Illegal character %s" % repr(t.value[0])
250 self._error(msg, t) 250 self._error(msg, t)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698