Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.compilers    |    Compiler construction, theory, etc. (Mod    |    2,753 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 1,398 of 2,753    |
|    Aeran to All    |
|    Re: Parser question    |
|    13 Jul 08 11:33:06    |
      From: avron2006b@yahoo.com              You probably want to identify tail recursion. If nothing is built up on       the stack while recursing it is possible to avoid the recursive call. If       you have a grammar like: a -> Ba|N then you can when implementing the       parser instead of writing it like:       sub a()        matchB        if (look == 'N') matchN else a()       end sub              You could write it like this:       sub a()        loop forever        matchB        if (look == 'N')        matchN        break out from loop              You can also avoid doing a procedure call for every nonterminal. The       grammar you wrote above you could fit into one procedure:              sub expr        term()        if (look == '+')        match+        term()        elseif (look == '-')        match-        term()              The above procedure cover both expr and moreterms.              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca