diff options
author | Camil Staps | 2017-03-06 22:09:49 +0100 |
---|---|---|
committer | Camil Staps | 2017-03-06 22:11:55 +0100 |
commit | 0cd7371ce8f7956a856f11632ea2fbd7a88fda75 (patch) | |
tree | e5dc63b97c81e9d58a1aeedcfb1516d372d8d62e | |
parent | Readme (diff) |
Make of in lambdacase optional
-rw-r--r-- | README.md | 9 | ||||
-rw-r--r-- | frontend/parse.icl | 14 |
2 files changed, 17 insertions, 6 deletions
@@ -41,6 +41,15 @@ is transformed to where `x` is a fresh variable. +The `of` is optional (though recommended to distinguish Clean from Haskell). + +The extension to the grammar: + +``` +LambdaAbstr = ... + | \case [of] {CaseAltDef}+ +``` + [clean]: http://clean.cs.ru.nl [cocl]: https://svn.cs.ru.nl/repos/clean-compiler/ [ghclambdacase]: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#lambda-case diff --git a/frontend/parse.icl b/frontend/parse.icl index 82a88e3..d5b15ef 100644 --- a/frontend/parse.icl +++ b/frontend/parse.icl @@ -3676,10 +3676,12 @@ trySimpleNonLhsExpressionT :: !Token *ParseState -> *(!Bool,!ParsedExpr,!*ParseS trySimpleNonLhsExpressionT BackSlashToken pState # (token, pState) = nextToken FunctionContext pState | token == CaseToken + # (token, pState) = nextToken FunctionContext pState + # pState = if (token == OfToken) id tokenBack pState # (lam_ident, pState) = internalIdent "_lcl" pState (case_ident, pState) = internalIdent "_lcc" pState (arg_ident, pState) = internalIdent "_lca" pState - (alts, pState) = wantCaseOfExp pState + (alts, pState) = wantCaseAlts pState (file_name, line_nr, pState) = getFileAndLineNr pState position = FunPos file_name line_nr lam_ident.id_name @@ -4177,13 +4179,13 @@ wantCaseExp :: !ParseState -> (ParsedExpr, !ParseState) wantCaseExp pState # (case_ident, pState) = internalIdent "_c" pState # (case_exp, pState) = wantExpression pState - # (alts, pState) = wantCaseOfExp pState + # pState = wantToken FunctionContext "case expression" OfToken pState + # (alts, pState) = wantCaseAlts 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 +wantCaseAlts :: !ParseState -> ([CaseAlt], !ParseState) +wantCaseAlts pState + # pState = wantBeginGroup "case" pState (case_alts, (definingSymbol,pState)) = parseList tryCaseAlt (RhsDefiningSymbolCase, pState) (found, alt, pState) = tryLastCaseAlt definingSymbol pState |