From ad0976f8d5f2afbca4e2fe6cbb3d2c2e53760222 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 3 Nov 2003 10:21:30 +0000 Subject: [PATCH] * Grammar changes. Attributes in attribute sets are now delimited with semicolons instead of comma's. Final semicolon in the set is optional. --- src/fix-ng/fix.sdf | 57 ++++++++++++++++---------------------------- src/fix-ng/parser.cc | 3 +++ 2 files changed, 24 insertions(+), 36 deletions(-) diff --git a/src/fix-ng/fix.sdf b/src/fix-ng/fix.sdf index 8effe6d21..e09480314 100644 --- a/src/fix-ng/fix.sdf +++ b/src/fix-ng/fix.sdf @@ -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 diff --git a/src/fix-ng/parser.cc b/src/fix-ng/parser.cc index 7dff0363d..e159262ca 100644 --- a/src/fix-ng/parser.cc +++ b/src/fix-ng/parser.cc @@ -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);