Skip to content

Commit

Permalink
Append punctuation tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
DQNEO committed Aug 29, 2019
1 parent 8df1ec0 commit a7f2cc8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func ungetChar() {
}

type Token struct {
kind string // "intliteral"
kind string // "intliteral", "punct"
value string
}

Expand Down Expand Up @@ -66,6 +66,13 @@ func tokenize() []*Token {
}
tokens = append(tokens, token)
fmt.Printf(" '%s'", token.value)
case ';':
token := &Token{
kind: "punct",
value: string([]byte{char}),
}
tokens = append(tokens, token)
fmt.Printf(" '%s'", token.value)
default:
panic(fmt.Sprintf("tokenizer: Invalid char: '%c'", char))
}
Expand Down

0 comments on commit a7f2cc8

Please sign in to comment.