darobin / webidl.js

DEPRECATED — Use https://github.com/darobin/webidl2.js instead
http://berjon.com/
26 stars 10 forks source link

can't handle HTML5 type DOMStringList #1

Open davidflanagan opened 13 years ago

davidflanagan commented 13 years ago

The parser can't parse the type DOMSringList, or, in general any type name that has one of the primitive WebIDL types as a prefix. So longStringList would also not parse. I don't know if this is a problem with the grammar or the parser generator. But consider this line from node/WebIDLParser.js:

                if (input.substr(pos, 9) === "DOMString") {
                  var result4 = "DOMString"
                  pos += 9;

It looks ahead for known type names, but doesn't verify that they are at token boundaries.

darobin commented 13 years ago

Do you have a test handy? I think it's a problem with the grammar and I think I know how to fix it, but a copy of the IDL you're trying to parse (not just the bits that break) would be helpful. It's probably a problem with the grammar.

davidflanagan commented 13 years ago

When I try to parse this (straight from the HTML5 spec):

interface HTMLPropertiesCollection : HTMLCollection { caller getter PropertyNodeList namedItem(in DOMString name); readonly attribute DOMStringList names; };

I get this:

node.js:114 throw e; // process.nextTick error, or 'error' event on first tick ^ Expected "?", "[]" or [ \r\n ] but "L" found.

If I change DOMStringList to DOMString or StringList it parses. If I change it to "octet" it parses. But if I change it to "octetTest", it doesn't parse. This time, the error is on the "T" (in Test) instead of the L in List.