implement-modules #43

Closed
sashakoshka wants to merge 502 commits from implement-modules into main
Showing only changes of commit ea8d5e6b3a - Show all commits

View File

@ -65,8 +65,8 @@ func (this *Parser) parseExpressionRootIdent () (entity.Expression, error) {
return this.parseDeclarationCore(pos, name)
} else {
switch name {
case "true", "false": // TODO
case "nil": // TODO
case "true", "false": return this.parseLiteralBoolean ()
case "nil": return this.parseLiteralNil()
case "if": // TODO
case "loop": // TODO
default: return this.parseVariable()
@ -150,3 +150,24 @@ func (this *Parser) parseLiteralString () (*entity.LiteralString, error) {
ValueUTF8: this.value(),
}, nil
}
func (this *Parser) parseLiteralBoolean () (*entity.LiteralBoolean, error) {
err := this.expectValueDesc("Boolean", lexer.Ident, "true", "false")
if err != nil { return nil, err }
defer this.next()
return &entity.LiteralBoolean {
Position: this.pos(),
Value: this.value() == "true",
}, nil
}
func (this *Parser) parseLiteralNil () (*entity.LiteralNil, error) {
err := this.expectValueDesc("Boolean", lexer.Ident, "nil")
if err != nil { return nil, err }
defer this.next()
return &entity.LiteralNil {
Position: this.pos(),
}, nil
}