Skip to content

Commit

Permalink
all exceptions are turned into buffered problems; all tests pass!
Browse files Browse the repository at this point in the history
  • Loading branch information
grammarware committed Jan 7, 2013
1 parent d31977e commit 07aaf3c
Show file tree
Hide file tree
Showing 3 changed files with 297 additions and 213 deletions.
28 changes: 22 additions & 6 deletions shared/rascal/src/transform/Results.rsc
Expand Up @@ -2,15 +2,23 @@
module transform::Results

import syntax::BGF;
//import syntax::XBGF;
import syntax::XBGF;

data XBGFOutcome
= ok()
| problem(str msg)
| problemXBGF(str msg, XBGFCommand xbgf)
| problemProd(str msg, BGFProduction p)
| problemProd2(str msg, BGFProduction p1, BGFProduction p2)
| problemPinProds(str msg, BGFProduction p, list[BGFProduction] ps)
| problemProds(str msg, list[BGFProduction] ps)
| problemProds2(str msg, list[BGFProduction] ps1, list[BGFProduction] ps2)
| problemExpr(str msg, BGFExpression e)
| problemExpr2(str msg, BGFExpression e1, BGFExpression e2)
| problemNT(str msg, str x)
| problemNT2(str msg, str x, str y)
| problemStr(str msg, str x)
| problemStr2(str msg, str x, str y)
| problemStrs(str msg, list[str] xs)
| problemScope(str msg, XBGFScope w)
| manyProblems(list[XBGFOutcome] lst)
;

Expand All @@ -30,10 +38,18 @@ public XBGFResult add(XBGFResult x, XBGFResult y) = <add(x.r,y.r),y.g>;
public XBGFResult add(XBGFOutcome x, XBGFResult y) = <add(x,y.r),y.g>;

public void thw(ok()) {}
public void thw(problem(str msg)) {throw msg;}
public void thw(problemXBGF(str msg, XBGFCommand xbgf)) {throw msg+":\n<xbgf>";}
public void thw(problemProd(str msg, BGFProduction p)) {throw msg+":\n<p>";}
public void thw(problemNT(str msg, str x)) {throw msg+": <x>";}
public void thw(problemNT2(str msg, str x, str y)) {throw msg+": <x> and <y>";}
public void thw(problemExpr(str msg, BGFExpression e)) {throw msg+":\n<e>";}
public void thw(problemProd2(str msg, BGFProduction p1, BGFProduction p2)) {throw msg+":\n\t<p1>\nand\n\t<p2>";}
public void thw(problemPinProds(str msg, BGFProduction p, list[BGFProduction] ps)) {throw msg+"\n\t<p>\nin\n\t<ps>";}
public void thw(problemProds(str msg, list[BGFProduction] ps)) {throw msg+":\n<ps>";}
public void thw(problemProds2(str msg, list[BGFProduction] ps1, list[BGFProduction] ps2)) {throw msg+":\n<ps1>\nvs\n<ps2>";}
public void thw(problemStr(str msg, str x)) {throw msg+": <x>";}
public void thw(problemStr2(str msg, str x, str y)) {throw msg+": <x> and <y>";}
public void thw(problemStrs(str msg, list[str] xs)) {throw msg+":\n\t<xs>";}
public void thw(problemExpr(str msg, BGFExpression e)) {throw msg+":\n\t<e>";}
public void thw(problemExpr2(str msg, BGFExpression e1, BGFExpression e2)) {throw msg+":\n<e1> and <e2>";}
public void thw(problemScope(str msg, XBGFScope w)) {throw "<msg> in <w>";}
public void thw(manyProblems(list[XBGFOutcome] lst)) {for (x <- lst) thw(x);} // will not work
public default void thw(XBGFOutcome x) {}

0 comments on commit 07aaf3c

Please sign in to comment.