[Haskell-beginners] A Pascal-like Language Compiler

Larry Evans cppljevans at suddenlink.net
Thu Oct 23 09:37:51 EDT 2008

  On 10/23/08 03:23, Joel Björnson wrote:
> On Thu, Oct 23, 2008 at 12:18 AM, Pranesh Srinivasan <spranesh at gmail.com> wrote:
>> That seems like a very nice scheme to follow. I had a similar method in
>> mind. Step 3 is what I am really worried about. How easy/difficult will
>> it be in a pure func language, to "transform" the sytnax tree.
> I think the pureness is actually an advantage here, since the
> transformation is a function from one syntax tree to another. If
> however, you feel the need of keeping a state and you don't wanna pass
> around this explicitly, you may consider using a state monad.
>> I have to take a deeper look at BNFC. But from an initial look, it seems
>> way too powerful for me to use? At least as powerful as yacc. And that
>> with Haskell, should give me a very good toolset-advantage?
> If the project is about writing parsers then using BNFC would probably
> be considered cheating. But for practical purposes I think it's a
> great tool that would save you a lot of work.
> - Joel
HI Joel.

Does BNFC calculate the lookahead sets for a grammar?
I'm attempting to do this with haskell, but I would hate
to "reinvent the wheel".  I would think if haskell can tranform
a syntax tree, then haskell could transform a grammar tree
to calculate the lookahead sets.  My purpose it not so much
create a compiler as illustrate how it's done.  I found the
Dragon's book description hard to follow and thought
redoing it using functors (to transform the tree into
another, with different operators) then simplify the
transformed trees (one tree for each lookahead set)
then find the fixpoint of those trees (really forest:
1 tree for each production) would be a good way
to demonstrate the method.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20081023/88ec8c43/attachment.htm

More information about the Beginners mailing list