Parse loops
This commit is contained in:
parent
78050694d6
commit
790f1ca6be
@ -62,8 +62,8 @@ func (this *Parser) parseExpressionRootIdent () (entity.Expression, error) {
|
|||||||
switch name {
|
switch name {
|
||||||
case "true", "false": return this.parseLiteralBoolean ()
|
case "true", "false": return this.parseLiteralBoolean ()
|
||||||
case "nil": return this.parseLiteralNil()
|
case "nil": return this.parseLiteralNil()
|
||||||
case "if": // TODO
|
case "if": return this.parseIfElse()
|
||||||
case "loop": // TODO
|
case "loop": return this.parseLoop()
|
||||||
default: return this.parseVariableOrDeclaration()
|
default: return this.parseVariableOrDeclaration()
|
||||||
}
|
}
|
||||||
panic(this.bug())
|
panic(this.bug())
|
||||||
@ -111,3 +111,23 @@ func (this *Parser) parseVariableOrDeclaration () (entity.Expression, error) {
|
|||||||
return variable, nil
|
return variable, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *Parser) parseIfElse () (*entity.IfElse, error) {
|
||||||
|
// TODO
|
||||||
|
panic(this.bug())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Parser) parseLoop () (*entity.Loop, error) {
|
||||||
|
err := this.expectDesc("Loop", lexer.Ident)
|
||||||
|
if err != nil { return nil, err }
|
||||||
|
pos := this.pos()
|
||||||
|
|
||||||
|
this.next()
|
||||||
|
body, err := this.parseExpression()
|
||||||
|
if err != nil { return nil, err }
|
||||||
|
|
||||||
|
return &entity.Loop {
|
||||||
|
Position: pos,
|
||||||
|
Body: body,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user