OLD | NEW |
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 'IMPORT', | 56 'IMPORT', |
57 'MODULE', | 57 'MODULE', |
58 'STRUCT', | 58 'STRUCT', |
59 'INTERFACE', | 59 'INTERFACE', |
60 'ENUM', | 60 'ENUM', |
61 'CONST', | 61 'CONST', |
62 'TRUE', | 62 'TRUE', |
63 'FALSE', | 63 'FALSE', |
64 'DEFAULT', | 64 'DEFAULT', |
65 'ARRAY' | 65 'ARRAY', |
| 66 'MAP' |
66 ) | 67 ) |
67 | 68 |
68 keyword_map = {} | 69 keyword_map = {} |
69 for keyword in keywords: | 70 for keyword in keywords: |
70 keyword_map[keyword.lower()] = keyword | 71 keyword_map[keyword.lower()] = keyword |
71 | 72 |
72 ## | 73 ## |
73 ## All the tokens recognized by the lexer | 74 ## All the tokens recognized by the lexer |
74 ## | 75 ## |
75 tokens = keywords + ( | 76 tokens = keywords + ( |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 return t | 243 return t |
243 | 244 |
244 # Ignore C and C++ style comments | 245 # Ignore C and C++ style comments |
245 def t_COMMENT(self, t): | 246 def t_COMMENT(self, t): |
246 r'(/\*(.|\n)*?\*/)|(//.*(\n[ \t]*//.*)*)' | 247 r'(/\*(.|\n)*?\*/)|(//.*(\n[ \t]*//.*)*)' |
247 t.lexer.lineno += t.value.count("\n") | 248 t.lexer.lineno += t.value.count("\n") |
248 | 249 |
249 def t_error(self, t): | 250 def t_error(self, t): |
250 msg = "Illegal character %s" % repr(t.value[0]) | 251 msg = "Illegal character %s" % repr(t.value[0]) |
251 self._error(msg, t) | 252 self._error(msg, t) |
OLD | NEW |