- parse :: String -> String -> Either ParseError JSNode
- readJs :: String -> JSNode
- parseFile :: FilePath -> IO JSNode
- showStripped :: JSNode -> String
- showStrippedMaybe :: Show a => Either a JSNode -> [Char]
- data JSNode = NS Node SrcSpan
- data ParseError
- data AlexPosn = AlexPn !Int !Int !Int
- type P a = StateT ParseState (Either ParseError) a
- data ParseState = ParseState {}
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.
showStripped :: JSNode -> StringSource
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 AlexPosn | An error from the lexer. Character found where it should not be. |
StrError String | A generic error containing a string message. No source location. |
Posn
records the location of a token in the input text. It has three
fields: the address (number of characters preceding the token), line number
and column of a token within the file. start_pos
gives the position of the
start of the file and eof_pos
a standard encoding for the end of file.
move_pos
calculates the new position after traversing a given character,
assuming the usual eight character tab stops.
type P a = StateT ParseState (Either ParseError) aSource