Respec: variable inlines should support generic types

Created on 23 Mar 2019  路  13Comments  路  Source: w3c/respec

For example:

Let |networks:sequence<DOMString>| be an empty DOMString sequence.

Most helpful comment

Yeah, ran into that today 馃榿

All 13 comments

Should also support spaced types e.g. unsigned long long.

Yeah, ran into that today 馃榿

I think we can basically just split on ":"... left side is variable, right side is type. Done.

Right side is type already. We need to update the regex. Maybe like

- \\B\\|\\w[\\s\\w]*\\w(?:\\s*\\:\\s*\\w+)?\\|\\B
+ \\B\\|\\w[\\s\\w]*\\w(?:\\s*\\:.+)?\\|\\B

But if we know everything on the right of : is type, what would we do with the regex?

Regex is for splitting the text in subtxt. We can have a simpler regex like \B\|.+(?:\:.+)\|\B. I'm not sure of the cases it may go "bad" - like over matching text.
Context: https://github.com/w3c/respec/blob/6e87fc6df575090f2ae77d82d9c8ae416c8c503a/src/core/inlines.js#L139

https://github.com/w3c/respec/blob/6e87fc6df575090f2ae77d82d9c8ae416c8c503a/src/core/inlines.js#L101-L102

I was thinking if we could send the type into webidl2.js, we can get back a simple AST. Then we could have some fun :)

@saschanaz, wdyt of the comment above? Doable?

webidl2.js is not exposing classes yet, and even if it did the classes doesn't support parsing string snippets yet. Supporting that would be absolutely great, though.

Ok, we should come up with a simple replica of https://github.com/w3c/webidl2.js/#idl-type

@sidvishnoi Well I don't think #2221 fully solves this, at least as per the discussion related to getting AST from WebIDL2 module.

We can open a new issue 馃榾

Was this page helpful?
0 / 5 - 0 ratings