Bug 762758 - Implement underscore-escape in xpidl parser r=khuey
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Tue, 12 Jun 2012 22:01:06 +0900
changeset 96468 88d5451ed337a1b02f453153e8b4463f7051bfb2
parent 96467 6cced69f7fb6fc863aebedac308a6e3a297d4ee3
child 96469 1bdd81c4d92699083da52a1d9d6de494f2da5443
push id10545
push usermasayuki@d-toybox.com
push dateTue, 12 Jun 2012 13:01:36 +0000
treeherdermozilla-inbound@88d5451ed337 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs762758
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 762758 - Implement underscore-escape in xpidl parser r=khuey
xpcom/idl-parser/xpidl.py
--- a/xpcom/idl-parser/xpidl.py
+++ b/xpcom/idl-parser/xpidl.py
@@ -193,16 +193,18 @@ class NameMap(object):
         return self._d.itervalues()
 
     def __contains__(self, key):
         return key in builtinMap or key in self._d
 
     def set(self, object):
         if object.name in builtinMap:
             raise IDLError("name '%s' is a builtin and cannot be redeclared" % (object.name), object.location)
+        if object.name.startswith("_"):
+            object.name = object.name[1:]
         if object.name in self._d:
             old = self._d[object.name]
             if old == object: return
             if isinstance(old, Forward) and isinstance(object, Interface):
                 self._d[object.name] = object
             elif isinstance(old, Interface) and isinstance(object, Forward):
                 pass
             else:
@@ -1113,17 +1115,17 @@ class IDLParser(object):
     def t_singlelinecomment(self, t):
         r'(?m)//.*?$'
 
     def t_IID(self, t):
         return t
     t_IID.__doc__ = r'%(c)s{8}-%(c)s{4}-%(c)s{4}-%(c)s{4}-%(c)s{12}' % {'c': hexchar}
 
     def t_IDENTIFIER(self, t):
-        r'(unsigned\ long\ long|unsigned\ short|unsigned\ long|long\ long)(?![A-Za-z][A-Za-z_0-9])|[A-Za-z][A-Za-z_0-9]*'
+        r'(unsigned\ long\ long|unsigned\ short|unsigned\ long|long\ long)(?!_?[A-Za-z][A-Za-z_0-9])|_?[A-Za-z][A-Za-z_0-9]*'
         t.type = self.keywords.get(t.value, 'IDENTIFIER')
         return t
 
     def t_LCDATA(self, t):
         r'(?s)%\{[ ]*C\+\+[ ]*\n(?P<cdata>.*?\n?)%\}[ ]*(C\+\+)?'
         t.type = 'CDATA'
         t.value = t.lexer.lexmatch.group('cdata')
         t.lexer.lineno += t.value.count('\n')