print("<" + input_line) print(">" + output_line) print() if __name__ == "__main__": # called from the command line sys.excepthook = debugHook parser = parser.Parser(ui=ui()) if (1 < len(sys.argv)): for fileName in sys.argv[1:]: print("Parsing: " + fileName) file = open(fileName) parser.reset() text = file.read() parser.parse(text) assert (text == unicode(parser)) quit() idl = u"""dictionary CSSFontFaceLoadEventInit : EventInit { sequence<CSSFontFaceRule> fontfaces = [ ]; }; interface Simple{ serializer; serializer = { foo }; serializer cereal(short one); iterable<Foo>; iterable<Foo, Bar>; readonly maplike<Foo, Bar>; setlike<Uint8ClampedArray>; attribute boolean required; static attribute Foo foo;
print(">" + output_line) print() if __name__ == "__main__": # called from the command line sys.excepthook = debugHook sys.stdout = codecs.getwriter('utf8')(sys.stdout) parser = parser.Parser(ui=ui()) if (1 < len(sys.argv)): for fileName in sys.argv[1:]: print("Parsing: " + fileName) file = open(fileName) parser.reset() text = file.read() parser.parse(text) assert (text == unicode(parser)) quit() idl = u"""dictionary CSSFontFaceLoadEventInit : EventInit { sequence<CSSFontFaceRule> fontfaces = [ ]; }; interface Simple{ serializer; serializer = { foo }; serializer cereal(short one); iterable<Foo>; iterable<Foo, Bar>; async iterable<Foo, Bar>; readonly maplike<Foo, Bar>; setlike<Uint8ClampedArray>; attribute boolean required; static attribute Foo foo;
callback callFoo = short(); callback callFoo2 = unsigned long long(unrestricted double one, DOMString two, Fubar ... three); callback interface callMe { attribute short round setraises (for the heck of it); }; exception foo:bar { short round; const long one = 2; Foo foo; unsigned long long longest; }; """ # idl = idl.replace(' ', ' ') print "IDL >>>\n" + idl + "\n<<<" parser.parse(idl) testDifference(idl, unicode(parser)) print "MARKED UP:" marker = NullMarker() testDifference(idl, parser.markup(marker)) assert(marker.text == idl) print parser.markup(Marker()) print repr(parser) print "Complexity: " + unicode(parser.complexityFactor) for construct in parser.constructs: print unicode(construct.idlType) + u': ' + unicode(construct.normalName) for member in construct: