| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 import re | 6 import re |
| 7 import subprocess | 7 import subprocess |
| 8 import tempfile | 8 import tempfile |
| 9 | 9 |
| 10 from pegparser import * | 10 from pegparser import * |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 re.compile(r'[0-9]+')) | 168 re.compile(r'[0-9]+')) |
| 169 | 169 |
| 170 def _FloatLiteral(): | 170 def _FloatLiteral(): |
| 171 return re.compile(r'[0-9]+\.[0-9]*') | 171 return re.compile(r'[0-9]+\.[0-9]*') |
| 172 | 172 |
| 173 # Attributes: | 173 # Attributes: |
| 174 def Attribute(): | 174 def Attribute(): |
| 175 return syntax_switch( | 175 return syntax_switch( |
| 176 # Web IDL: | 176 # Web IDL: |
| 177 [MAYBE(ExtAttrs), MAYBE(Stringifier), MAYBE(ReadOnly), | 177 [MAYBE(ExtAttrs), MAYBE(Stringifier), MAYBE(ReadOnly), |
| 178 'attribute', Type, Id, MAYBE(_AttrRaises), ';'], | 178 'attribute', Type, Id, ';'], |
| 179 # WebKit: | 179 # WebKit: |
| 180 [ | 180 [ |
| 181 MAYBE(Stringifier), | 181 MAYBE(Stringifier), |
| 182 MAYBE(ExtAttrs), MAYBE(Static), MAYBE(ReadOnly), 'attribute', MAYBE(Ex
tAttrs), | 182 MAYBE(ExtAttrs), MAYBE(Static), MAYBE(ReadOnly), 'attribute', MAYBE(Ex
tAttrs), |
| 183 Type, Id, MAYBE(_AttrRaises), ';'], | 183 Type, Id, ';'], |
| 184 # FremontCut: | 184 # FremontCut: |
| 185 [MAYBE(_Annotations), MAYBE(ExtAttrs), | 185 [MAYBE(_Annotations), MAYBE(ExtAttrs), |
| 186 MAYBE(_AttrGetterSetter), MAYBE(Stringifier), MAYBE(ReadOnly), | 186 MAYBE(_AttrGetterSetter), MAYBE(Stringifier), MAYBE(ReadOnly), |
| 187 'attribute', Type, Id, MAYBE(_AttrRaises), ';']) | 187 'attribute', Type, Id, ';']) |
| 188 | |
| 189 def _AttrRaises(): | |
| 190 return syntax_switch( | |
| 191 # Web IDL: | |
| 192 MANY(OR(GetRaises, SetRaises)), | |
| 193 # WebKit: | |
| 194 MANY(OR(GetRaises, SetRaises, Raises), separator=',')) | |
| 195 | 188 |
| 196 # Special fremontcut feature: | 189 # Special fremontcut feature: |
| 197 def _AttrGetterSetter(): | 190 def _AttrGetterSetter(): |
| 198 return OR(AttrGetter, AttrSetter) | 191 return OR(AttrGetter, AttrSetter) |
| 199 | 192 |
| 200 def AttrGetter(): | 193 def AttrGetter(): |
| 201 return 'getter' | 194 return 'getter' |
| 202 | 195 |
| 203 def AttrSetter(): | 196 def AttrSetter(): |
| 204 return 'setter' | 197 return 'setter' |
| 205 | 198 |
| 206 def ReadOnly(): | 199 def ReadOnly(): |
| 207 return 'readonly' | 200 return 'readonly' |
| 208 | 201 |
| 209 def GetRaises(): | |
| 210 return syntax_switch( | |
| 211 # Web IDL: | |
| 212 ['getraises', '(', _ScopedNames, ')'], | |
| 213 # WebKit: | |
| 214 ['getter', 'raises', '(', _ScopedNames, ')']) | |
| 215 | |
| 216 def SetRaises(): | |
| 217 return syntax_switch( | |
| 218 # Web IDL: | |
| 219 ['setraises', '(', _ScopedNames, ')'], | |
| 220 # WebKit: | |
| 221 ['setter', 'raises', '(', _ScopedNames, ')']) | |
| 222 | |
| 223 # Operation: | 202 # Operation: |
| 224 def Operation(): | 203 def Operation(): |
| 225 return syntax_switch( | 204 return syntax_switch( |
| 226 # Web IDL: | 205 # Web IDL: |
| 227 [MAYBE(ExtAttrs), MAYBE(Static), MAYBE(Stringifier), MAYBE(_Specials), | 206 [MAYBE(ExtAttrs), MAYBE(Static), MAYBE(Stringifier), MAYBE(_Specials), |
| 228 ReturnType, MAYBE(Id), '(', _Arguments, ')', MAYBE(Raises), | 207 ReturnType, MAYBE(Id), '(', _Arguments, ')', ';'], |
| 229 ';'], | |
| 230 # WebKit: | 208 # WebKit: |
| 231 [MAYBE(ExtAttrs), MAYBE(Static), | 209 [MAYBE(ExtAttrs), MAYBE(Static), |
| 232 ReturnType, MAYBE(Id), '(', _Arguments, ')', | 210 ReturnType, MAYBE(Id), '(', _Arguments, ')', ';'], |
| 233 MAYBE(Raises), ';'], | |
| 234 # FremontCut: | 211 # FremontCut: |
| 235 [MAYBE(_Annotations), MAYBE(ExtAttrs), MAYBE(Static), MAYBE(Stringifier)
, | 212 [MAYBE(_Annotations), MAYBE(ExtAttrs), MAYBE(Static), MAYBE(Stringifier)
, |
| 236 MAYBE(_Specials), ReturnType, MAYBE(Id), '(', _Arguments, ')', | 213 MAYBE(_Specials), ReturnType, MAYBE(Id), '(', _Arguments, ')', ';']) |
| 237 MAYBE(Raises), ';']) | |
| 238 | 214 |
| 239 def Static(): | 215 def Static(): |
| 240 return 'static' | 216 return 'static' |
| 241 | 217 |
| 242 def _Specials(): | 218 def _Specials(): |
| 243 return MANY(Special) | 219 return MANY(Special) |
| 244 | 220 |
| 245 def Special(): | 221 def Special(): |
| 246 return re.compile(r'getter|setter|creator|deleter|caller') | 222 return re.compile(r'getter|setter|creator|deleter|caller') |
| 247 | 223 |
| 248 def Stringifier(): | 224 def Stringifier(): |
| 249 return 'stringifier' | 225 return 'stringifier' |
| 250 | 226 |
| 251 def Raises(): | |
| 252 return ['raises', '(', _ScopedNames, ')'] | |
| 253 | |
| 254 # Operation arguments: | 227 # Operation arguments: |
| 255 def _Arguments(): | 228 def _Arguments(): |
| 256 return MAYBE(MANY(Argument, ',')) | 229 return MAYBE(MANY(Argument, ',')) |
| 257 | 230 |
| 258 def Argument(): | 231 def Argument(): |
| 259 return syntax_switch( | 232 return syntax_switch( |
| 260 # Web IDL: | 233 # Web IDL: |
| 261 [MAYBE(ExtAttrs), MAYBE(Optional), MAYBE('in'), | 234 [MAYBE(ExtAttrs), MAYBE(Optional), MAYBE('in'), |
| 262 MAYBE(Optional), Type, MAYBE(AnEllipsis), Id], | 235 MAYBE(Optional), Type, MAYBE(AnEllipsis), Id], |
| 263 # WebKit: | 236 # WebKit: |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 Args: | 411 Args: |
| 439 content -- text to parse. | 412 content -- text to parse. |
| 440 defines -- an array of pre-processor defines. | 413 defines -- an array of pre-processor defines. |
| 441 includePaths -- an array of path strings used by the | 414 includePaths -- an array of path strings used by the |
| 442 gcc pre-processor. | 415 gcc pre-processor. |
| 443 """ | 416 """ |
| 444 if self._syntax == WEBKIT_SYNTAX: | 417 if self._syntax == WEBKIT_SYNTAX: |
| 445 content = self._pre_process(content, defines, includePaths) | 418 content = self._pre_process(content, defines, includePaths) |
| 446 | 419 |
| 447 return self._pegparser.parse(content) | 420 return self._pegparser.parse(content) |
| OLD | NEW |