Implemented const keyword
This commit is contained in:
parent
5f37a9e84a
commit
91a3ec9d52
21 changed files with 164 additions and 26 deletions
|
@ -65,6 +65,7 @@ const (
|
|||
___END_OPERATORS___ // </operators>
|
||||
___KEYWORDS___ // <keywords>
|
||||
Assert // assert
|
||||
Const // const
|
||||
Else // else
|
||||
Extern // extern
|
||||
If // if
|
||||
|
|
|
@ -25,10 +25,11 @@ func TestFunction(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestKeyword(t *testing.T) {
|
||||
tokens := token.Tokenize([]byte("assert if import else extern loop return struct switch"))
|
||||
tokens := token.Tokenize([]byte("assert const if import else extern loop return struct switch"))
|
||||
|
||||
expected := []token.Kind{
|
||||
token.Assert,
|
||||
token.Const,
|
||||
token.If,
|
||||
token.Import,
|
||||
token.Else,
|
||||
|
|
|
@ -15,6 +15,8 @@ func identifier(tokens List, buffer []byte, i Position) (List, Position) {
|
|||
switch string(identifier) {
|
||||
case "assert":
|
||||
kind = Assert
|
||||
case "const":
|
||||
kind = Const
|
||||
case "if":
|
||||
kind = If
|
||||
case "else":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue