forked from lix-project/lix
* Let syntax.
This commit is contained in:
parent
a2a9bacd82
commit
1b4184ccbb
|
@ -160,6 +160,11 @@ Expr evalExpr2(EvalState & state, Expr e)
|
||||||
if (ATmatch(e, "Rec([<list>])", &bnds))
|
if (ATmatch(e, "Rec([<list>])", &bnds))
|
||||||
return expandRec(e, (ATermList) bnds);
|
return expandRec(e, (ATermList) bnds);
|
||||||
|
|
||||||
|
/* Let expressions `let {..., body = ...}' are just desugared
|
||||||
|
into `(rec {..., body = ...}).body'. */
|
||||||
|
if (ATmatch(e, "LetRec(<term>)", &e1))
|
||||||
|
return evalExpr(state, ATmake("Select(Rec(<term>), \"body\")", e1));
|
||||||
|
|
||||||
/* Barf. */
|
/* Barf. */
|
||||||
throw badTerm("invalid expression", e);
|
throw badTerm("invalid expression", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,9 @@ exports
|
||||||
"rec" "{" {Bind ","}* "}"
|
"rec" "{" {Bind ","}* "}"
|
||||||
-> Expr {cons("Rec")}
|
-> Expr {cons("Rec")}
|
||||||
|
|
||||||
|
"let" "{" {Bind ","}* "}"
|
||||||
|
-> Expr {cons("LetRec")}
|
||||||
|
|
||||||
"{" {Bind ","}* "}"
|
"{" {Bind ","}* "}"
|
||||||
-> Expr {cons("Attrs")}
|
-> Expr {cons("Attrs")}
|
||||||
|
|
||||||
|
@ -59,6 +62,12 @@ exports
|
||||||
Expr "." Id
|
Expr "." Id
|
||||||
-> Expr {cons("Select")}
|
-> Expr {cons("Select")}
|
||||||
|
|
||||||
|
"if" Expr "then" Expr "else" Expr
|
||||||
|
-> Expr {cons("If")}
|
||||||
|
|
||||||
|
Expr "==" Expr
|
||||||
|
-> Expr {cons("OpEq")}
|
||||||
|
|
||||||
context-free priorities
|
context-free priorities
|
||||||
|
|
||||||
Expr "." Id -> Expr
|
Expr "." Id -> Expr
|
||||||
|
|
Loading…
Reference in a new issue