Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^5: Writing a Programming Language in Perl

by Jeffrey Kegler (Hermit)
on Nov 14, 2011 at 17:28 UTC ( #937994=note: print w/replies, xml ) Need Help??

in reply to Re^4: Writing a Programming Language in Perl
in thread Writing a Programming Language in Perl

Marpa will handle both left- and right-recursion in linear time. Marpa would accept directly all three of the grammars that you describe. The left- and right-recursive grammars would be parsed in linear time. The one which is both left and right-recursive is ambiguous, and so might be non-linear.

Marpa parses only context-free grammars, so its core algorithm does not handle context. But neither does PRD's core algorithm, which is LL and considerably less powerful than Marpa's. Both Marpa and PRD use "add-on" features to allow context sensitivity.

When it comes to extensions like context-sensitivity, PRD has the advantage of being based on recursive descent, which modern programmers find intuitive, and which has a very long track record. Marpa also has features which allow context-sensitivity. For the most general case, you can take the context-free subset of the grammar, produce an ambiguous parse, and then using ranking and/or selection. A more targeted approach could use Marpa's ability to track the progress of the parse token-by-token, and alter the input based on what it sees.

Marpa's underlying algorithm is highly mathematical and far from intuitive. But this comes with a compensating advantage -- Marpa can and has been converted to C, in which form it is over 20 times as fast. Recursive descent's advantages come from easy customization, making C conversion difficult or impractical.

So for context-sensitivity, it's a matter of different strategies. My own highly biased opinion is that many applications will find Marpa an advance over recursive descent.

  • Comment on Re^5: Writing a Programming Language in Perl

Replies are listed 'Best First'.
Re^6: Writing a Programming Language in Perl
by ikegami (Pope) on Nov 14, 2011 at 20:13 UTC

    I'm not sure why you're replying with a comparison between Marpa and PRD. I didn't advocate or even talk about PRD.

    The relevant part of your reply is that Marpa does provide the special tools to handle associativity or context in general. An example would be nice.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://937994]
[Discipulus]: you are almoste there..retry ;=)
[Tux]: Hmm, that must be something in pm_cb_g
[Tux]: in the dialog area it shows correct, but the url is broken in the CB
[Discipulus]: you still need to put href:// , no?
[Tux]: [htps://metacpan. org/source/ MLEHMANN/Canary- Stability-2012/| this] is the same link posted on the PM side inside the CB
[Discipulus]: and you wrote ttps and then htps
[Tux]: new try
[Tux]: \o/ (sorry for the noise)
[Discipulus]: anyway, i'm more interested about the general idea: you (and others) do not install modules by this guy. Rigth?
[Tux]: correct

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2017-09-20 07:26 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (234 votes). Check out past polls.