Implemented struct parser
This commit is contained in:
parent
00e7216256
commit
30940f0100
19 changed files with 388 additions and 252 deletions
|
@ -70,6 +70,7 @@ const (
|
|||
Import // import
|
||||
Loop // loop
|
||||
Return // return
|
||||
Struct // struct
|
||||
Switch // switch
|
||||
___END_KEYWORDS___ // </keywords>
|
||||
)
|
||||
|
|
|
@ -25,7 +25,7 @@ func TestFunction(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestKeyword(t *testing.T) {
|
||||
tokens := token.Tokenize([]byte("assert if import else loop return switch"))
|
||||
tokens := token.Tokenize([]byte("assert if import else loop return struct switch"))
|
||||
|
||||
expected := []token.Kind{
|
||||
token.Assert,
|
||||
|
@ -34,6 +34,7 @@ func TestKeyword(t *testing.T) {
|
|||
token.Else,
|
||||
token.Loop,
|
||||
token.Return,
|
||||
token.Struct,
|
||||
token.Switch,
|
||||
token.EOF,
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ func identifier(tokens List, buffer []byte, i Position) (List, Position) {
|
|||
kind = Loop
|
||||
case "return":
|
||||
kind = Return
|
||||
case "struct":
|
||||
kind = Struct
|
||||
case "switch":
|
||||
kind = Switch
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue