aboutsummaryrefslogtreecommitdiff
path: root/frontend/parse.icl
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/parse.icl')
-rw-r--r--frontend/parse.icl27
1 files changed, 23 insertions, 4 deletions
diff --git a/frontend/parse.icl b/frontend/parse.icl
index be4cbaa..82a88e3 100644
--- a/frontend/parse.icl
+++ b/frontend/parse.icl
@@ -3674,6 +3674,20 @@ string_to_int s
trySimpleNonLhsExpressionT :: !Token *ParseState -> *(!Bool,!ParsedExpr,!*ParseState)
trySimpleNonLhsExpressionT BackSlashToken pState
+ # (token, pState) = nextToken FunctionContext pState
+ | token == CaseToken
+ # (lam_ident, pState) = internalIdent "_lcl" pState
+ (case_ident, pState) = internalIdent "_lcc" pState
+ (arg_ident, pState) = internalIdent "_lca" pState
+ (alts, pState) = wantCaseOfExp pState
+ (file_name, line_nr, pState)
+ = getFileAndLineNr pState
+ position = FunPos file_name line_nr lam_ident.id_name
+ expr = PE_Case case_ident (PE_Ident arg_ident) alts
+ ewl = {ewl_nodes = [], ewl_expr = expr, ewl_locals = LocalParsedDefs [], ewl_position = LinePos file_name line_nr}
+ rhs = {rhs_alts = UnGuardedExpr ewl, rhs_locals = LocalParsedDefs []}
+ = (True, PE_Lambda lam_ident [PE_Ident arg_ident] rhs position, pState)
+ # pState = tokenBack pState
# (lam_ident, pState) = internalIdent (toString backslash) pState
(file_name, line_nr, pState)
= getFileAndLineNr pState
@@ -4162,15 +4176,20 @@ where
wantCaseExp :: !ParseState -> (ParsedExpr, !ParseState)
wantCaseExp pState
# (case_ident, pState) = internalIdent "_c" pState
- (case_exp, pState) = wantExpression pState
- pState = wantToken FunctionContext "case expression" OfToken pState
+ # (case_exp, pState) = wantExpression pState
+ # (alts, pState) = wantCaseOfExp pState
+ = (PE_Case case_ident case_exp alts, pState)
+
+wantCaseOfExp :: !ParseState -> ([CaseAlt], !ParseState)
+wantCaseOfExp pState
+ # pState = wantToken FunctionContext "case expression" OfToken pState
pState = wantBeginGroup "case" pState
(case_alts, (definingSymbol,pState))
= parseList tryCaseAlt (RhsDefiningSymbolCase, pState)
(found, alt, pState) = tryLastCaseAlt definingSymbol pState
| found
- = (PE_Case case_ident case_exp (case_alts++[alt]), wantEndCase pState)
- = (PE_Case case_ident case_exp case_alts, wantEndCase pState)
+ = ((case_alts++[alt]), wantEndCase pState)
+ = (case_alts, wantEndCase pState)
where
tryCaseAlt :: (!RhsDefiningSymbol, !ParseState) -> (!Bool, CaseAlt, (!RhsDefiningSymbol, !ParseState))
tryCaseAlt (definingSymbol, pState)