language-ecmascript-0.17.0.1: JavaScript parser and pretty-printer library

Safe HaskellNone
LanguageHaskell2010

Language.ECMAScript3.Parser

Description

Parser for ECMAScript 3.

Synopsis

Documentation

parse Source

Arguments

:: Stream s Identity Char 
=> Parser s a

The parser to use

-> SourceName

Name of the source file

-> s

the stream to parse, usually a String

-> Either ParseError a 

Parse from a stream given a parser, same as parse in Parsec. We can use this to parse expressions or statements alone, not just whole programs.

type Parser s a = ParsecT s ParserState Identity a Source

The parser type, parametrised by the stream type s and the return value a

expression :: Stream s Identity Char => Parser s (Expression SourcePos) Source

A parser that parses ECMAScript expressions

statement :: Stream s Identity Char => Parser s (Statement SourcePos) Source

The parser that parses a single ECMAScript statement

program :: Stream s Identity Char => Parser s (JavaScript SourcePos) Source

A parser that parses an ECMAScript program.

parseFromString Source

Arguments

:: String

JavaScript source to parse

-> Either ParseError (JavaScript SourcePos) 

A convenience function that takes a String and tries to parse it as an ECMAScript program:

parseFromString = parse program ""

parseFromFile Source

Arguments

:: (Error e, MonadIO m, MonadError e m) 
=> String

file name

-> m (JavaScript SourcePos) 

A convenience function that takes a filename and tries to parse the file contents an ECMAScript program, it fails with an error message if it can't.

parseScriptFromString Source

Arguments

:: String

source file name

-> String

JavaScript source to parse

-> Either ParseError (JavaScript SourcePos) 

Deprecated: Use parseFromString instead

Parse a JavaScript program from a string

parseJavaScriptFromFile Source

Arguments

:: MonadIO m 
=> String

file name

-> m [Statement SourcePos] 

Deprecated: Use parseFromFile instead

Read a JavaScript program from file an parse it into a list of statements

parseString Source

Arguments

:: String

JavaScript source

-> [Statement SourcePos] 

Deprecated: Use parseFromString instead

Parse a JavaScript source string into a list of statements

type ParsedStatement = Statement SourcePos Source

Deprecated: These type aliases will be hidden in the next version

type ParsedExpression = Expression SourcePos Source

Deprecated: These type aliases will be hidden in the next version

parseSimpleExpr' :: Stream s Identity Char => ExpressionParser s Source

Deprecated: These parsers will be hidden in the next version

parseBlockStmt :: Stream s Identity Char => StatementParser s Source

Deprecated: These parsers will be hidden in the next version

type StatementParser s = Parser s ParsedStatement Source

Deprecated: These type aliases will be hidden in the next version

type ExpressionParser s = Parser s ParsedExpression Source

Deprecated: These type aliases will be hidden in the next version

parseObjectLit :: Stream s Identity Char => ExpressionParser s Source

Deprecated: These parsers will be hidden in the next version