|
Hi Roger, Roger Pomeroy wrote: I was just wondering if there is any documentation on the AST transformations, other than that at Nat Pryce's website. There isn't much additional documentation. There's a document somewhere on the site by Kevin (Komivi Agbakpem) who developed the code. Actually, the principles and the syntax are simple enough. The main problem is not so much the documentation; it's the error messages. I keep running into errors like java.lang.RuntimeException: [388,55] expecting #LPObjectName# when #PObjectName?# was found java.lang.RuntimeException: [388,60] production PForList was transformed, and may not appear here undecorated. Both of these errors indicate a problem with the cardinality of some element in your transformation. The first message is about a one vs one-or-zero cardinality problem, e.g. a {-> b } =
x b? y {-> b };
"a" transforms into a "b", yet the alternative transformation yields a
"b?" (as the "b" has a "?" in the alternative). This can be fixed by
fixing the cardinality of "b?" in the production transformation:a {-> b? } =
x b? y {-> b };
The second error is probably due to a similar problem involving lists,
instead of optional elements. e.g.a {-> b* } =
x b? y {-> b };
It can be fixed by providing the expected list:a {-> b* } =
x b? y {-> [b] };
Most of the cryptic error messages are related to such
cardinality problems.SableCC 4 is designed to give much clearer messages. As the code is meant to be maintainable, it should be easy to improve any message that users don't find clear enough. Also, SableCC 4 infers most simple AST transformations. In many cases, one will hopefully just write a parser grammar and a tree grammar, without needing to provide explicit transformations. Also, any more ideas on when SableCC 4 will be ready? I have been so impressed by how easy this has been so far (especially considering I'm doing this for the first time...) but there are a couple of the ver 4 features I'll eventually need. I know; everyone wants SableCC 4 yesterday, myself included. It would be so neat to have SableCC 4 to develop SableCC 4... Yeah, I'm working on it. I don't want to promise any deadline, as everything has taken much more time than I anticipated. I'm trying to get the lexer generator out, as the lexer engine is currently fully operational, but when I started tying the engine with the input syntax, I realized that it was necessary to do all semantic verifications at once, including the parser part. I couldn't just verify the lexer part, as there are strong semantic ties between all the parts. So, again, it is taking more time than anticipated. Etienne -- Etienne M. Gagnon, Ph.D. SableCC: http://sablecc.org |
Attachment:
signature.asc
Description: OpenPGP digital signature