refactor: non-recursive statements and array types
This commit is contained in:
parent
70aa58b879
commit
cfad2f08f4
@ -78,8 +78,10 @@ object ast {
|
||||
case object BoolType extends BaseType with ParserBridge0[BoolType.type]
|
||||
case object CharType extends BaseType with ParserBridge0[CharType.type]
|
||||
case object StringType extends BaseType with ParserBridge0[StringType.type]
|
||||
case class ArrayType(elemType: Type) extends Type with PairElemType
|
||||
object ArrayType extends ParserBridge1[Type, ArrayType]
|
||||
case class ArrayType(elemType: Type, dimensions: Int)
|
||||
extends Type
|
||||
with PairElemType
|
||||
object ArrayType extends ParserBridge2[Type, Int, ArrayType]
|
||||
case class PairType(fst: PairElemType, snd: PairElemType) extends Type
|
||||
object PairType extends ParserBridge2[PairElemType, PairElemType, PairType]
|
||||
|
||||
@ -89,18 +91,18 @@ object ast {
|
||||
with ParserBridge0[UntypedPairType.type]
|
||||
|
||||
// waccadoodledo
|
||||
case class Program(funcs: List[FuncDecl], main: Stmt)
|
||||
object Program extends ParserBridge2[List[FuncDecl], Stmt, Program]
|
||||
case class Program(funcs: List[FuncDecl], main: List[Stmt])
|
||||
object Program extends ParserBridge2[List[FuncDecl], List[Stmt], Program]
|
||||
|
||||
// Function Definitions
|
||||
case class FuncDecl(
|
||||
returnType: Type,
|
||||
name: Ident,
|
||||
params: List[Param],
|
||||
body: Stmt
|
||||
body: List[Stmt]
|
||||
)
|
||||
object FuncDecl
|
||||
extends ParserBridge4[Type, Ident, List[Param], Stmt, FuncDecl]
|
||||
extends ParserBridge4[Type, Ident, List[Param], List[Stmt], FuncDecl]
|
||||
|
||||
case class Param(paramType: Type, name: Ident)
|
||||
object Param extends ParserBridge2[Type, Ident, Param]
|
||||
@ -122,14 +124,13 @@ object ast {
|
||||
object Exit extends ParserBridge1[Expr, Exit]
|
||||
case class Print(expr: Expr, newline: Boolean) extends Stmt
|
||||
object Print extends ParserBridge2[Expr, Boolean, Print]
|
||||
case class If(cond: Expr, thenStmt: Stmt, elseStmt: Stmt) extends Stmt
|
||||
object If extends ParserBridge3[Expr, Stmt, Stmt, If]
|
||||
case class While(cond: Expr, body: Stmt) extends Stmt
|
||||
object While extends ParserBridge2[Expr, Stmt, While]
|
||||
case class Block(stmt: Stmt) extends Stmt
|
||||
object Block extends ParserBridge1[Stmt, Block]
|
||||
case class SeqStmt(stmt1: Stmt, stmt2: Stmt) extends Stmt
|
||||
object SeqStmt extends ParserBridge2[Stmt, Stmt, SeqStmt]
|
||||
case class If(cond: Expr, thenStmt: List[Stmt], elseStmt: List[Stmt])
|
||||
extends Stmt
|
||||
object If extends ParserBridge3[Expr, List[Stmt], List[Stmt], If]
|
||||
case class While(cond: Expr, body: List[Stmt]) extends Stmt
|
||||
object While extends ParserBridge2[Expr, List[Stmt], While]
|
||||
case class Block(stmt: List[Stmt]) extends Stmt
|
||||
object Block extends ParserBridge1[List[Stmt], Block]
|
||||
|
||||
sealed trait LValue
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user