goby-lang / goby

Goby - Yet another programming language written in Go
MIT License
3.49k stars 171 forks source link

Return error when found invalid assignment value (currently ignore) #786

Closed st0012 closed 5 years ago

st0012 commented 5 years ago

This fixes certain invalid syntaxes reported in #783 like

123 = []
[] = []
{} = []

But cases like 123foo = [] are caused by lexer's whitespace-insensitive. Which means that it doesn't consider whitespace while reading characters. So in this case, it'll tokenize the code into Int, Ident, Eq, LBracket and RBracket instead of Illegal, Eq, LBracket and RBracket.

To make the lexer whitespace-sensetive, we need to do some refactoring or even redesign for our lexer. So I choose to pick the low hanging fruits first and address that in other PR.

st0012 commented 5 years ago

@saveriomiroddi thanks for the quick review!