* 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:
Eelco Dolstra 2003-11-03 10:21:30 +00:00
parent 40986312bb
commit ad0976f8d5
2 changed files with 24 additions and 36 deletions

View File

@ -20,60 +20,45 @@ exports
sorts Expr Bind sorts Expr Bind
context-free syntax context-free syntax
Id Id -> Expr {cons("Var")}
-> Expr {cons("Var")}
Int Int -> Expr {cons("Int")}
-> Expr {cons("Int")}
Str Str -> Expr {cons("Str")}
-> Expr {cons("Str")}
Uri Uri -> Expr {cons("Uri")}
-> Expr {cons("Uri")}
Path Path -> Expr {cons("Path")}
-> Expr {cons("Path")}
"(" Expr ")" "(" Expr ")" -> Expr {bracket}
-> Expr {bracket}
Expr Expr Expr Expr -> Expr {cons("Call"), left}
-> Expr {cons("Call"), left}
"{" {Id ","}* "}" ":" Expr "{" {Id ","}* "}" ":" Expr -> Expr {cons("Function"), right}
-> Expr {cons("Function"), right}
"rec" "{" {Bind ","}* "}" "rec" "{" Binds "}" -> Expr {cons("Rec")}
-> Expr {cons("Rec")} "let" "{" Binds "}" -> Expr {cons("LetRec")}
"{" Binds "}" -> Expr {cons("Attrs")}
"let" "{" {Bind ","}* "}" Id "=" Expr -> Bind {cons("Bind")}
-> Expr {cons("LetRec")} {Bind ";"}* -> Binds
Bind ";" -> BindSemi
BindSemi* -> Binds
"{" {Bind ","}* "}" "[" Expr* "]" -> Expr {cons("List")}
-> Expr {cons("Attrs")}
Id "=" Expr Expr "." Id -> Expr {cons("Select")}
-> Bind {cons("Bind")}
"[" {Expr ","}* "]" "if" Expr "then" Expr "else" Expr -> Expr {cons("If")}
-> Expr {cons("List")}
Expr "." Id Expr "==" Expr -> Expr {cons("OpEq")}
-> Expr {cons("Select")}
"if" Expr "then" Expr "else" Expr Bool -> Expr {cons("Bool")}
-> Expr {cons("If")}
Expr "==" Expr
-> Expr {cons("OpEq")}
Bool
-> Expr {cons("Bool")}
context-free priorities context-free priorities
Expr "." Id -> Expr Expr "." Id -> Expr
>
> Expr Expr -> Expr > Expr Expr -> Expr
> "{" {Id ","}* "}" ":" Expr -> Expr > "{" {Id ","}* "}" ":" Expr -> Expr

View File

@ -147,6 +147,9 @@ Expr parseExprFromFile(Path path)
if (!imploded) if (!imploded)
throw Error(format("cannot implode parse tree")); throw Error(format("cannot implode parse tree"));
debug(format("imploded parse tree of `%1%': %2%")
% path % printTerm(imploded));
/* Finally, clean it up. */ /* Finally, clean it up. */
Cleanup cleanup; Cleanup cleanup;
cleanup.basePath = dirOf(path); cleanup.basePath = dirOf(path);