LR Parsing algorithm

kiddiegrinderkiddiegrinder Join Date: 2004-01-09 Member: 25181Members, Constellation
<div class="IPBDescription">JAVA</div>Hi,

Im trying to make a java program that will take in a word an use a grammar (context-free) to convert it into a parse tree (an print it out somehow...).

Im just trying to think of how I would do it in a resutling string first like...

word = abcde

grammar =

S -> abcE
E -> de

"abcde -> abcE -> S"

If anyone has looked at parsing before (an how compilers are generated) pm me <img src="style_emoticons/<#EMO_DIR#>/smile-fix.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile-fix.gif" />

I've already written a program to convert a CFG -> PDA but that was a lot easier than making a parser...

Any suggestions would be welcome <img src="style_emoticons/<#EMO_DIR#>/smile-fix.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile-fix.gif" />

Comments

  • BlackMageBlackMage [citation needed] Join Date: 2003-06-18 Member: 17474Members, Constellation
    edited December 2006
    can't be of much help with java but my imageboards use perl context-free grammar thingamadoodles to generate the codes for CAPTCHA, the code was blatantly stolen from here: <a href="http://www.ruf.rice.edu/%7Epound/#werd" target="_blank">http://www.ruf.rice.edu/%7Epound/#werd</a>
  • douchebagatrondouchebagatron Custom member title Join Date: 2003-12-20 Member: 24581Members, Constellation, Reinforced - Shadow
    im not sure exactly what you want to do, but it sounds like you might want to use a hashmap or hashtable. maybe.
  • kiddiegrinderkiddiegrinder Join Date: 2004-01-09 Member: 25181Members, Constellation
    <!--quoteo(post=1592513:date=Dec 27 2006, 12:53 AM:name=Black_Mage)--><div class='quotetop'>QUOTE(Black_Mage @ Dec 27 2006, 12:53 AM) [snapback]1592513[/snapback]</div><div class='quotemain'><!--quotec-->
    can't be of much help with java but my imageboards use perl context-free grammar thingamadoodles to generate the codes for CAPTCHA, the code was blatantly stolen from here: <a href="http://www.ruf.rice.edu/%7Epound/#werd" target="_blank">http://www.ruf.rice.edu/%7Epound/#werd</a>
    <!--QuoteEnd--></div><!--QuoteEEnd-->

    Wicked cheers, that should be helpful thanks,

    Im also thinking of a way to convert a pushdown automata to a grammar if that would be easier
Sign In or Register to comment.