Hi All,
 Could you please share some advice on the following situation?
 I wrote my first Petit Parser.
 From the documentation I read that:
1) it is possible to depend on other parsers making the development more
modular.
 2) The docs also suggest that, in order to separate grammars rules from
productions, we can make a  parser with productions  a subclass of a parser
which defines the grammar.

I started applying 1) so my structure is something like

  AbstractParser   " contains some common basic elements common to all
subclasses)
       StatementAParser
       StatementBParser
       PLParser  "this guy uses the StatementX parsers"

 So there is a parser for different statements of the programming language.
 The PLParser uses PetitParser dependency mechanism to rely on the
Statement*Parsers.    For instance:
   PLParser>> ruleB
^ (self dependencyAt: StatementBParser)  ruleB


So far so good, the grammar is working, the parser works.

Now, I would like to write the productions, separately from the grammar
part (remember 2) ), so I should make subclasses adding the productions in
the form
  >>ruleA
   ^super ruleA  ===> [ my production code]

The point is that PLParser explicitly depends on Statements*Parser, and the
name of the Statement*Parser appears here and there, so creating subclasses
would result in maintenance nightmare. The new layer of parsers with
productions will duplicate the dependencies and I foresee it will be a mess.

So now, I think that having just one big class with all the rules for the
grammar is better if you plan to separate productions code  isolated from
the grammar.

Am I right? Maybe I'm missing some point regarding writing composed parsers
and separating productions from grammar.

Any pointer or comment is welcome.

Arturo

Reply via email to