Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Ocamlburg problem
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christian Lindig <lindig@c...>
Subject: Re: [Caml-list] Ocamlburg problem

On Apr 23, 2004, at 6:48 AM, Ken Rose wrote:

> Does anyone have any experience debugging OCamlBurg code generators? 
> I'm getting an "Uncovered" exception, and I'm unable to figure out why 
> it's failing.  Debugging tips, anyone?

An Uncovered exception means, your subject tree cannot be matched with 
your rules - a rule is missing. In general it is quite difficult to 
argue that an existing set of rules in complete.

For debugging our OCamlburg rules we have no magic bullet. When an 
Uncovered exception occurs we pretty print the subject tree and inspect 
it manually.

Another trick is to have a set of rules in addition to the existing 
rules. These rules are constructed in way that they always cover the 
subject tree. For example, we are having rules for an "any" nonterminal 
to match a certain kind of expressions.

any : True  ()          {: cat [ "True"  ] :}
any : False ()          {: cat [ "False" ] :}
any : Link(x, w:int)    {: cat [ "Link(";x#mangled_text;",";width w;")" 
] :}
any : Late(string,w:int){: cat [ "Late(";string;",";width w;")" ] :}
any : Bits(bits)        {: cat [ "Bits(b)" ] :}

any : Fetch (any, w:int){: cat [ "Fetch(";any;",";width w;")" ] :}

any : Add(x:any, y:any) {: cat [ "Add(";x;", ";y;")" ] :}
any : Sub(x:any, y:any) {: cat [ "Sub(";x;", ";y;")" ] :}
any : Sx(any)           {: cat [ "Sx(";any;")" ] :}
any : Zx(any)           {: cat [ "Zx(";any;")" ] :}
any : Lobits(any)       {: cat [ "Lobits(";any;")" ] :}

These rules just follow the syntactical structure of the subject tree 
and thus we know it will always match. The semantic actions simply 
build a string of the subject tree. If you guard this set of rules with 
a high cost it will never match when your real rules can find a cover, 
but it matches otherwise and you won't get an Uncovered.

You can find this code here:

	http://www.cminusminus.org/rsync/qc--/src/alpharec.nw



-- Christian

--
http://www.st.cs.uni-sb.de/~lindig/

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners