Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Parser.Parser
Description
Provides parser that produces AST.
Synopsis
- parse :: Text -> Maybe Program
- programP :: Parser Program
- topLevelDeclP :: Parser (Either VarDecl FunctionDef)
- functionDefP :: Parser FunctionDef
- expressionP :: Parser Expression
- termExpressionP :: Parser Expression
- opsTable :: [[Operator Parser Expression]]
- binaryOp :: Text -> BinaryOp -> Operator Parser Expression
- unaryOp :: Text -> UnaryOp -> Operator Parser Expression
- funcCallOp :: Parser (Expression -> Expression)
- arrayAccessByIndexOp :: Parser (Expression -> Expression)
- typeP :: Parser Type
- arrayTypeP :: Parser ArrayType
- functionTypeP :: Parser FunctionType
- statementP :: Parser Statement
- stmtReturnP :: Parser Statement
- stmtForGoToP :: Parser Statement
- stmtForP :: Parser Statement
- varDeclP :: Parser VarDecl
- ifElseP :: Parser IfElse
- blockP :: Parser Block
- simpleStmtP :: Parser SimpleStmt
- stmtAssignmentP :: Parser SimpleStmt
- stmtIncDecP :: Parser SimpleStmt
- stmtShortVarDeclP :: Parser SimpleStmt
- stmtExpressionP :: Parser SimpleStmt
- lvalueP :: Parser Lvalue
- valueP :: Parser Value
- arrayValP :: Parser ArrayValue
- functionValP :: Parser FunctionValue
- functionP :: Parser Function
- choice' :: (Foldable f, MonadParsec e s m, Functor f) => f (m a) -> m a
- eitherP' :: MonadParsec e s m => m a -> m b -> m (Either a b)
- optional' :: MonadParsec e s m => m a -> m (Maybe a)
- maybeVoid :: MonadParsec e s m => m a -> m (MaybeVoid a)
Parser
Program (top-level) parsers
topLevelDeclP :: Parser (Either VarDecl FunctionDef) Source #
Top-level declaration parser, it parses either var declaration or function definition.
functionDefP :: Parser FunctionDef Source #
Function definition parser.
Expressions parsers
expressionP :: Parser Expression Source #
Expression parser.
termExpressionP :: Parser Expression Source #
Terminal expression parser, it's terminal in terms of makeExprParser
parser.
opsTable :: [[Operator Parser Expression]] Source #
Operators table, contains all operator parsers and their fixity.
Operators
binaryOp :: Text -> BinaryOp -> Operator Parser Expression Source #
Utility function, that takes operator symbol, binary operator constructor and gives new binary operator in return.
unaryOp :: Text -> UnaryOp -> Operator Parser Expression Source #
Utility function, that takes operator symbol, unary operator constructor and gives new unary operator in return.
funcCallOp :: Parser (Expression -> Expression) Source #
Function call operator.
arrayAccessByIndexOp :: Parser (Expression -> Expression) Source #
Array access by index operator.
Types parsers
arrayTypeP :: Parser ArrayType Source #
Array type parser.
functionTypeP :: Parser FunctionType Source #
Function type parser.
Statements parsers
statementP :: Parser Statement Source #
Statement parser.
stmtReturnP :: Parser Statement Source #
Return statement parser.
stmtForGoToP :: Parser Statement Source #
For goto statement parser.
simpleStmtP :: Parser SimpleStmt Source #
Simple statement parser.
stmtAssignmentP :: Parser SimpleStmt Source #
Assignment statement parser.
stmtIncDecP :: Parser SimpleStmt Source #
Increment or decrement statement parser.
stmtShortVarDeclP :: Parser SimpleStmt Source #
Short var declaration statement parser.
stmtExpressionP :: Parser SimpleStmt Source #
Expression statement parser.
Values parsers
arrayValP :: Parser ArrayValue Source #
Array value parser.
functionValP :: Parser FunctionValue Source #
Function value parser.
Utils
choice' :: (Foldable f, MonadParsec e s m, Functor f) => f (m a) -> m a Source #
Choice between elements parser with built-in backtracking support.
eitherP' :: MonadParsec e s m => m a -> m b -> m (Either a b) Source #
Combine two alternatives with built-in backtracking support.
optional' :: MonadParsec e s m => m a -> m (Maybe a) Source #
Optional element parser with built-in backtracking support.
maybeVoid :: MonadParsec e s m => m a -> m (MaybeVoid a) Source #