- parse :: String -> String -> Either ParseError JSNode
- readJs :: String -> JSNode
- parseFile :: FilePath -> IO JSNode
- data JSNode
- = JSArguments [[JSNode]]
- | JSArrayLiteral [JSNode]
- | JSBlock JSNode
- | JSBreak [JSNode] [JSNode]
- | JSCallExpression String [JSNode]
- | JSCase JSNode JSNode
- | JSCatch JSNode [JSNode] JSNode
- | JSContinue [JSNode]
- | JSDecimal String
- | JSDefault JSNode
- | JSDoWhile JSNode JSNode JSNode
- | JSElement String [JSNode]
- | JSElementList [JSNode]
- | JSElision [JSNode]
- | JSEmpty JSNode
- | JSExpression [JSNode]
- | JSExpressionBinary String [JSNode] [JSNode]
- | JSExpressionParen JSNode
- | JSExpressionPostfix String [JSNode]
- | JSExpressionTernary [JSNode] [JSNode] [JSNode]
- | JSFinally JSNode
- | JSFor [JSNode] [JSNode] [JSNode] JSNode
- | JSForIn [JSNode] JSNode JSNode
- | JSForVar [JSNode] [JSNode] [JSNode] JSNode
- | JSForVarIn JSNode JSNode JSNode
- | JSFunction JSNode [JSNode] JSNode
- | JSFunctionBody [JSNode]
- | JSFunctionExpression [JSNode] JSNode
- | JSHexInteger String
- | JSIdentifier String
- | JSIf JSNode JSNode
- | JSIfElse JSNode JSNode JSNode
- | JSLabelled JSNode JSNode
- | JSLiteral String
- | JSMemberDot [JSNode] JSNode
- | JSMemberSquare [JSNode] JSNode
- | JSObjectLiteral [JSNode]
- | JSOperator String
- | JSPropertyNameandValue JSNode [JSNode]
- | JSRegEx String
- | JSReturn [JSNode]
- | JSSourceElements [JSNode]
- | JSSourceElementsTop [JSNode]
- | JSStatementList [JSNode]
- | JSStringLiteral Char [Char]
- | JSSwitch JSNode [JSNode]
- | JSThrow JSNode
- | JSTry JSNode [JSNode]
- | JSUnary String
- | JSVarDecl JSNode [JSNode]
- | JSVariables String [JSNode]
- | JSWhile JSNode JSNode
- | JSWith JSNode [JSNode]
- data ParseError
- data SrcLocation
- = Sloc {
- sloc_filename :: !String
- sloc_row :: !Int
- sloc_column :: !Int
- | NoLocation
- = Sloc {
- data SrcSpan
- = SpanCoLinear {
- span_filename :: !String
- span_row :: !Int
- span_start_column :: !Int
- span_end_column :: !Int
- | SpanMultiLine {
- span_filename :: !String
- span_start_row :: !Int
- span_start_column :: !Int
- span_end_row :: !Int
- span_end_column :: !Int
- | SpanPoint {
- span_filename :: !String
- span_row :: !Int
- span_column :: !Int
- | SpanEmpty
- = SpanCoLinear {
- class Span a where
- type P a = StateT ParseState (Either ParseError) a
- data ParseState = ParseState {
- location :: !SrcLocation
- input :: !String
- previousToken :: !Token
- lastEOL :: !SrcSpan
- comments :: [Token]
Documentation
:: String | The input stream (Javascript source code). |
-> String | The name of the Javascript source (filename or input device). |
-> Either ParseError JSNode | An error or maybe the abstract syntax tree (AST) of zero or more Javascript statements, plus comments. |
Parse one compound statement, or a sequence of simple statements. Generally used for interactive input, such as from the command line of an interpreter. Return comments in addition to the parsed statements.
data ParseError Source
UnexpectedToken Token | An error from the parser. Token found where it should not be. Note: tokens contain their own source span. |
UnexpectedChar Char SrcLocation | An error from the lexer. Character found where it should not be. |
StrError String | A generic error containing a string message. No source location. |
data SrcLocation Source
A location for a syntactic entity from the source code. The location is specified by its filename, and starting row and column.
Sloc | |
| |
NoLocation |
Source location spanning a contiguous section of a file.
SpanCoLinear | A span which starts and ends on the same line. |
| |
SpanMultiLine | A span which starts and ends on different lines. |
| |
SpanPoint | A span which is actually just one point in the file. |
| |
SpanEmpty | No span information. |
Types which have a span.
type P a = StateT ParseState (Either ParseError) aSource
data ParseState Source
ParseState | |
|