forked from lix-project/lix
* Grammar changes. Attributes in attribute sets are now delimited with
semicolons instead of comma's. Final semicolon in the set is optional.
This commit is contained in:
parent
40986312bb
commit
ad0976f8d5
|
@ -20,60 +20,45 @@ exports
|
|||
sorts Expr Bind
|
||||
context-free syntax
|
||||
|
||||
Id
|
||||
-> Expr {cons("Var")}
|
||||
Id -> Expr {cons("Var")}
|
||||
|
||||
Int
|
||||
-> Expr {cons("Int")}
|
||||
Int -> Expr {cons("Int")}
|
||||
|
||||
Str
|
||||
-> Expr {cons("Str")}
|
||||
Str -> Expr {cons("Str")}
|
||||
|
||||
Uri
|
||||
-> Expr {cons("Uri")}
|
||||
Uri -> Expr {cons("Uri")}
|
||||
|
||||
Path
|
||||
-> Expr {cons("Path")}
|
||||
Path -> Expr {cons("Path")}
|
||||
|
||||
"(" Expr ")"
|
||||
-> Expr {bracket}
|
||||
"(" Expr ")" -> Expr {bracket}
|
||||
|
||||
Expr Expr
|
||||
-> Expr {cons("Call"), left}
|
||||
Expr Expr -> Expr {cons("Call"), left}
|
||||
|
||||
"{" {Id ","}* "}" ":" Expr
|
||||
-> Expr {cons("Function"), right}
|
||||
"{" {Id ","}* "}" ":" Expr -> Expr {cons("Function"), right}
|
||||
|
||||
"rec" "{" {Bind ","}* "}"
|
||||
-> Expr {cons("Rec")}
|
||||
"rec" "{" Binds "}" -> Expr {cons("Rec")}
|
||||
"let" "{" Binds "}" -> Expr {cons("LetRec")}
|
||||
"{" Binds "}" -> Expr {cons("Attrs")}
|
||||
|
||||
"let" "{" {Bind ","}* "}"
|
||||
-> Expr {cons("LetRec")}
|
||||
Id "=" Expr -> Bind {cons("Bind")}
|
||||
{Bind ";"}* -> Binds
|
||||
Bind ";" -> BindSemi
|
||||
BindSemi* -> Binds
|
||||
|
||||
"{" {Bind ","}* "}"
|
||||
-> Expr {cons("Attrs")}
|
||||
"[" Expr* "]" -> Expr {cons("List")}
|
||||
|
||||
Id "=" Expr
|
||||
-> Bind {cons("Bind")}
|
||||
Expr "." Id -> Expr {cons("Select")}
|
||||
|
||||
"[" {Expr ","}* "]"
|
||||
-> Expr {cons("List")}
|
||||
"if" Expr "then" Expr "else" Expr -> Expr {cons("If")}
|
||||
|
||||
Expr "." Id
|
||||
-> Expr {cons("Select")}
|
||||
Expr "==" Expr -> Expr {cons("OpEq")}
|
||||
|
||||
"if" Expr "then" Expr "else" Expr
|
||||
-> Expr {cons("If")}
|
||||
|
||||
Expr "==" Expr
|
||||
-> Expr {cons("OpEq")}
|
||||
|
||||
Bool
|
||||
-> Expr {cons("Bool")}
|
||||
Bool -> Expr {cons("Bool")}
|
||||
|
||||
context-free priorities
|
||||
|
||||
Expr "." Id -> Expr
|
||||
>
|
||||
> Expr Expr -> Expr
|
||||
> "{" {Id ","}* "}" ":" Expr -> Expr
|
||||
|
||||
|
|
|
@ -147,6 +147,9 @@ Expr parseExprFromFile(Path path)
|
|||
if (!imploded)
|
||||
throw Error(format("cannot implode parse tree"));
|
||||
|
||||
debug(format("imploded parse tree of `%1%': %2%")
|
||||
% path % printTerm(imploded));
|
||||
|
||||
/* Finally, clean it up. */
|
||||
Cleanup cleanup;
|
||||
cleanup.basePath = dirOf(path);
|
||||
|
|
Loading…
Reference in a new issue