zilch-lang / nstar

The compiler for N⋆, a statically typed assembly language used as a compiler backend for Zilch
BSD 3-Clause "New" or "Revised" License
29 stars 2 forks source link

Reject end of lines in characters #20

Closed Mesabloo closed 4 years ago

Mesabloo commented 4 years ago

At the moment, the lexer allows the following:

'
'

which is definetely an error. This is because of how character lexing is handled in the compiler (see https://github.com/nihil-lang/nsc/blob/6b7304210ceb0d583304a860c2dc303bb40e7aa4/lib/nsc-parser/src/Language/NStar/Syntax/Lexer.hs#L157) where MP.anySingle accepts any character. We instead want to reject any end of line character (\n or \r). We could really use MP.satisfy (not . isNewline) instead, this should be a quick fix.

The test https://github.com/nihil-lang/nsc/blob/develop/test/error_lx_eolChar.nst should pass when it is fixed.

Mesabloo commented 4 years ago

Fixed by 033c7d714bd1100d7acdf959ddd3401d7e340482 on branch develop.