Skip to content

Commit

Permalink
feat(wip): break and continue statements
Browse files Browse the repository at this point in the history
  • Loading branch information
silverhairs committed Aug 12, 2023
1 parent 100d50b commit bcb8425
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions glox/ast/stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type StmtVisitor interface {
VisitBlockStmt(*BlockStmt) any
VisitIfStmt(*IfStmt) any
VisitWhile(*WhileStmt) any
VisitBreak(*Break) any
}

type Statement interface {
Expand Down Expand Up @@ -92,3 +93,15 @@ func NewWhileStmt(cond Expression, body Statement) *WhileStmt {
func (stmt *WhileStmt) Accept(v StmtVisitor) any {
return v.VisitWhile(stmt)
}

type Break struct {
Token token.Token
}

func NewBreakStmt(tok token.Token) *Break {
return &Break{Token: tok}
}

func (b *Break) Accept(v StmtVisitor) any {
return v.VisitBreak(b)
}

0 comments on commit bcb8425

Please sign in to comment.