Index: bindings/scripts/blink_idl_parser.py |
diff --git a/bindings/scripts/blink_idl_parser.py b/bindings/scripts/blink_idl_parser.py |
index 6b205f2421c0c3f18ac2d51bad1fdce7988fe697..59218a8fd85bd332ae1a7da1814c4bda53a65280 100644 |
--- a/bindings/scripts/blink_idl_parser.py |
+++ b/bindings/scripts/blink_idl_parser.py |
@@ -71,6 +71,7 @@ from idl_parser.idl_parser import IDLParser, ListFromConcat |
from idl_parser.idl_parser import ParseFile as parse_file |
from blink_idl_lexer import BlinkIDLLexer |
+import blink_idl_lexer |
# Explicitly set starting symbol to rule defined only in base parser. |
@@ -332,23 +333,17 @@ class BlinkIDLParser(IDLParser): |
elif len(p) == 3: |
p[0] = ListFromConcat(self.BuildTrue('NULLABLE'), p[2]) |
- # [b76.1] Add support for compound Extended Attribute values (A&B and A|B) |
+ # [b94] Add support for OR Extended Attribute values "A|B" |
def p_ExtendedAttributeIdentList(self, p): |
- """ExtendedAttributeIdentList : identifier '=' identifier '&' IdentAndList |
+ """ExtendedAttributeIdentList : identifier '=' '(' IdentifierList ')' |
| identifier '=' identifier '|' IdentOrList""" |
- value = self.BuildAttribute('VALUE', p[3] + p[4] + p[5]) |
- p[0] = self.BuildNamed('ExtAttribute', p, 1, value) |
- |
- # [b76.2] A&B&C |
- def p_IdentAndList(self, p): |
- """IdentAndList : identifier '&' IdentAndList |
- | identifier""" |
- if len(p) > 3: |
- p[0] = p[1] + p[2] + p[3] |
+ if type(p[4]) is list: |
+ value = self.BuildAttribute('VALUE', ','.join(p[4])) |
else: |
- p[0] = p[1] |
+ value = self.BuildAttribute('VALUE', p[3] + p[4] + p[5]) |
+ p[0] = self.BuildNamed('ExtAttribute', p, 1, value) |
- # [b76.3] A|B|C |
+ # [b94.1] A|B|C |
def p_IdentOrList(self, p): |
"""IdentOrList : identifier '|' IdentOrList |
| identifier""" |
@@ -380,6 +375,8 @@ class BlinkIDLParser(IDLParser): |
def __init__(self, |
# common parameters |
debug=False, |
+ # local parameters |
+ rewrite_tables=False, |
# idl_parser parameters |
lexer=None, verbose=False, mute_error=False, |
# yacc parameters |
@@ -394,6 +391,11 @@ class BlinkIDLParser(IDLParser): |
write_tables = True |
if outputdir: |
picklefile = picklefile or os.path.join(outputdir, 'parsetab.pickle') |
+ if rewrite_tables: |
+ try: |
+ os.unlink(picklefile) |
+ except OSError: |
+ pass |
lexer = lexer or BlinkIDLLexer(debug=debug, |
outputdir=outputdir, |
@@ -433,13 +435,17 @@ class BlinkIDLParser(IDLParser): |
################################################################################ |
def main(argv): |
- # If file itself executed, cache parse table |
+ # If file itself executed, cache lex/parse tables |
try: |
outputdir = argv[1] |
except IndexError as err: |
print 'Usage: %s OUTPUT_DIR' % argv[0] |
return 1 |
- parser = BlinkIDLParser(outputdir=outputdir) |
+ blink_idl_lexer.main(argv) |
+ # Important: rewrite_tables=True causes the cache file to be deleted if it |
+ # exists, thus making sure that PLY doesn't load it instead of regenerating |
+ # the parse table. |
+ parser = BlinkIDLParser(outputdir=outputdir, rewrite_tables=True) |
if __name__ == '__main__': |