20 lines
477 B
Go
20 lines
477 B
Go
package build
|
|
|
|
import (
|
|
"git.akyoto.dev/cli/q/src/build/token"
|
|
"git.akyoto.dev/cli/q/src/errors"
|
|
)
|
|
|
|
// CompileKeyword compiles an instruction that starts with a keyword.
|
|
func (f *Function) CompileKeyword(tokens token.List) error {
|
|
switch tokens[0].Text() {
|
|
case "return":
|
|
return f.CompileReturn(tokens)
|
|
|
|
case "loop":
|
|
return f.CompileLoop(tokens)
|
|
|
|
default:
|
|
return errors.New(&errors.KeywordNotImplemented{Keyword: tokens[0].Text()}, f.File, tokens[0].Position)
|
|
}
|
|
}
|