-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad56372
commit 3126a4a
Showing
5 changed files
with
268 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
BuiltinType | ||
// primitives | ||
= "number" &NoChar | ||
/ "string" &NoChar | ||
/ "boolean" &NoChar | ||
/ "undefined" &NoChar | ||
/ "null" &NoChar | ||
|
||
// standard types | ||
/ "Object" &NoChar | ||
/ "Function" &NoChar | ||
/ "Symbol" &NoChar | ||
/ "Error" &NoChar | ||
/ "EvalError" &NoChar | ||
/ "InternalError" &NoChar | ||
/ "RangeError" &NoChar | ||
/ "ReferenceError" &NoChar | ||
/ "SyntaxError" &NoChar | ||
/ "TypeError" &NoChar | ||
/ "URIError" &NoChar | ||
/ "Date" &NoChar | ||
/ "RegExp" &NoChar | ||
/ "Array" &NoChar | ||
/ "Int8Array" &NoChar | ||
/ "Uint8Array" &NoChar | ||
/ "Uint8ClampedArray" &NoChar | ||
/ "Int16Array" &NoChar | ||
/ "Uint16Array" &NoChar | ||
/ "Int32Array" &NoChar | ||
/ "Uint32Array" &NoChar | ||
/ "Float32Array" &NoChar | ||
/ "Float64Array" &NoChar | ||
/ "BigInt64Array" &NoChar | ||
/ "BigUint64Array" &NoChar | ||
/ "Promise" &NoChar | ||
/ "Generator" &NoChar | ||
/ "GeneratorFunction" &NoChar | ||
/ "AsyncFunction" &NoChar | ||
/ "XMLHttpRequest" &NoChar | ||
/ "ArrayBuffer" &NoChar | ||
/ "SharedArrayBuffer" &NoChar | ||
/ "Atomics" &NoChar | ||
/ "DataView" &NoChar | ||
/ "JSON" &NoChar | ||
/ "Map" &NoChar | ||
/ "Set" &NoChar | ||
/ "WeakMap" &NoChar | ||
/ "WeakSet" &NoChar | ||
/ "Reflect" &NoChar | ||
/ "Proxy" &NoChar | ||
|
||
// Geolocation | ||
/ "PositionError" &NoChar | ||
/ "PositionOptions" &NoChar | ||
/ "Position" &NoChar | ||
/ "Geolocation" &NoChar | ||
|
||
// DOM | ||
/ "Attr" &NoChar | ||
/ "CDATASection" &NoChar | ||
/ "CharacterData" &NoChar | ||
/ "ChildNode" &NoChar | ||
/ "Comment" &NoChar | ||
/ "CustomEvent" &NoChar | ||
/ "Document" &NoChar | ||
/ "DocumentFragment" &NoChar | ||
/ "DocumentType" &NoChar | ||
/ "DOMError" &NoChar | ||
/ "DOMException" &NoChar | ||
/ "DOMImplementation" &NoChar | ||
/ "DOMString" &NoChar | ||
/ "DOMTimeStamp" &NoChar | ||
/ "DOMStringList" &NoChar | ||
/ "DOMTokenList" &NoChar | ||
/ "Element" &NoChar | ||
/ "Event" &NoChar | ||
/ "EventTarget" &NoChar | ||
/ "HTMLCollection" &NoChar | ||
/ "MutationObserver" &NoChar | ||
/ "MutationRecord" &NoChar | ||
/ "NamedNodeMap" &NoChar | ||
/ "Node" &NoChar | ||
/ "NodeFilter" &NoChar | ||
/ "NodeIterator" &NoChar | ||
/ "NodeList" &NoChar | ||
/ "NonDocumentTypeChildNode" &NoChar | ||
/ "ParentNode" &NoChar | ||
/ "ProcessingInstruction" &NoChar | ||
/ "Selection" &NoChar | ||
/ "Range" &NoChar | ||
/ "Text" &NoChar | ||
/ "TextDecoder" &NoChar | ||
/ "TextEncoder" &NoChar | ||
/ "TimeRanges" &NoChar | ||
/ "TreeWalker" &NoChar | ||
/ "URL" &NoChar | ||
/ "Window" &NoChar | ||
/ "Worker" &NoChar | ||
/ "XMLDocument" &NoChar | ||
|
||
// HTML Types | ||
/ "HTMLElement" &NoChar | ||
/ "HTMLCanvasElement" &NoChar | ||
/ "HTMLImageElement" &NoChar | ||
/ "HTMLVideoElement" &NoChar | ||
|
||
// PointerEvent | ||
/ "PointerEvent" &NoChar | ||
|
||
// TouchEvent | ||
/ "TouchEvent" &NoChar | ||
|
||
// MouseEvent | ||
/ "MouseEvent" &NoChar | ||
|
||
// TypeScript types | ||
/ "*" &NoChar | ||
// "?" will be catched by a special rule in type_rewrite_peg_rules | ||
/ "any" &NoChar | ||
/ "void" &NoChar | ||
/ "Partial" &NoChar | ||
|
||
// Other special types | ||
/ "Class" &NoChar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
{ | ||
function flatten(input) { | ||
return Array.isArray(input) ? input.map(i => flatten(i)).join("") : input; | ||
} | ||
} | ||
|
||
All | ||
= all: Lines { return flatten(all); } | ||
|
||
Lines | ||
= Line "\n" Lines | ||
/ Line | ||
|
||
Line | ||
= _ "*" _ TypeExpecting _ ComplexType ("#" [^\n\r]*)? | ||
/ _ "*" _ CurlyTypeExpecting _ CurlyType [^\n\r]* | ||
/ _ "*" _ !TypeExpecting !CurlyTypeExpecting [^\n\r]* | ||
/ _ [^\n\r]* [^*\n\r]* | ||
|
||
CurlyTypeExpecting | ||
= "@param" | ||
/ "@property" | ||
/ "@return" "s"? | ||
/ "@typedef" | ||
/ "@type" | ||
/ "@this" | ||
/ "@enum" | ||
|
||
TypeExpecting | ||
= "@fires" | ||
/ "@event" | ||
|
||
CurlyType | ||
= "{" _ TypeList _ "}" | ||
|
||
TypeList | ||
= ComplexType _b "|" _b TypeList | ||
/ ComplexType | ||
|
||
ComplexType | ||
= [?!]? ComplexTypeUnmodified "="? | ||
/ "?" // short curcuit for the builtin type "?" | ||
|
||
ComplexTypeUnmodified | ||
= "(" _ TypeList _ ")" | ||
/ Spread | ||
/ GenericType | ||
/ FunctionType | ||
/ SimpleType | ||
/ InlineObjectType | ||
|
||
InlineObjectType | ||
= "{" _b InlineObjectPropertyList _b "}" | ||
|
||
InlineObjectPropertyList | ||
= InlineObjectProperty _ "," _b InlineObjectPropertyList | ||
/ InlineObjectProperty | ||
|
||
InlineObjectProperty | ||
= [A-Za-z][A-Za-z0-9_]* _ ":" _b ComplexType | ||
|
||
Spread | ||
= "..." ComplexType | ||
|
||
FunctionType | ||
= "function" _ "(" _ (FunctionThis? _b ParameterList)? ")" (":" _b ComplexType)? | ||
|
||
FunctionThis | ||
= "this:" | ||
/ "new:" | ||
|
||
SimpleType | ||
= RewriteType | ||
/ BuiltinType | ||
/ ConvertedType | ||
/ GenericParameter | ||
|
||
NoChar | ||
= [^A-Za-z0-9_] | ||
|
||
GenericType | ||
= SimpleType "."? "<" ParameterList ">" | ||
|
||
ParameterList | ||
= TypeList "," _b ParameterList | ||
/ TypeList | ||
|
||
ConvertedType | ||
= "module:" [a-zA-Z/]+ (("~" / ".") [a-zA-Z]+)? &NoChar | ||
|
||
GenericParameter | ||
= [A-Z] &NoChar | ||
|
||
_b "break or whitespace" | ||
= _ "\n" _ "*" _ | ||
/ _ | ||
|
||
_ "whitespace" | ||
= [ \t]* |