ContentsIndex
Language.Go.Parser.Parser
Description
y
Synopsis
goTokenize :: String -> [GoTokenPos]
goSemiNeeded :: GoToken -> Bool
goRecognize :: [GoTokenPos] -> [GoTokenPos]
goParse :: String -> String -> Either ParseError GoSource
goParseTokens :: String -> [GoTokenPos] -> Either ParseError GoSource
goParseFileWith :: GoParser a -> String -> String -> Either ParseError a
goParseTestWith :: GoParser a -> String -> Either ParseError a
goSource :: GoParser GoSource
goSourceRest :: GoParser ()
goPackageClause :: GoParser GoId
goTopLevelPrel :: GoParser GoPrel
goTopLevelDecl :: GoParser GoDecl
goImportDecl :: GoParser GoPrel
goImportSpec :: GoParser [GoImpSpec]
goTokenEq :: GoToken -> GoToken -> Bool
goToken :: GoToken -> GoParser GoToken
goIdentifier :: GoParser GoId
goOperator :: GoParser GoOp
goUnaryOp :: GoParser ()
goBinaryOp :: GoParser ()
goAssignOp :: GoParser ()
goTokArrowOp :: GoParser ()
goTokColonEq :: GoParser ()
goTokEq :: GoParser ()
goAfter :: GoParser b -> GoParser a -> GoParser a
goSemi :: GoParser a -> GoParser a
goString :: GoParser String
goBuiltinCall :: GoParser GoPrim
goBuiltinArgs :: GoParser [GoExpr]
goTypeName :: GoParser GoType
goTypeLit :: GoParser GoType
goArrayType :: GoParser GoType
goSliceType :: GoParser GoType
goStructType :: GoParser GoType
goFieldTag :: GoParser String
goPointerType :: GoParser GoType
goFunctionType :: GoParser GoType
goSignature :: GoParser GoSig
goResult :: GoParser [GoParam]
goParameters :: GoParser [GoParam]
goParameterList :: GoParser [GoParam]
goParameterDecl :: GoParser [GoParam]
goInterfaceType :: GoParser GoType
goMapType :: GoParser GoType
goChannelType :: GoParser GoType
goDeclaration :: GoParser GoDecl
goStatement :: GoParser GoStmt
goLabeledStmt :: GoParser GoStmt
goSimple :: GoParser GoSimp
goIncDecStmt :: GoParser GoSimp
goAssignment :: GoParser GoSimp
goShortVarDecl :: GoParser GoSimp
goBlock :: GoParser GoBlock
goIdentifierList :: GoParser [GoId]
goExpressionList :: GoParser [GoExpr]
goCVSpecs :: GoParser [GoCVSpec]
goConstDecl :: GoParser GoDecl
goVarDecl :: GoParser GoDecl
goTypeDecl :: GoParser GoDecl
goTypeSpecs :: GoParser [GoTypeSpec]
goFunctionDecl :: GoParser GoDecl
goMethodDecl :: GoParser GoDecl
goReceiver :: GoParser GoRec
goQualifiedIdent :: GoParser GoPrim
goOperand :: GoParser GoPrim
goLiteralPrim :: GoParser GoPrim
goLiteral :: GoParser GoLit
goBasicLit :: GoParser GoLit
goCompositeLit :: GoParser GoLit
goArrayElipsisType :: GoParser GoType
goLiteralType :: GoParser GoType
goLiteralValue :: GoParser GoComp
goElementList :: GoParser [GoElement]
goElement :: GoParser GoElement
goElementKey :: GoParser GoKey
goKey :: GoParser GoKey
goValue :: GoParser GoValue
goFunctionLit :: GoParser GoLit
goExpression :: GoParser GoExpr
goPrimaryExpr :: GoParser GoExpr
goPrimary :: GoParser GoPrim
goPrimary''' :: GoPrim -> GoParser GoPrim
goPrimary'' :: GoPrim -> GoParser GoPrim
goPrimary' :: GoParser GoPrim
goConversion :: GoParser GoPrim
goUnaryExpr :: GoParser GoExpr
goBinaryExpr :: GoParser GoExpr
goSelector :: GoPrim -> GoParser GoPrim
goIndex :: GoPrim -> GoParser GoPrim
goSlice :: GoPrim -> GoParser GoPrim
goTypeAssertion :: GoPrim -> GoParser GoPrim
goCall :: GoPrim -> GoParser GoPrim
goIfStmt :: GoParser GoStmt
goExprSwitchStmt :: GoParser GoStmt
goExprCaseClause :: GoParser GoCase
goExprSwitchCase :: GoParser (Maybe [GoExpr])
goCondition :: GoParser GoForClause
goForClause :: GoParser GoForClause
goRangeClause :: GoParser GoForClause
goGoStmt :: GoParser GoStmt
goReturnStmt :: GoParser GoStmt
Documentation
goTokenize :: String -> [GoTokenPos]

Tokenize Go Language source code

TODO:

  • [X] Semicolon insertion (currently ';' is required) - DONE!
  • [ ] Unicode identifiers (currently '#[...]' can be used)
goSemiNeeded :: GoToken -> Bool
goRecognize :: [GoTokenPos] -> [GoTokenPos]
goParse :: String -> String -> Either ParseError GoSource
Parse Go Language source code into AST
goParseTokens :: String -> [GoTokenPos] -> Either ParseError GoSource
Parse Go Language token list into AST
goParseFileWith :: GoParser a -> String -> String -> Either ParseError a
goParseTestWith :: GoParser a -> String -> Either ParseError a
goSource :: GoParser GoSource
Go Source production
goSourceRest :: GoParser ()
goPackageClause :: GoParser GoId
Go PackageClase production
goTopLevelPrel :: GoParser GoPrel

Nonstandard TopLevelPrel production

This is not part of the standard, but is here to abstract away some of the details of possible extensions to the language.

goTopLevelDecl :: GoParser GoDecl
Go TopLevelDecl production
goImportDecl :: GoParser GoPrel
goImportSpec :: GoParser [GoImpSpec]
goTokenEq :: GoToken -> GoToken -> Bool
goToken :: GoToken -> GoParser GoToken
goIdentifier :: GoParser GoId
goOperator :: GoParser GoOp
goUnaryOp :: GoParser ()
goBinaryOp :: GoParser ()
goAssignOp :: GoParser ()
goTokArrowOp :: GoParser ()
goTokColonEq :: GoParser ()
goTokEq :: GoParser ()
goAfter :: GoParser b -> GoParser a -> GoParser a
goSemi :: GoParser a -> GoParser a
goString :: GoParser String
goBuiltinCall :: GoParser GoPrim
goBuiltinArgs :: GoParser [GoExpr]
goTypeName :: GoParser GoType
goTypeLit :: GoParser GoType
goArrayType :: GoParser GoType
goSliceType :: GoParser GoType
goStructType :: GoParser GoType
goFieldTag :: GoParser String
goPointerType :: GoParser GoType
goFunctionType :: GoParser GoType
goSignature :: GoParser GoSig
goResult :: GoParser [GoParam]
goParameters :: GoParser [GoParam]
goParameterList :: GoParser [GoParam]
goParameterDecl :: GoParser [GoParam]
goInterfaceType :: GoParser GoType
goMapType :: GoParser GoType
goChannelType :: GoParser GoType
goDeclaration :: GoParser GoDecl
goStatement :: GoParser GoStmt
goLabeledStmt :: GoParser GoStmt
goSimple :: GoParser GoSimp
goIncDecStmt :: GoParser GoSimp
goAssignment :: GoParser GoSimp
Go Assignment production
goShortVarDecl :: GoParser GoSimp
Go ShortVarDecl production
goBlock :: GoParser GoBlock
goIdentifierList :: GoParser [GoId]
goExpressionList :: GoParser [GoExpr]
goCVSpecs :: GoParser [GoCVSpec]
goConstDecl :: GoParser GoDecl
goVarDecl :: GoParser GoDecl
goTypeDecl :: GoParser GoDecl
goTypeSpecs :: GoParser [GoTypeSpec]
goFunctionDecl :: GoParser GoDecl
goMethodDecl :: GoParser GoDecl
goReceiver :: GoParser GoRec
goQualifiedIdent :: GoParser GoPrim
goOperand :: GoParser GoPrim
goLiteralPrim :: GoParser GoPrim
goLiteral :: GoParser GoLit
goBasicLit :: GoParser GoLit
goCompositeLit :: GoParser GoLit
goArrayElipsisType :: GoParser GoType
goLiteralType :: GoParser GoType
goLiteralValue :: GoParser GoComp
goElementList :: GoParser [GoElement]
goElement :: GoParser GoElement
goElementKey :: GoParser GoKey
goKey :: GoParser GoKey
goValue :: GoParser GoValue
goFunctionLit :: GoParser GoLit
goExpression :: GoParser GoExpr

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.

goPrimaryExpr :: GoParser GoExpr

Standard PrimaryExpr

PrimaryExpr is occurs in many places:

  • Expression,
  • TypeSwitchGuard,
  • and in its own definition.

Therefore, it is useful to have a separate datatype for it, since otherwise we would have to repeat ourselves. This is the responsibility goPrimary below. The only thing we do here is convert the AST one level, so it's an expression.

goPrimary :: GoParser GoPrim
Self-contained primary expressions
goPrimary''' :: GoPrim -> GoParser GoPrim
goPrimary'' :: GoPrim -> GoParser GoPrim
goPrimary' :: GoParser GoPrim
goConversion :: GoParser GoPrim
goUnaryExpr :: GoParser GoExpr
goBinaryExpr :: GoParser GoExpr
goSelector :: GoPrim -> GoParser GoPrim
goIndex :: GoPrim -> GoParser GoPrim
goSlice :: GoPrim -> GoParser GoPrim
goTypeAssertion :: GoPrim -> GoParser GoPrim
goCall :: GoPrim -> GoParser GoPrim
goIfStmt :: GoParser GoStmt
goExprSwitchStmt :: GoParser GoStmt
goExprCaseClause :: GoParser GoCase
goExprSwitchCase :: GoParser (Maybe [GoExpr])
goCondition :: GoParser GoForClause
goForClause :: GoParser GoForClause
goRangeClause :: GoParser GoForClause
goGoStmt :: GoParser GoStmt
goReturnStmt :: GoParser GoStmt
Produced by Haddock version 2.4.2