Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class StatementNode {
- enum Kind {
- case IFELSE, FOR, WHILE, BLOCK
- }
- var text: String
- var kind: Kind
- var position:(col: Int, row: Int)
- init(_ position: (Int, Int),_ kind: Kind,_ text: String) {
- self.text = text
- self.position = position
- self.kind = kind
- }
- }
- class DeclType {
- enum declType {
- case VAR, TYPE, CONST
- }
- var type: declType
- var text: String
- var position:(col: Int, row: Int)
- init(_ position: (Int, Int),_ text: String, _ type:declType) {
- self.type = type
- self.text = text
- self.position = position
- }
- }
- class VarType: DeclType {
- init(_ position: (Int, Int), _ text: String) {
- super.init(position, text, .VAR)
- }
- }
- class DeclarationScope {
- var declList = [String: DeclType]()
- }
- class Block: StatementNode {
- var declScope: DeclarationScope?
- var stmtList = [StatementNode]()
- init(_ position: (Int, Int),_ text: String,_ declaration:DeclarationScope? = nil) {
- self.declScope = declaration
- super.init(position, .BLOCK, text)
- }
- }
- class IFElseStmt: StatementNode {
- var condition: Expression
- var block: StatementNode
- var elseBlock: StatementNode?
- init(_ position: (Int, Int),_ text: String,_ cond: Expression,_ block: StatementNode,_ elseBlock:StatementNode? = nil) {
- self.condition = cond
- self.block = block
- self.elseBlock = elseBlock
- super.init(position, .IFELSE, text)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement