language-javascript-0.0.2: Parser for JavaScript

Language.JavaScript.Parser

Synopsis

Documentation

parseSource

Arguments

:: 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 JSNode Source

data ParseError Source

Constructors

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.

Constructors

Sloc 
NoLocation 

data SrcSpan Source

Source location spanning a contiguous section of a file.

Constructors

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.

class Span a whereSource

Types which have a span.

Methods

getSpan :: a -> SrcSpanSource

Instances

Span SrcSpan 
Span SrcLocation 
Span Token 
Span a => Span [a] 
Span a => Span (Maybe a) 
(Span a, Span b) => Span (Either a b) 
(Span a, Span b) => Span (a, b)