lex . and ω (and #)
This commit is contained in:
parent
49c43ad296
commit
1dd4ff0e22
3 changed files with 10 additions and 4 deletions
|
@ -96,6 +96,7 @@ tokens = choice [
|
||||||
simple [","] $ P Comma,
|
simple [","] $ P Comma,
|
||||||
simple ["::", "∷"] $ P DblColon,
|
simple ["::", "∷"] $ P DblColon,
|
||||||
simple [":"] $ P Colon, -- needs to be after "::"
|
simple [":"] $ P Colon, -- needs to be after "::"
|
||||||
|
simple ["."] $ P Dot,
|
||||||
|
|
||||||
simple ["->", "→"] $ P Arrow,
|
simple ["->", "→"] $ P Arrow,
|
||||||
simple ["=>", "⇒"] $ P DblArrow,
|
simple ["=>", "⇒"] $ P DblArrow,
|
||||||
|
@ -106,6 +107,7 @@ tokens = choice [
|
||||||
keyword "fun" Fun, keyword "λ" Fun,
|
keyword "fun" Fun, keyword "λ" Fun,
|
||||||
keyword "let" Let, keyword "in" In,
|
keyword "let" Let, keyword "in" In,
|
||||||
keyword "case" Case, keyword "of" Of,
|
keyword "case" Case, keyword "of" Of,
|
||||||
|
keyword "ω" Omega, simple ["#"] $ K Omega,
|
||||||
|
|
||||||
match name $ Name,
|
match name $ Name,
|
||||||
match symbol $ Symbol . assert_total strTail,
|
match symbol $ Symbol . assert_total strTail,
|
||||||
|
|
|
@ -13,6 +13,7 @@ data Punc
|
||||||
| LBrace | RBrace
|
| LBrace | RBrace
|
||||||
| Comma
|
| Comma
|
||||||
| Colon | DblColon
|
| Colon | DblColon
|
||||||
|
| Dot
|
||||||
| Arrow | DblArrow
|
| Arrow | DblArrow
|
||||||
| Times | Triangle
|
| Times | Triangle
|
||||||
| Wild
|
| Wild
|
||||||
|
@ -22,7 +23,7 @@ data Punc
|
||||||
|
|
||||||
public export
|
public export
|
||||||
data Keyword
|
data Keyword
|
||||||
= Fun | Let | In | Case | Of
|
= Fun | Let | In | Case | Of | Omega
|
||||||
|
|
||||||
%runElab derive "Keyword" [Generic, Meta, Eq, Ord, DecEq, Show]
|
%runElab derive "Keyword" [Generic, Meta, Eq, Ord, DecEq, Show]
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,7 @@ tests = "lexer" :- [
|
||||||
acceptsWith' "'a" [Symbol "a"],
|
acceptsWith' "'a" [Symbol "a"],
|
||||||
acceptsWith' "'ab" [Symbol "ab"],
|
acceptsWith' "'ab" [Symbol "ab"],
|
||||||
acceptsWith' "'_b" [Symbol "_b"],
|
acceptsWith' "'_b" [Symbol "_b"],
|
||||||
|
acceptsWith' "a.b.c" [Name "a", P Dot, Name "b", P Dot, Name "c"],
|
||||||
rejects' "'",
|
rejects' "'",
|
||||||
rejects' "1abc"
|
rejects' "1abc"
|
||||||
],
|
],
|
||||||
|
@ -124,6 +125,8 @@ tests = "lexer" :- [
|
||||||
acceptsWith' "in" [K In],
|
acceptsWith' "in" [K In],
|
||||||
acceptsWith' "case" [K Case],
|
acceptsWith' "case" [K Case],
|
||||||
acceptsWith' "of" [K Of],
|
acceptsWith' "of" [K Of],
|
||||||
|
acceptsWith' "ω" [K Omega],
|
||||||
|
acceptsWith' "#" [K Omega],
|
||||||
acceptsWith' "funk" [Name "funk"]
|
acceptsWith' "funk" [Name "funk"]
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue