language-javascript-0.5.7: Parser for JavaScript

Safe Haskell | None

Language.JavaScript.Parser.Parser

Contents

- Parsing
- Parsing expressions

Synopsis

- parse :: String -> String -> Either String JSNode
- readJs :: String -> JSNode
- parseFile :: FilePath -> IO JSNode
- parseFileUtf8 :: FilePath -> IO JSNode
- parseUsing :: Alex JSNode -> String -> String -> Either String JSNode
- showStripped :: JSNode -> String
- showStrippedMaybe :: Show a => Either a JSNode -> String

# Parsing

parse

Arguments

:: String | The input stream (Javascript source code).
-> String | The name of the Javascript source (filename or input device).
-> Either String 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.

readJs :: String -> JSNode

parseFile :: FilePath -> IO JSNode

Parse the given file. For UTF-8 support, make sure your locale is set such that System.IO.localeEncoding returns utf8

parseFileUtf8 :: FilePath -> IO JSNode

Parse the given file, explicitly setting the encoding to UTF8 when reading it

# Parsing expressions

parseUsing

Arguments

:: Alex JSNode | The parser to be used
-> String | The input stream (Javascript source code).
-> String | The name of the Javascript source (filename or input device).
-> Either String 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 -> String

showStrippedMaybe :: Show a => Either a JSNode -> String