detect reserved words inside names like 'a.λ.b'

This commit is contained in:
rhiannon morris 2023-09-24 17:36:20 +02:00
parent d4de74eab6
commit f04c4619ef
3 changed files with 95 additions and 44 deletions

View file

@ -47,7 +47,12 @@ tests = "lexer" :- [
lexes " " [],
lexes "-- line comment" [],
lexes "name -- line comment" [Name "name"],
lexes "-- line comment\nnameBetween -- and another" [Name "nameBetween"],
lexes
"""
-- line comment
nameBetween -- and another
"""
[Name "nameBetween"],
lexes "{- block comment -}" [],
lexes "{- {- nested -} block comment -}" []
],
@ -70,13 +75,14 @@ tests = "lexer" :- [
lexes "normalïse" [Name "normalïse"],
-- ↑ replace i + combining ¨ with precomposed ï
lexes "map#" [Name "map#"],
lexes "map#[" [Name "map#", Reserved "["], -- don't actually do this
lexes "map #[" [Name "map", Reserved "#["],
lexes "write!" [Name "write!"],
lexes "uhh??!?!?!?" [Name "uhh??!?!?!?"],
todo "check for reserved words in a qname",
skip $
lexes "abc.fun.def"
[Name "abc", Reserved ".", Reserved "λ", Reserved ".", Name "def"],
lexFail "abc.fun.ghi",
lexFail "abc.λ.ghi",
lexFail "abc.ω.ghi",
lexes "+" [Name "+"],
lexes "*" [Name "*"],