Report invalid characters.
This commit is contained in:
parent
b00c450600
commit
75ad2792f6
2 changed files with 7 additions and 0 deletions
|
|
@ -1,5 +1,9 @@
|
|||
package runner
|
||||
|
||||
import (
|
||||
lerrors "github.com/AYM1607/crafting-interpreters/golox/internal/errors"
|
||||
)
|
||||
|
||||
type Scanner struct {
|
||||
source string
|
||||
|
||||
|
|
@ -54,6 +58,8 @@ func (s *Scanner) scanToken() {
|
|||
s.addToken(SEMI)
|
||||
case '*':
|
||||
s.addToken(STAR)
|
||||
default:
|
||||
lerrors.EmitError(s.line, "Unexpected character.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
1
golox/test-invalid.lox
Normal file
1
golox/test-invalid.lox
Normal file
|
|
@ -0,0 +1 @@
|
|||
{,{.(;)-}}*@
|
||||
Loading…
Add table
Add a link
Reference in a new issue