Skip to content

Commit 2f4ae24

Browse files
committed
add matchlambda
1 parent 382298b commit 2f4ae24

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

hs-src/Language/Egison/ParserNonS.hs

+4
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ term = P.lexeme lexer
229229
term' :: Parser EgisonExpr
230230
term' = matchExpr
231231
<|> matchAllExpr
232+
<|> matchLambdaExpr
232233
<|> matcherExpr
233234
<|> matcherDFSExpr
234235
<|> functionWithArgExpr
@@ -322,6 +323,9 @@ matchAllExpr = keywordMatchAll >> MatchAllExpr <$> expr <* (inSpaces $ string "a
322323
matchExpr :: Parser EgisonExpr
323324
matchExpr = keywordMatch >> MatchExpr <$> expr <* (inSpaces $ string "as") <*> expr <*> matchClauses
324325

326+
matchLambdaExpr :: Parser EgisonExpr
327+
matchLambdaExpr = keywordMatchLambda >> MatchLambdaExpr <$ (inSpaces $ string "as") <*> expr <*> matchClauses
328+
325329
matchClauses :: Parser [MatchClause]
326330
matchClauses = many1 matchClause
327331

lib/math/expression.egi

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
[_ {}]}]
4040
[<apply $ $> [eq (list math-expr)]
4141
{[<Div <Plus {<Term 1 {[<Apply $v $mexprs> 1] @{}}> @{}}>
42-
<Plus {<Term 1 {}> @{}}>>
42+
<Plus {<Term 1 {}> @{}}>>
4343
{[v (map to-math-expr' mexprs)]}]
4444
[_ {}]}]
4545
[<quote $> [math-expr]
@@ -281,7 +281,7 @@
281281
[_ #f]})
282282
xs))]}))
283283
{@ts1 @ts2})]}))))
284-
284+
285285
(define $find-symbols-from-poly
286286
(lambda [$poly]
287287
(match-all poly math-expr
@@ -301,7 +301,7 @@
301301
(lambda [$x $a $mexpr]
302302
(map-symbols (rewrite-symbol x a $) mexpr)))
303303

304-
(define $rewrite-symbol
304+
(define $rewrite-symbol
305305
(lambda [$x $a $sexpr]
306306
(match sexpr symbol-expr
307307
{[,x a]

0 commit comments

Comments
 (0)