polterguy / lizzie

A script language for .Net and the CLR
https://ainiro.io/
MIT License
190 stars 27 forks source link

Should have stricter checking of symbol names #32

Closed SapphireBrand closed 5 years ago

SapphireBrand commented 5 years ago

Current code checks only that symbol names cannot contain whitespace.

It seems to me that you should also exclude punctuation symbols used by the Lizzie language: (){} and comma.

polterguy commented 5 years ago

Actually, in regards to the (){}, characters, finding one of these in the place where I suspect you're looking (SanityCheckSymbolName?) would be theoretically impossible, since at this point if the code contained such characters, the tokenizer would have create a new token - So adding a check for these characters would be a redundant check, and simply use additional CPU, for no purpose - Unless somebody have create their own Tokenizer, which is possible though, but highly unlikely, and if they do, they'll probably tokenize similarly according to these characters ...

Basically, checking for anything we're checking for here, is due to Lizzie's tokens definition redundant, since it would be logically impossible to encounter any of these characters as a part of a symbol name, since the tokenizer would then have stopped interpreting it as a single token, and declared it as three tokens (separated by the special character, e.g. {)

E.g.

foo{bar

Becomes 3 tokens ...

  1. foo
  2. {
  3. bar

So a symbol could never, not even in theory, contain such characters ... :)