Safe Haskell | None |
---|
Language.Go.Parser.Parser
Description
This module provides parsers for the various Go language elements.
- goParse :: String -> String -> Either ParseError GoSource
- goParseFileWith :: GoParser a -> String -> String -> Either ParseError a
- goParseTestWith :: GoParser a -> String -> Either ParseError a
- goTokenize :: String -> [GoTokenPos]
- goParseTokens :: String -> [GoTokenPos] -> Either ParseError GoSource
- goSource :: GoParser GoSource
- goImportDecl :: GoParser GoPrel
- goTopLevelDecl :: GoParser GoDecl
- goType :: GoParser GoType
- goBlock :: GoParser GoBlock
- goExpression :: GoParser GoExpr
- goStatement :: GoParser GoStmt
All-in-one parsers
goParse :: String -> String -> Either ParseError GoSourceSource
Parse Go Language source code into AST
goParseFileWith :: GoParser a -> String -> String -> Either ParseError aSource
goParseTestWith :: GoParser a -> String -> Either ParseError aSource
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
goImportDecl :: GoParser GoPrelSource
Standard ImportDecl
See also: SS. 13.3. Import declarations
goTopLevelDecl :: GoParser GoDeclSource
Standard TopLevelDecl
See also: SS. 9. Declarations and scope
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