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

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

Issue 290693003: Mojo: Mojom: Remove integer suffixes (e.g., u, l, ul, etc.). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 7 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 | « no previous file | mojo/public/tools/bindings/pylib/mojom_tests/parse/lexer_unittest.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 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 # Disable lint check for finding modules: 9 # Disable lint check for finding modules:
10 # pylint: disable=F0401 10 # pylint: disable=F0401
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 ## Regexes for use in tokens 113 ## Regexes for use in tokens
114 ## 114 ##
115 115
116 # valid C identifiers (K&R2: A.2.3) 116 # valid C identifiers (K&R2: A.2.3)
117 identifier = r'[a-zA-Z_][0-9a-zA-Z_]*' 117 identifier = r'[a-zA-Z_][0-9a-zA-Z_]*'
118 118
119 hex_prefix = '0[xX]' 119 hex_prefix = '0[xX]'
120 hex_digits = '[0-9a-fA-F]+' 120 hex_digits = '[0-9a-fA-F]+'
121 121
122 # integer constants (K&R2: A.2.5.1) 122 # integer constants (K&R2: A.2.5.1)
123 integer_suffix_opt = \ 123 decimal_constant = '0|([1-9][0-9]*)'
124 r'(([uU]ll)|([uU]LL)|(ll[uU]?)|(LL[uU]?)|([uU][lL])|([lL][uU]?)|[uU])?' 124 octal_constant = '0[0-7]+'
125 decimal_constant = \ 125 hex_constant = hex_prefix+hex_digits
126 '(0'+integer_suffix_opt+')|([1-9][0-9]*'+integer_suffix_opt+')'
127 octal_constant = '0[0-7]*'+integer_suffix_opt
128 hex_constant = hex_prefix+hex_digits+integer_suffix_opt
129 126
130 bad_octal_constant = '0[0-7]*[89]' 127 bad_octal_constant = '0[0-7]*[89]'
131 128
132 # character constants (K&R2: A.2.5.2) 129 # character constants (K&R2: A.2.5.2)
133 # Note: a-zA-Z and '.-~^_!=&;,' are allowed as escape chars to support #line 130 # Note: a-zA-Z and '.-~^_!=&;,' are allowed as escape chars to support #line
134 # directives with Windows paths as filenames (..\..\dir\file) 131 # directives with Windows paths as filenames (..\..\dir\file)
135 # For the same reason, decimal_escape allows all digit sequences. We want to 132 # For the same reason, decimal_escape allows all digit sequences. We want to
136 # parse all correct code, even if it means to sometimes parse incorrect 133 # parse all correct code, even if it means to sometimes parse incorrect
137 # code. 134 # code.
138 # 135 #
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 return t 281 return t
285 282
286 # Ignore C and C++ style comments 283 # Ignore C and C++ style comments
287 def t_COMMENT(self, t): 284 def t_COMMENT(self, t):
288 r'(/\*(.|\n)*?\*/)|(//.*(\n[ \t]*//.*)*)' 285 r'(/\*(.|\n)*?\*/)|(//.*(\n[ \t]*//.*)*)'
289 pass 286 pass
290 287
291 def t_error(self, t): 288 def t_error(self, t):
292 msg = 'Illegal character %s' % repr(t.value[0]) 289 msg = 'Illegal character %s' % repr(t.value[0])
293 self._error(msg, t) 290 self._error(msg, t)
OLDNEW
« no previous file with comments | « no previous file | mojo/public/tools/bindings/pylib/mojom_tests/parse/lexer_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698