[antlr-interest] Re: PERL VS ANTLR
cintyram <cintyram at yahoo.com>
cintyram at yahoo.com
Wed Jan 29 11:10:05 PST 2003
you are right, and i stand corrected ;
my answer was not comprehensive enough to state that antlr does not
support all cfgs but only predicated LL ; on the other hand , though i
must admit to my being not the expert on this, LR grammars can be
represented by an equivalent LL grammar ;
i remember having done some exercises on this in the compiler theory
class ;
also since regular grammars are based on finite automata , and cfgs
are based on pushdown automata [ like stack ] , any finite automaton
can be modeled by an infinite automaton , that is to say any table
based machine can also be implemented by a stack based machine as in
principle the stack can grow upto infinite ; but the converse is not
true as the dfa's state space is limited ;
as for perl, im sorry i have only a limited knowledge of the language
, that too from my meagre experience of havbing used it for some cgi
scripts and for some small tools for preprocessing the input for a
simulator ; maybe some one who has more knowledge on this can help ;
i also agree that parsers , and by extension parser generators,
especially antlr] provide a far better and easier to use mechanism for
defining exception conditions and reporting them or recovering from them ;
cheers
ram
--- In antlr-interest at yahoogroups.com, Brian Smith
<brian-l-smith at u...> wrote:
> ANTLR doesn't support really support just any context free grammars. It
> handles predicated LL(k) grammars. Because of the LL(k), it cannot
> handle all context free grammars. Yet, because of the predicates, it
can
> handle some grammars that are not context free, given the proper
> predicates. [Hmm, I wonder, if there is a mechanical transformation of
> LR(k) or GLR grammars to predicated LL(k) grammars?]
>
> Also, Perl doesn't just handle regular grammars because Perl's "regular
> expressions" are really not "regular;" they are much more powerful. It
> is my understanding that in Perl 6, there is even a way to write Perl
> "regular expressions" in an EBNF style that is similar to the style
used
> in parser-generator systems like ANTLR and YACC. I believe that Perl
> also has something analogous to ANTLR's predicates. I would be very
> interested to read a paper that attempts to define the class of
grammars
> that Perl's "regular expressions" can handle.
>
> Personally, I wouldn't use Perl for any situation for which the
input is
> likely to contain syntax errors that I would be required to report on
> (e.g. a compiler). I would generally use Perl for cases where I could
> assume that the input is well-formed, and/or situations where I can
> ignore and easily recover from syntax errors (e.g. log files). But,
> maybe that just evidence of my lack of experience with Perl.
>
> - Brian
>
> sudip mitra wrote:
> > wow ...!!! some explanation ... you think very clearly !!!
> >
> > */"cintyram <cintyram at y...>" <cintyram at y...>/* wrote:
> >
> > well , in principle, antlr supports context free , which is a
super
> > set of regular ;
> > but perl is a programming languge and helps you in doing specific
> > tasks which might be part of your solution, like making it easy to
> > read a file, etc .. also the pattern matching and other r.e
functions
> > are very powerful and sufficient for most common tasks; for
eg: if all
> > you have to do is read links out of a file, or simply search and
> > replace a specific patter with a specific other .. then perl
might be
> > easier to use;
> >
> > on the other hand, if you try writing a system like monty's gcc
> > framework etc. in PERL you will find that it is easier to
think and
> > specify in ebnf ;
> > so the comparison is actually case by case , and one should not
> > generalize ;
> >
> >
> > also with antlr, you generate code to do something, but with
perl you
> > actually formulate the whole solution! and code it!!
> >
> > so your question for the most part wants to compare apples and
oranges.
> > /e
> > cheers
> > ram
> >
> >
> >
> > --- In antlr-interest at yahoogroups.com, "John D. Mitchell"
> > wrote:
> > > Sounds like a troll but what the heck... :-)
> > >
> > > >>>>> "sudip" == sudip mitra writes:
> > > [...]
> > >
> > > > I was wondering how do Perl and Antlr compare . Would
Antlr be a
> > > > superset of Perl ? Or is Perl THE language for text
manipulation ?
> > > > Answers to this question should ignore the learning time
.I just
> > want to
> > > > know if Antlr can do more than Perl even if its a
language blah
> > blah
> > > > ...!!!
> > >
> > > (A) Perl is a general purpose programming language.
> > >
> > > (B) Perl programs for translation work tend very strongly to be
> > based on
> > > ad hoc, simplistic (though often ridiculously complex) use
of regular
> > > expressions.
> > ! >
> > > (C) ANTLR is a grammar-based lexer/parser/walker generator.
> > >
> > > Go wild,
> > > John
> >
> >
> >
> >
> > Your use of Yahoo! Groups is subject to
> > http://docs.yahoo.com/info/terms/
> >
> >
> >
------------------------------------------------------------------------
> > Do you Yahoo!?
> > Yahoo! Mail Plus
> > <http://rd.yahoo.com/mail/mailsig/*http://mailplus.yahoo.com> -
> > Powerful. Affordable. Sign up now
> > <http://rd.yahoo.com/mail/mailsig/*http://mailplus.yahoo.com>
> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
> > <http://docs.yahoo.com/info/terms/>.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list