On Wed, Mar 15, 2017 at 9:42 PM, Daniel Blanch <
[email protected]> wrote:

>
> Much clearer now, thanks a lot.
>
> El martes, 14 de marzo de 2017, 16:29:39 (UTC+1), Jeffrey Kegler escribió:
>>
>> "Bless" versus actions is just a TIMTOWTDI feature.  I found bless less
>> useful, to the extent I considered removing it in the forthcoming R3
>> Marpa.  But it has its fans.
>>
>> If how bless works doesn't leap out at you, stick with actions -- they're
>> all I use.  You can learn how to use bless later -- or never.
>>
>> The actions can generate an AST, or do all of the semantics immediately.
>> In fact you can generate an AST just using a default action:
>>
>> :default ::= action => [name, values]
>>
>
> This, with this:
>
>  $Data::Dumper::Deepcopy = 1; # prints all node names
>
> Helped me to understand better what marpa does.
>
>
>>
>> This separates the parsing from the semantics, so it's easier to
>> visualize what's going on.  Particularly for your first Marpa project, it's
>> often best to start with an AST.
>>
>> The AST method is also quite powerful and, in terms of speed, reasonable,
>> so that you may wind up sticking with it as your final way of doing things.
>>
>
> what if i want to implement a visitor pattern, isn't it what bless method
> is for?
>
IMHO, yes, or the interpreter pattern, as is semantics_package
<https://metacpan.org/pod/distribution/Marpa-R2/pod/Scanless/R.pod#semantics_package>
option
of the recognizer

BTW, I once wrote a helper module to work with Marpa::R2 ASTs
<https://github.com/rns/MarpaX-AST> and had my share of infatuation with
visitor <https://github.com/rns/MarpaX-AST/search?utf8=%E2%9C%93&q=visitor>
and interpreter
<https://github.com/rns/MarpaX-AST/search?utf8=%E2%9C%93&q=interpreter>
patterns that, unfortunately, I had not time and/or focus to release or
maintain. Perhaps you’ll find it interesting and/or useful.


>
>> On Tue, Mar 14, 2017 at 8:08 AM, Daniel Blanch <[email protected]>
>> wrote:
>>
>>> Hi, I keep trying to understand the semantics of marpa. Forgive me if my
>>> questions are too basic.
>>>
>>> I've read the documentation, in particular this
>>> http://search.cpan.org/~jkegl/Marpa-R2-3.000000/pod/Semantics.pod.
>>>
>>> I've noticed that instead of using actions, it uses bless. I'm not sure
>>> if I have understand the reason well enough. What I understand is the
>>> following.
>>>
>>> 1) Marpa's bless, creates objects initializing it with the parse result
>>> of the rule instance
>>> 2) If the result of other subrules is blessed too, the parent rule will
>>> get a reference to the subrules blessed objects.
>>> 3) Doing so provides a somehow 'Semantic tree'
>>> 4) After parsing I'll get a reference of the root node i can use to
>>> traverse the whole tree and get the result this way.
>>>
>>> I'm I right?
>>>
>>> So, what's the difference with actions? Is it that with actions the
>>> result is computed on the fly? do actions use an AST then or do the parse
>>> and the result in just one step.
>>>
>>> What's the recomended way of using marpa to translate a language, bless
>>> adverb or action adverb?
>>>
>>> Than you very much in advance.
>>>
>>>
>>>
>>>
>>>
>>> On Monday, March 13, 2017 at 2:59:35 PM UTC+1, Daniel Blanch wrote:
>>>>
>>>> Hi Marpers,
>>>>
>>>> I've been using Marpa for a while, it seems promising, but I find it
>>>> difficult to understand how default actions and custom actions work
>>>> together when trying to get a result. Where can I find a tutorial or
>>>> documentation to understand it? How did you learn Marpa? Documentation is a
>>>> bit confusing.
>>>>
>>>> Thank you very much in advance.
>>>>
>>>> Regards.
>>>>
>>>> Daniel.
>>>>
>>> --
>>> 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