diff options
16 files changed, 22 insertions, 19 deletions
diff --git a/src/LambdaCube/Compiler/Parser.hs b/src/LambdaCube/Compiler/Parser.hs index dd196ae6..cf46ef27 100644 --- a/src/LambdaCube/Compiler/Parser.hs +++ b/src/LambdaCube/Compiler/Parser.hs | |||
@@ -372,9 +372,12 @@ parseTerm prec = withRange setSI $ case prec of | |||
372 | option t $ mkPi <$> (Visible <$ reservedOp "->" <|> Hidden <$ reservedOp "=>") <*> pure t <*> parseTTerm PrecLam | 372 | option t $ mkPi <$> (Visible <$ reservedOp "->" <|> Hidden <$ reservedOp "=>") <*> pure t <*> parseTTerm PrecLam |
373 | PrecEq -> parseTerm PrecAnn >>= \t -> option t $ SAppV2 (SBuiltin "'EqCT" `SAppV` SType) t <$ reservedOp "~" <*> parseTTerm PrecAnn | 373 | PrecEq -> parseTerm PrecAnn >>= \t -> option t $ SAppV2 (SBuiltin "'EqCT" `SAppV` SType) t <$ reservedOp "~" <*> parseTTerm PrecAnn |
374 | PrecAnn -> parseTerm PrecOp >>= \t -> option t $ SAnn t <$> parseType Nothing | 374 | PrecAnn -> parseTerm PrecOp >>= \t -> option t $ SAnn t <$> parseType Nothing |
375 | PrecOp -> join $ calculatePrecs <$> namespace <*> dsInfo <*> some item where | 375 | PrecOp -> join $ calculatePrecs <$> namespace <*> dsInfo <*> (notExp <|> notOp False) where |
376 | item = Right <$> parseTerm PrecApp | 376 | notExp = (++) <$> ope <*> option [] (notOp True) |
377 | <|> Left <$> parseSIName operatorT | 377 | notOp x = try "expression" ((++) <$> ((++) <$> ex PrecApp <*> option [] ope) <*> option [] (notOp True)) |
378 | <|> if x then try "lambda" (ex PrecLam) else mzero | ||
379 | ope = pure . Left <$> parseSIName operatorT | ||
380 | ex pr = pure . Right <$> parseTerm pr | ||
378 | PrecApp -> | 381 | PrecApp -> |
379 | try "" {- TODO: adjust try for better error messages e.g. don't use braces -} | 382 | try "" {- TODO: adjust try for better error messages e.g. don't use braces -} |
380 | (apps' <$> sVar upperCase <*> braces (commaSep $ lowerCase *> reservedOp "=" *> ((,) Visible <$> parseTerm PrecLam))) | 383 | (apps' <$> sVar upperCase <*> braces (commaSep $ lowerCase *> reservedOp "=" *> ((,) Visible <$> parseTerm PrecLam))) |
@@ -473,6 +476,7 @@ parseTerm prec = withRange setSI $ case prec of | |||
473 | cont :: forall a . a -> (SIName -> [Either SIName SExp] -> Either String a) -> [Either SIName SExp] -> Either String a | 476 | cont :: forall a . a -> (SIName -> [Either SIName SExp] -> Either String a) -> [Either SIName SExp] -> Either String a |
474 | cont _ f (Left op: xs) = f op xs | 477 | cont _ f (Left op: xs) = f op xs |
475 | cont e _ [] = return e | 478 | cont e _ [] = return e |
479 | cont _ _ _ = Left "TODO: better error message @477" | ||
476 | 480 | ||
477 | calcPrec' = calcPrec (\op x y -> SGlobal op `SAppV` x `SAppV` y) (getFixity dcls . snd) | 481 | calcPrec' = calcPrec (\op x y -> SGlobal op `SAppV` x `SAppV` y) (getFixity dcls . snd) |
478 | 482 | ||
diff --git a/testdata/language-features/basic-list/list03.reject.out b/testdata/language-features/basic-list/list03.reject.out index 5ef4c263..b1877931 100644 --- a/testdata/language-features/basic-list/list03.reject.out +++ b/testdata/language-features/basic-list/list03.reject.out | |||
@@ -1,3 +1,3 @@ | |||
1 | "testdata/language-features/basic-list/list03.reject.lc" (line 2, column 1): | 1 | "testdata/language-features/basic-list/list03.reject.lc" (line 2, column 1): |
2 | unexpected end of input | 2 | unexpected end of input |
3 | expecting "," or "]" \ No newline at end of file | 3 | expecting expression \ No newline at end of file |
diff --git a/testdata/language-features/basic-list/list04.reject.out b/testdata/language-features/basic-list/list04.reject.out index f97f8851..abc472f9 100644 --- a/testdata/language-features/basic-list/list04.reject.out +++ b/testdata/language-features/basic-list/list04.reject.out | |||
@@ -1,3 +1,3 @@ | |||
1 | "testdata/language-features/basic-list/list04.reject.lc" (line 2, column 1): | 1 | "testdata/language-features/basic-list/list04.reject.lc" (line 2, column 1): |
2 | unexpected end of input | 2 | unexpected end of input |
3 | expecting "," or "]" \ No newline at end of file | 3 | expecting expression \ No newline at end of file |
diff --git a/testdata/language-features/basic-list/list05.reject.out b/testdata/language-features/basic-list/list05.reject.out index 7633bb70..aa249773 100644 --- a/testdata/language-features/basic-list/list05.reject.out +++ b/testdata/language-features/basic-list/list05.reject.out | |||
@@ -1,3 +1,3 @@ | |||
1 | "testdata/language-features/basic-list/list05.reject.lc" (line 2, column 1): | 1 | "testdata/language-features/basic-list/list05.reject.lc" (line 2, column 1): |
2 | unexpected end of input | 2 | unexpected end of input |
3 | expecting "if", "forall", "\\", "case", "|", char literal, literal string, float literal, "#", natural, "_", "'", identifier, uppercase ident, dotdot expression, List comprehension, "[", "(", "{", "let", symbols, ":" or backquoted ident \ No newline at end of file | 3 | expecting expression \ No newline at end of file |
diff --git a/testdata/language-features/basic-list/list06.reject.out b/testdata/language-features/basic-list/list06.reject.out index 6bdb5d8a..b1fb7188 100644 --- a/testdata/language-features/basic-list/list06.reject.out +++ b/testdata/language-features/basic-list/list06.reject.out | |||
@@ -1,3 +1,3 @@ | |||
1 | "testdata/language-features/basic-list/list06.reject.lc" (line 1, column 10): | 1 | "testdata/language-features/basic-list/list06.reject.lc" (line 1, column 10): |
2 | unexpected "," | 2 | unexpected "," |
3 | expecting "if", "forall", "\\", "case", "|", char literal, literal string, float literal, "#", natural, "_", "'", identifier, uppercase ident, dotdot expression, List comprehension, "[", "(", "{", "let", symbols, ":", backquoted ident or "]" \ No newline at end of file | 3 | expecting expression \ No newline at end of file |
diff --git a/testdata/language-features/basic-values/def05.reject.out b/testdata/language-features/basic-values/def05.reject.out index 60095f3d..7c6b91ba 100644 --- a/testdata/language-features/basic-values/def05.reject.out +++ b/testdata/language-features/basic-values/def05.reject.out | |||
@@ -1,4 +1,4 @@ | |||
1 | "testdata/language-features/basic-values/def05.reject.lc" (line 4, column 1): | 1 | "testdata/language-features/basic-values/def05.reject.lc" (line 4, column 1): |
2 | unexpected end of input | 2 | unexpected end of input |
3 | expecting projection, swizzling, "@", char literal, literal string, float literal, "#", natural, "_", "'", identifier, uppercase ident, dotdot expression, List comprehension, "[", "(", "{", "let", symbols, ":", backquoted ident, "::", "~", "->", "=>", "where", "data", "class", "instance", type family, type instance, "type", typed ident, "infix", "infixl", "infixr", operator definition, lhs or pattern | 3 | expecting projection, swizzling, "@", char literal, literal string, float literal, "#", natural, "_", "'", identifier, uppercase ident, dotdot expression, List comprehension, "[", "(", "{", "let", symbols, ":", backquoted ident, expression, lambda, "::", "~", "->", "=>", "where", "data", "class", "instance", type family, type instance, "type", typed ident, "infix", "infixl", "infixr", operator definition, lhs or pattern |
4 | different number of arguments of fun at testdata/language-features/basic-values/def05.reject.lc 1:1-1:4 \ No newline at end of file | 4 | different number of arguments of fun at testdata/language-features/basic-values/def05.reject.lc 1:1-1:4 \ No newline at end of file |
diff --git a/testdata/language-features/basic-values/def06.reject.out b/testdata/language-features/basic-values/def06.reject.out index a4fac531..bcf412d2 100644 --- a/testdata/language-features/basic-values/def06.reject.out +++ b/testdata/language-features/basic-values/def06.reject.out | |||
@@ -1,4 +1,4 @@ | |||
1 | "testdata/language-features/basic-values/def06.reject.lc" (line 5, column 1): | 1 | "testdata/language-features/basic-values/def06.reject.lc" (line 5, column 1): |
2 | unexpected end of input | 2 | unexpected end of input |
3 | expecting projection, swizzling, "@", char literal, literal string, float literal, "#", natural, "_", "'", identifier, uppercase ident, dotdot expression, List comprehension, "[", "(", "{", "let", symbols, ":", backquoted ident, "::", "~", "->", "=>", "where", "data", "class", "instance", type family, type instance, "type", typed ident, "infix", "infixl", "infixr", operator definition, lhs or pattern | 3 | expecting projection, swizzling, "@", char literal, literal string, float literal, "#", natural, "_", "'", identifier, uppercase ident, dotdot expression, List comprehension, "[", "(", "{", "let", symbols, ":", backquoted ident, expression, lambda, "::", "~", "->", "=>", "where", "data", "class", "instance", type family, type instance, "type", typed ident, "infix", "infixl", "infixr", operator definition, lhs or pattern |
4 | different number of arguments of fun2 at testdata/language-features/basic-values/def06.reject.lc 1:1-1:5 \ No newline at end of file | 4 | different number of arguments of fun2 at testdata/language-features/basic-values/def06.reject.lc 1:1-1:5 \ No newline at end of file |
diff --git a/testdata/language-features/basic-values/indentation03.reject.out b/testdata/language-features/basic-values/indentation03.reject.out index 2d7eeedb..e4d1b181 100644 --- a/testdata/language-features/basic-values/indentation03.reject.out +++ b/testdata/language-features/basic-values/indentation03.reject.out | |||
@@ -1,3 +1,3 @@ | |||
1 | "testdata/language-features/basic-values/indentation03.reject.lc" (line 2, column 11): | 1 | "testdata/language-features/basic-values/indentation03.reject.lc" (line 2, column 11): |
2 | unexpected reserved operator "=" | 2 | unexpected reserved operator "=" |
3 | expecting symbols \ No newline at end of file | 3 | expecting symbols or lambda \ No newline at end of file |
diff --git a/testdata/language-features/basic-values/infix04.reject.out b/testdata/language-features/basic-values/infix04.reject.out index 9efba6ec..92ba823f 100644 --- a/testdata/language-features/basic-values/infix04.reject.out +++ b/testdata/language-features/basic-values/infix04.reject.out | |||
@@ -1,3 +1,3 @@ | |||
1 | "testdata/language-features/basic-values/infix04.reject.lc" (line 3, column 19): | 1 | "testdata/language-features/basic-values/infix04.reject.lc" (line 3, column 19): |
2 | unexpected "(" | 2 | unexpected "(" |
3 | expecting backquoted ident \ No newline at end of file | 3 | expecting backquoted ident or lambda \ No newline at end of file |
diff --git a/testdata/language-features/basic-values/literal01.lc b/testdata/language-features/basic-values/literal01.lc index 5180ae8a..9f886274 100644 --- a/testdata/language-features/basic-values/literal01.lc +++ b/testdata/language-features/basic-values/literal01.lc | |||
@@ -10,4 +10,4 @@ charValue = 'A' | |||
10 | stringValue1 = "Hello World" | 10 | stringValue1 = "Hello World" |
11 | stringValue2 = "\nHello\32World\tagain!\r\n" | 11 | stringValue2 = "\nHello\32World\tagain!\r\n" |
12 | 12 | ||
13 | natValue = #1234 | 13 | natValue = '1234 |
diff --git a/testdata/language-features/basic-values/literal01.out b/testdata/language-features/basic-values/literal01.out index 6e617798..bba02e5b 100644 --- a/testdata/language-features/basic-values/literal01.out +++ b/testdata/language-features/basic-values/literal01.out | |||
@@ -13,5 +13,4 @@ testdata/language-features/basic-values/literal01.lc 10:1-10:13 String | |||
13 | testdata/language-features/basic-values/literal01.lc 10:16-10:29 String | 13 | testdata/language-features/basic-values/literal01.lc 10:16-10:29 String |
14 | testdata/language-features/basic-values/literal01.lc 11:1-11:13 String | 14 | testdata/language-features/basic-values/literal01.lc 11:1-11:13 String |
15 | testdata/language-features/basic-values/literal01.lc 11:16-11:45 String | 15 | testdata/language-features/basic-values/literal01.lc 11:16-11:45 String |
16 | testdata/language-features/basic-values/literal01.lc 13:1-13:9 Int | 16 | testdata/language-features/basic-values/literal01.lc 13:1-13:9 Nat |
17 | testdata/language-features/basic-values/literal01.lc 13:12-13:17 Int | ||
diff --git a/testdata/language-features/basic-values/redefine02.reject.out b/testdata/language-features/basic-values/redefine02.reject.out index b990ab72..ea5e22e1 100644 --- a/testdata/language-features/basic-values/redefine02.reject.out +++ b/testdata/language-features/basic-values/redefine02.reject.out | |||
@@ -1,3 +1,3 @@ | |||
1 | "testdata/language-features/basic-values/redefine02.reject.lc" (line 3, column 9): | 1 | "testdata/language-features/basic-values/redefine02.reject.lc" (line 3, column 9): |
2 | expecting identifier, uppercase ident, typed ident, operator definition, lhs or pattern | 2 | expecting expression |
3 | Invalid indentation. Found a token at indentation 8. Expecting a token at an indentation greater than or equal to 13.IndentStream {indentationState = IndentationState {minIndentation = 13, maxIndentation = 14, absMode = False, tokenRel = Ge}, tokenStream = ""} or Invalid indentation. Found a token at indentation 8. Expecting a token at an indentation greater than or equal to 12.IndentStream {indentationState = IndentationState {minIndentation = 12, maxIndentation = 12, absMode = False, tokenRel = Ge}, tokenStream = ""} \ No newline at end of file | 3 | Invalid indentation. Found a token at indentation 8. Expecting a token at an indentation greater than or equal to 13.IndentStream {indentationState = IndentationState {minIndentation = 13, maxIndentation = 14, absMode = False, tokenRel = Ge}, tokenStream = ""} or Invalid indentation. Found a token at indentation 8. Expecting a token at an indentation greater than or equal to 12.IndentStream {indentationState = IndentationState {minIndentation = 12, maxIndentation = 12, absMode = False, tokenRel = Ge}, tokenStream = ""} \ No newline at end of file |
diff --git a/testdata/language-features/basic-values/redefine03.reject.out b/testdata/language-features/basic-values/redefine03.reject.out index a4e20764..31468c1e 100644 --- a/testdata/language-features/basic-values/redefine03.reject.out +++ b/testdata/language-features/basic-values/redefine03.reject.out | |||
@@ -1,4 +1,4 @@ | |||
1 | "testdata/language-features/basic-values/redefine03.reject.lc" (line 4, column 1): | 1 | "testdata/language-features/basic-values/redefine03.reject.lc" (line 4, column 1): |
2 | unexpected end of input | 2 | unexpected end of input |
3 | expecting projection, swizzling, "@", char literal, literal string, float literal, "#", natural, "_", "'", identifier, uppercase ident, dotdot expression, List comprehension, "[", "(", "{", "let", symbols, ":", backquoted ident, "::", "~", "->", "=>", "where", "data", "class", "instance", type family, type instance, "type", typed ident, "infix", "infixl", "infixr", operator definition, lhs or pattern | 3 | expecting projection, swizzling, "@", char literal, literal string, float literal, "#", natural, "_", "'", identifier, uppercase ident, dotdot expression, List comprehension, "[", "(", "{", "let", symbols, ":", backquoted ident, expression, lambda, "::", "~", "->", "=>", "where", "data", "class", "instance", type family, type instance, "type", typed ident, "infix", "infixl", "infixr", operator definition, lhs or pattern |
4 | redefined x at testdata/language-features/basic-values/redefine03.reject.lc 2:9-2:10 \ No newline at end of file | 4 | redefined x at testdata/language-features/basic-values/redefine03.reject.lc 2:9-2:10 \ No newline at end of file |
diff --git a/testdata/language-features/basic-values/where02.reject.out b/testdata/language-features/basic-values/where02.reject.out index 2d4cf109..186eee42 100644 --- a/testdata/language-features/basic-values/where02.reject.out +++ b/testdata/language-features/basic-values/where02.reject.out | |||
@@ -1,3 +1,3 @@ | |||
1 | "testdata/language-features/basic-values/where02.reject.lc" (line 4, column 6): | 1 | "testdata/language-features/basic-values/where02.reject.lc" (line 4, column 6): |
2 | unexpected reserved operator "=" | 2 | unexpected reserved operator "=" |
3 | expecting symbols \ No newline at end of file | 3 | expecting symbols or lambda \ No newline at end of file |
diff --git a/testdata/language-features/guard/guard10.reject.out b/testdata/language-features/guard/guard10.reject.out index 9067b149..56b38afa 100644 --- a/testdata/language-features/guard/guard10.reject.out +++ b/testdata/language-features/guard/guard10.reject.out | |||
@@ -1,3 +1,3 @@ | |||
1 | "testdata/language-features/guard/guard10.reject.lc" (line 2, column 2): | 1 | "testdata/language-features/guard/guard10.reject.lc" (line 2, column 2): |
2 | expecting symbols | 2 | expecting symbols or lambda |
3 | Invalid indentation. Found a token at indentation 1. Expecting a token at an indentation greater than or equal to 2.IndentStream {indentationState = IndentationState {minIndentation = 2, maxIndentation = 6, absMode = False, tokenRel = Ge}, tokenStream = ""} \ No newline at end of file | 3 | Invalid indentation. Found a token at indentation 1. Expecting a token at an indentation greater than or equal to 2.IndentStream {indentationState = IndentationState {minIndentation = 2, maxIndentation = 6, absMode = False, tokenRel = Ge}, tokenStream = ""} \ No newline at end of file |
diff --git a/testdata/listcompr01.reject.out b/testdata/listcompr01.reject.out index 5cb55a0d..2b83196c 100644 --- a/testdata/listcompr01.reject.out +++ b/testdata/listcompr01.reject.out | |||
@@ -1,3 +1,3 @@ | |||
1 | "testdata/listcompr01.reject.lc" (line 6, column 42): | 1 | "testdata/listcompr01.reject.lc" (line 6, column 42): |
2 | unexpected ',' | 2 | unexpected ',' |
3 | expecting end of "]", projection, swizzling, "@", char literal, literal string, float literal, "#", natural, "_", "'", identifier, uppercase ident, dotdot expression, List comprehension, "[", "(", "{", "let", symbols, ":", backquoted ident, "::", "~", "->", "=>", "where", "data", "class", "instance", type family, type instance, "type", typed ident, "infix", "infixl", "infixr", operator definition, lhs, pattern or end of input \ No newline at end of file | 3 | expecting end of "]", projection, swizzling, "@", char literal, literal string, float literal, "#", natural, "_", "'", identifier, uppercase ident, dotdot expression, List comprehension, "[", "(", "{", "let", symbols, ":", backquoted ident, expression, lambda, "::", "~", "->", "=>", "where", "data", "class", "instance", type family, type instance, "type", typed ident, "infix", "infixl", "infixr", operator definition, lhs, pattern or end of input \ No newline at end of file |