language-go-0.9: A library for analysis and synthesis of Go code.

Safe HaskellNone

Language.Go.Parser.Parser

Contents

Description

This module provides parsers for the various Go language elements.

Synopsis

All-in-one parsers

goParse :: String -> String -> Either ParseError GoSourceSource

Parse Go Language source code into AST

Tokenizing and parsing a token stream

goTokenize :: String -> [GoTokenPos]Source

Tokenize Go language source code

This is where semicolons are inserted into the token stream. We also filter out comments here, so any comment processing must occur before this stage.

See also: 4.3. Semicolons

goParseTokens :: String -> [GoTokenPos] -> Either ParseError GoSourceSource

Parse Go Language token list into AST

Parsers for main language elements

goSource :: GoParser GoSourceSource

Standard SourceFile

See also: SS. 13.1. Source file organization

goImportDecl :: GoParser GoPrelSource

Standard ImportDecl

See also: SS. 13.3. Import declarations

goTopLevelDecl :: GoParser GoDeclSource

Standard TopLevelDecl

See also: SS. 9. Declarations and scope

goType :: GoParser GoTypeSource

Standard Type

See also: SS. 6. Types

goBlock :: GoParser GoBlockSource

Standard Block

See also: SS. 8. Blocks

goExpression :: GoParser GoExprSource

Standard Expression

Technically, the Go spec says

  • Expression = UnaryExpr | Expression binary_op UnaryExpr .
  • UnaryExpr = PrimaryExpr | unary_op UnaryExpr .

but we combine these into one production here.

See also: SS. 10.12. Operators

goStatement :: GoParser GoStmtSource

Standard Statement

See also: SS. 11. Statements