Thank you for being so patient to a newbie.
It's just homework and I think it's not that deep because the course is only
about Perl.
I'm interested in parsing, but I haven't learnt much about it yet.

2011/4/25 Shlomi Fish <shlo...@iglu.org.il>

> Hi "Z",
>
> you replied to me in private (unintentionally, I presume), so I'm CCing the
> list on my reply (I hope it's OK).
>
> On Monday 25 Apr 2011 12:07:54 z sway wrote:
> > Hi,sorry I hadn't said it clearly,what I want to do is to generate a LOL
> > from an expression and try* *not to use any extra modules.
>
> OK, one thing you should realise is that, to quote my late grandfather,
> Perl
> without CPAN is like a cat without whiskers[whiskers]. While it sometimes
> makes sense to reduce dependencies[Deps], often many modules on CPAN are
> self-
> contained, or have very few dependencies and you can stick them in one
> place
> and forget about them or pack them in PAR. See:
>
> http://www.shadowcat.co.uk/blog/matt-s-trout/but-i-cant-use-cpan/
>
> (Matt S. Trout has an offensive and insulting style, so you have been
> warned,
> but he still says wise things of substance.).
>
> Anyway, you can put one of the parser generators on your system, and I
> think
> byacc-perl generates self-contained Perl code.
>
> > So far i've only got an idea that spilt the expression into a list_A,in
> > which each element is a number or"+*()",use list_B as a stack,pop from
> > list_A,push to list_B under some rules,finally got the tree in list_B.
> >
> > I think my method is a bit complicated,there should be a easier one even
> if
> > can't detect some mistakes like (5+)2)*5 or 6++7*8
> >
>
> Implementing your own Parse-Recdescent (or worse LALR/GLR/etc.) parser is
> prone to errors and inadvisable, especially if you don't have a lot of
> theoretical background. Unless this is homework in compilation theory or a
> similar course (which most universities don't really do in Perl, for better
> or
> for worse), then please use a parser generator, in case you're interested
> in
> writing your code quickly and correctly, rather than re-inventing your own
> square wheel (and trust me - it will be square).
>
> If you *are* interested in learning more about compiler theory and parsing,
> then I liked the Dragon book (read the green one I think, but there's
> already
> a newer Purple dragon one which should be better), and while it has some
> issues, is pretty good:
>
> http://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools
>
> There are many other online and offline books, tutorials and resources (on
> http://www.wikibooks.org/ / etc.), and you should be good to go. But doing
> it
> without learning it first is not a good idea. To quote
> http://en.wikiquote.org/wiki/Euclid , "There is no royal road to
> geometry",
> because sometimes various issues in computer science require learning some
> theory to do properly. Note though that parsing theory is not *that* hard.
>
> Sorry for the long post.
>
> Regards,
>
>        Shlomi Fish
>
> [whiskers] - I have only understood this sentence later on when I realised
> that cats with damaged whiskers lose their balance, and are very non-
> functional:
>
> http://en.wikipedia.org/wiki/Whiskers
>
> It didn't help that my grandfather said it in Hebrew, using the same word
> for
> "whiskers" as the Hebrew word for "moustache", which is completely
> inessential
> for humans to survive. There is an English idiom called "the Cat's
> whiskers",
> but I think it means more like "the top of the top" or "la creme de la
> creme".
>
> [Deps] - It is discussed here:
>
> http://www.onlamp.com/pub/a/onlamp/2004/04/08/disaster_recovery.html
>
> It kinda reminds me of "Can you build a package in one command?" from the
> "McConnell test"/"Joel test":
>
> http://www.joelonsoftware.com/articles/fog0000000043.html
>
>
> --
> -----------------------------------------------------------------
> Shlomi Fish       http://www.shlomifish.org/
> Understand what Open Source is - http://shlom.in/oss-fs
>
> There is no IGLU Cabal! None of them could pass the Turing test. But
> strangely
> enough a computer program they coded, could.
>
> Please reply to list if it's a mailing list post - http://shlom.in/reply .
>

Reply via email to