[antlr-interest] [comp.compilers.tools.pccts] Re: Is there a run-time parsing facility

sarkar_soumen sarkar_soumen at yahoo.com
Mon May 12 15:51:56 PDT 2003


I wanted to provide a practical example of "software development
productivity improvement" to those who are questioning "why do
we need grammar to automation translation at runtime".

Suppose I would like to be able single line or multi-line comments
to some temlates that is being processed by legacy software which
can not ignore these comments.

Single Line Example
---------------------
## This is a comment. 
 
Multi Line Example
----------------------------
#*
This is a multiline comment.
This is the second line
*#

Now to add this in the "current way" I need to make a compile time
investment of generating a parser and ignore single/multi-line
comments (i.e gets ALL other TEXT in memory). Had the grammar to
automation translation been possible at runtime I could have
provided a correct grammar file which defines a lexical filter/
channel which passes ALL TEXT except single/multi-line comments.

Once again, it is my view that the absence of dynamic
parsing services is an implementation limitation (i.e one needs
to necessarily go through grammar --> generated parser route). The
purpose of this post is to bring out the defficiency in software
development productivity this approach entails. Please note that
validation of dynamic text via dynamic grammar has been achieved
in XML world (i.e., XML schema vs XML) but the comparsion could be
debated in terms of syntactic theory.

Soumen Sarkar.

--- In antlr-interest at yahoogroups.com, "micheal_jor" 
<open.zone at v...> wrote:
> Hi Soumen,
> 
> > From a dynamic grammar/automation end-user point of view I
> > have the following "use cases":
> > 
> >    1. I am receiving a text string. I just supply a correct
> >       grammar file. The text string passes or fails. If the
> >       text string fails, I get pointer to text string which
> >       fails showing corresponding parser/lexer rule.
> 
> What additional benefit does this provide beyond the generally 
> avaible behavior of raising exceptions?
> 
> >    2. If I supply a wrong grammar file, I get an exception
> >       showing where in grammar file the error occurs.
> 
> Given that run-time systems also have a compile-time capability, 
I'd 
> have thought it was sufficient to simply alert you to the fact 
that 
> there is an error. Grammar file debugging can and should be done 
> interactively *before* the grammar is actually used dynamically.
> 
> >    3. Validation of text string does not cause unbound loop.
> >       Probably max-loop is configurable.
> 
> Depends on (2) above.
> 
> >    4. If I provide grammar rule, I get text fragment for a valid
> >       text string. In other words I retrive text fragments by
> >       parser/lexer rules. For example I say give me the 
substrings
> >       corresponding to SQL DELETE statements.
> 
> Is that just a special use of a pretty-printing TreeParser?
> 
> > Implementation details should be hidden. As I understand a parser
> > generator provides computational service by which a program
> > understands text by systematically breaking it by parser/lexer
> > rules. I just would like to avail this service without any
> > compile time/typing commitment. If I require I am willing to
> > do type commitment in the sense of dynamically using ANTLR types
> > but NO compile time commitment. I do not wish to use any 
generated
> > types (only type commitment is in terms of predefined ANTLR
> > types).
> > 
> > This may be difficult to do. I just wanted to clarify end user
> > requirements on dynamic grammar/automation computational service.
> > 
> > Regarding performance, this kind implementation may be horribly 
slow
> > today but may not be in future.
> 
> Are you planning to build such a dynamic generation framework atop 
> ANTLR Soumen?
> 
> Cheers,
> 
> Micheal


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list