Skip to content

Commit

Permalink
Widens the accepted symbol list (#1385)
Browse files Browse the repository at this point in the history
* Changed the valid symbols from inclusvie to exclusive

* Add test using the new valid symbols
  • Loading branch information
mariari authored Jul 18, 2022
1 parent 2ea049c commit d7ad691
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
16 changes: 4 additions & 12 deletions src/Juvix/Syntax/Concrete/Lexer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,11 @@ validTailChar :: Char -> Bool
validTailChar c =
isAlphaNum c || validFirstChar c

reservedSymbols :: [Char]
reservedSymbols = "\";(){}[].≔λ\\"

validFirstChar :: Char -> Bool
validFirstChar c =
or
[ isLetter c,
cat == MathSymbol,
cat == CurrencySymbol,
cat == ModifierLetter,
c `elem` extraAllowedChars
]
where
extraAllowedChars :: [Char]
extraAllowedChars = "_'-*,&"
cat = generalCategory c
validFirstChar c = not $ isNumber c || isSpace c || (c `elem` reservedSymbols)

dot :: forall e m. MonadParsec e Text m => m Char
dot = P.char '.'
Expand Down
7 changes: 6 additions & 1 deletion test/Scope/Positive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,10 @@ tests =
"Import embedded standard library"
"StdlibImport"
StdlibInclude
"StdlibImport.juvix"
"StdlibImport.juvix",
PosTest
"Check Valid Symbols"
""
StdlibInclude
"Symbols.juvix"
]
31 changes: 31 additions & 0 deletions tests/positive/Symbols.juvix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module Symbols;

open import Stdlib.Data.Nat;

╘⑽╛ : ℕ;
╘⑽╛ ≔ suc nine;

-- no - function!?
- : ℕ -> ℕ -> ℕ;
- ≔ (+);

(-) : ℕ -> ℕ -> ℕ;
(-) ≔ (-);

(*) : ℕ -> ℕ -> ℕ;
(*) ≔ (*);

infixl 6 -;
- : ℕ -> ℕ -> ℕ;
- ≔ (-);

infixl 7 ·;
· : ℕ -> ℕ -> ℕ;
· ≔ (*);

(0) : ℕ;
(0) ≔ ╘⑽╛ - ╘⑽╛ · zero;

主功能 : ℕ;
主功能 ≔ (0);
end;

0 comments on commit d7ad691

Please sign in to comment.