Skip to content

Commit

Permalink
Add AST
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeAbel committed Jan 3, 2024
1 parent ef31143 commit 289ffe2
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions lvtrun/src/AST.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

Check failure on line 1 in lvtrun/src/AST.hs

View workflow job for this annotation

GitHub Actions / tests

File name does not match module name:
getType :: Type -> String
getType Int32 = "Int32"
getType _ = Nothing

type Type = String

type TypeValue = Int32 | Bool | String

data Value = Var String | StaticValue TypeValue | Function FuncCall


-- Function

type Var = (Symbol, Type)

type ReturnType = Type | Void

type FuncPrototype = (Symbol, [Var], ReturnType)

type FuncDeclaration = (FuncPrototype, [Instruction])


-- condition

type Condition = (Value, [Instruction], [Instruction])

-- Instruction

type FuncCall = (Symbol, [Value])

type VarDeclaration = (Var, Value)

type VarAssignation = (Symbol, Value)

data Instruction = Function FuncCall | Return Value | Declaration VarDeclaration | Assignation VarAssignation | Cond Condition

0 comments on commit 289ffe2

Please sign in to comment.