IIRC, no.  You could always create an array of ranks indexed by rule
number, though the need to duplicate the information is, I admit, annoying.

On Wed, Aug 8, 2018 at 6:21 PM, Michael Spertus <[email protected]>
wrote:

> Forgot to ask: Is there a way for me to access a rule's rank from within
> its semantic action? That way I could simulate the tree ordering from
> indirect ranks during ASF pruning
>
> Thanks,
> Mike
>
>
> On Wednesday, August 8, 2018 at 2:50:16 PM UTC-7, Michael Spertus wrote:
>>
>> Thanks for the response Jeffrey. That would be awesome. Consider this a
>> vote for early bailing (Earley bailing?) in R3.
>>
>> Mike
>>
>> On Wednesday, August 8, 2018 at 1:40:47 PM UTC-5, Jeffrey Kegler wrote:
>>>
>>> It make *lots* of sense and I've considered it as a feature in R3.  It
>>> will never happen in R2 -- it'd be a massive risky change and R2 is stable.
>>>
>>> Incidentally, a limited implementation of it is how LATM lexing works.
>>> As a special case, I selectively turn on and off predictions in Earley set
>>> 0 of the lexer.
>>>
>>> On Wed, Aug 8, 2018 at 2:31 PM, Michael Spertus <[email protected]>
>>> wrote:
>>>
>>>> Thanks for the link, Amon. As I suspected, it says you should travers
>>>> the ASF in such cases...
>>>>
>>>> In a related question, is there any way for me to reject a rule during
>>>> the read() by listening for a prediction/completion events? A number of my
>>>> rules have conditions on their arguments that are known not to be
>>>> BNF-friendly. I know I can bail from those in a semantic action, but I
>>>> would like to reject before an exponential explosion in the number of
>>>> ambiguous parses. Does that make sense?
>>>>
>>>> Thanks,
>>>>
>>>> Mike
>>>>
>>>>
>>>> On Wednesday, August 8, 2018 at 12:01:24 AM UTC-7, amon wrote:
>>>>
>>>>> Your grammar as written is ambiguous and therefore Marpa gives you all
>>>>> parses in an unspecified order – to see them, iterate over the value
>>>>> like
>>>>>
>>>>> while (my $ref = $recce->value) {
>>>>>     print Dumper $$ref;
>>>>> }
>>>>>
>>>>> Marpa's ranks are a bit unintuitive, I previously ran into very
>>>>> similar problems. This lead to the Marpa::R2::Semantics::Rank
>>>>> document[1] being written (Thanks Jeffrey!). That document shows a
>>>>> related example. The solution seems to be to spell out the sequence
>>>>> rule explicitly:
>>>>>
>>>>> statements ::= xy rank => 1
>>>>> statements ::= x
>>>>> statements ::= y
>>>>> statements ::= statements xy rank => 1
>>>>> statements ::= statements x
>>>>> statements ::= statements y
>>>>>
>>>>> The docs emphasize: “The rank of a parse choice is the rank of the
>>>>> rule of its cause”, which suggests the problem is the intermediate
>>>>> statement rule. If I understand correctly, the "statements ::=
>>>>> statement+" sequence rule has no choices because it always gets a
>>>>> statement at each position (not a choice between x and xy). And the
>>>>> rank within statement does not matter because … I still don't
>>>>> understand this 100%.
>>>>>
>>>>> [1]: https://metacpan.org/pod/release/JKEGL/Marpa-R2-5.043_043/
>>>>> pod/Semantics/Rank.pod
>>>>>
>>>>> On Wed, 8 Aug 2018 at 07:33, Michael Spertus <[email protected]>
>>>>> wrote:
>>>>> >
>>>>> > This time with attachment :/
>>>>> >
>>>>> > On Wednesday, August 8, 2018 at 12:20:39 AM UTC-5, Michael Spertus
>>>>> wrote:
>>>>> >>
>>>>> >> Thanks for helping me to get to a (surprising) answer to my
>>>>> previous question. I was hoping you could help me with another. I want the
>>>>> following grammar to parse 'xy' as a single statement
>>>>> >>
>>>>> >>> statements ::= statement+
>>>>> >>> statement ::= xy | x | y
>>>>> >>> x ::= 'x'
>>>>> >>> y ::= 'y'
>>>>> >>> xy ::= 'x' 'y'
>>>>> >>>
>>>>> >>
>>>>> >> Unfortunately, it always parses as two statements, even if I use
>>>>> the attached "high_rule_only" code and rank the statement alternatives as
>>>>> >>
>>>>> >>>  statement ::= xy rank => 1 | x | y
>>>>> >>
>>>>> >>
>>>>> >> I still get two statements. Is there a way I can do this with
>>>>> ordering, or do I need to do something like traverse the ASF? Note that I
>>>>> need to do this at the ::= level rather than with lexemes because in the
>>>>> actual grammar I care about x and y are complicated rules themselves.
>>>>> >>
>>>>> >> Thanks,
>>>>> >> Mike
>>>>> >>
>>>>> > --
>>>>> > 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.
>>>>>
>>>> --
>>>> 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.
>>>>
>>>
>>> --
> 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.
>

-- 
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