A question: Are you using Longest Acceptable Tokens Matching?

lexeme default=  latm=>  1

Users almost always want LATM.  It often eliminates annoying ambiguities.

My guess is that the "||" is *not* going to help in this case. In Marpa, it separates priority levels, as in the priorities of arithmetic operations. It is *not* a logical OR. The "||" is a very handy notation for indicating priority levels, but it is perhaps misleading in this context.

You may want to look at lexeme priorities: http://search.cpan.org/~jkegl/Marpa-R2-2.084000/pod/Scanless/DSL.pod#priority -- in particular, giving your <Error> priority a lower priority than all other lexemes is the approach I would look at.

These are guesses based on your outline of the problem. It looks like a very interesting grammar and application. Let us know how they work out,

-- Jeffrey


On 04/29/2014 07:47 AM, [email protected] wrote:
Hello,

I can extract from some data structures a set of grammar rules that looks like:
topLevelRule1 ::= rule1 rule2 rule3
topLevelRule2 ::= rule2
rule1 ::= rule11 rule12
rule11 ~ token11
rule12~ token12
rule2 ~ token2
rule3 ~ token3

.... and so on (any kind of nested structures of this kind are to be expected),
and I would like to create a Marpa grammar from this to
parse against some MathML stuff ( and replace subtrees according to it.)

Now the input is not completely described by the grammar, so I would want to
use some kind of structure like:
Script ::= Notation (top level rule -> that is what I am going to replace)
      || Presentation (other MathML not described by my grammar)
|| Content (stuff that was already replaced on a previous run or by any other means)
      || Error (anything)

The problem is that the top level rules have precedence that has to be taken into
account.

-> I have tried using || to implement that, but found out that its action
is not deterministic and hence useless for my purpose.

-> I have also tried to use ranking_method in order to implement this,
but it just doesn't work out.

So, my question is as follows - if I have a (potentially large) set of alternative rules with certain precedence, how do I define a grammar like that ( also taking into account the possibility of ambiguous parses) - so that I can use the "event" adverb
to actually perform some substitutions.

To make it clearer - I would be happy enough even if I only got an answer to how the following should be implemented so that the alternative "|| Other action => do_printErr" is ONLY
executed if the first alternative failed.

:start ::= Script
Script ::= Number ',' Number action => do_printNr
          || Other action => do_printErr
Other ::= Error
Error ~ [\s\S]*

Number ~ digits
digits ~ [\d]+

Thank you in advance for help,
Toloaca Ion


--
You received this message because you are subscribed to the Google Groups "marpa parser" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "marpa 
parser" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to