AST
This commit is contained in:
parent
53b123b997
commit
8d8bc06034
51
src/Ast.hs
Normal file
51
src/Ast.hs
Normal file
@ -0,0 +1,51 @@
|
||||
module Ast where
|
||||
|
||||
type CompilationUnit = [Class]
|
||||
type DataType = String
|
||||
type Identifier = String
|
||||
|
||||
data ParameterDeclaration = ParameterDeclaration DataType Identifier
|
||||
data VariableDeclaration = VariableDeclaration DataType Identifier (Maybe Expression)
|
||||
data Class = Class DataType [MethodDeclaration] [VariableDeclaration]
|
||||
data MethodDeclaration = MethodDeclaration DataType Identifier [ParameterDeclaration] Statement
|
||||
|
||||
data Statement = If Expression Statement (Maybe Statement)
|
||||
| LocalVariableDeclaration VariableDeclaration
|
||||
| While Expression Statement
|
||||
| Block [Statement]
|
||||
| Return (Maybe Expression)
|
||||
| StatementExpressionStatement StatementExpression
|
||||
|
||||
data StatementExpression = Assignment Identifier Expression
|
||||
| ConstructorCall DataType [Expression]
|
||||
| MethodCall Identifier [Expression]
|
||||
|
||||
data BinaryOperator = Addition
|
||||
| Subtraction
|
||||
| Multiplication
|
||||
| Division
|
||||
| BitwiseAnd
|
||||
| BitwiseOr
|
||||
| BitwiseXor
|
||||
| CompareLessThan
|
||||
| CompareLessOrEqual
|
||||
| CompareGreaterThan
|
||||
| CompareGreaterOrEqual
|
||||
| CompareEqual
|
||||
| CompareNotEqual
|
||||
| And
|
||||
| Or
|
||||
| NameResolution
|
||||
|
||||
data UnaryOperator = Not
|
||||
| Minus
|
||||
|
||||
data Expression = IntegerLiteral Int
|
||||
| CharacterLiteral Char
|
||||
| BooleanLiteral Bool
|
||||
| NullLiteral
|
||||
| Reference Identifier
|
||||
| BinaryOperation BinaryOperator Expression Expression
|
||||
| UnaryOperation UnaryOperator Expression
|
||||
| StatementExpressionExpression StatementExpression
|
||||
|
Loading…
Reference in New Issue
Block a user