I'm no expert, but I'll hazard some answers: On Wed, Jun 28, 2006 at 04:26:45AM -0500, João Cruz Morais wrote: > I'm new to Parrot but reading from your slides if I understood correctly: > - PGE parses input according to a grammar and produces a derivation tree. > - TGE transforms the parse tree into an abstract syntax tree. > > With that said I have some questions (i'm sorry if they were answered > already somewhere): > - Whats the point of using PGE+TGE over the good old LEX+YACC besides the > better regexps?
I think lex+yacc is approximately equivalent to PGE alone. TGE is something different. You can't really say "besides the better regexps" because that's part of the point--having better tools with which to transform one language into another. PGE lets you annotate how the source language fits together (what's a token and what order the tokens may come in, etc.) while TGE let's you take those annotations and turn them into alternate (presumably more useful) representations. > - Can I use PGE skipping TGE? I don't see why not. If you look at the bottom of grammar_rules.pg, you'll see this: token syntax_error { <?PGE::Util::die: Syntax error> } where PGE::Util::die is a PIR subroutine. IIUC, everywhere you want some action to be performed (like code generation for instance) you could put a PIR subroutine in the grammar just as above and, of course, write the subroutine to do the action. > - PAST seems just fine as a concept but isn't it useless if I can target > directly to POST with minor fuss? It may be "uesless" in that specific case, but I think it's highly useful in the general case where the impedence mismatch between the language you are parsing and the language you are generating may be large (like say, between a very complex and rich language like Perl6 and a much simpler language like PIR ;). TGE lets you factor out the complexity of your source language in incremental steps (as small or as large steps as you want). > Good luck for today's presentation :) Yeah, good luck Pm :) -Scott -- Jonathan Scott Duff [EMAIL PROTECTED]