Created
May 24, 2020 16:32
-
-
Save melbourne2991/07224c22ccf071a1df2e920970cfce95 to your computer and use it in GitHub Desktop.
map union record types from js
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
type ofCst; | |
type unknownCstElement; | |
type cstChildrenDict = Js.Dict.t(list(unknownCstElement)); | |
type cstNode = { | |
name: string, | |
children: cstChildrenDict, | |
}; | |
type token; | |
type cstElement = | |
| Token(token) | |
| Node(cstNode); | |
type lexErrors; | |
type parseErrors; | |
type parseResult = { | |
cst: cstNode, | |
lexErrors, | |
parseErrors, | |
}; | |
let mapUnknownCst = (unknownCstElement: unknownCstElement) => | |
if (Js.typeof(Obj.magic(unknownCstElement)##tokenType) != "undefined") { | |
Token(Obj.magic(unknownCstElement): token); | |
} else { | |
Node(Obj.magic(unknownCstElement): cstNode); | |
}; | |
[@bs.module "./parser/index.js"] | |
external parse: string => parseResult = "parse"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment