On Tuesday, 10 February 2015 13:35:31 UTC+11, Thomas Weigert wrote:
>
> Ron,
>
> please see below....
>
> I guess in the end it comes back to what Jeff said earlier. He implied 
> that one cannot simply change the content of the input string.
>

No, you can't change it, but using the Ruby Slippers concept, you can tell 
Marpa to parse another part of the input string, in which you've secreted 
the Ruby Slippers. That's what happens in the sample code I mentioned in my 
email to you. It was MarpaX::Demo::SampleScripts and 
scripts/match.parentheses.02.pl. After that, you reset $pos back to the 
place you want Marpa to continue from.
 

> I guess that maybe somehow the recognizing is happening in the C code and 
> that the input is copied into C space and the position information is 
> maintained between the string I gave Marpa and the actual physical string 
> that sits in C space?
>

Yep.

More below.
 
[snip]

There are 2 courses of action in these situations: 
>>
>> 1: Since you know $pos, use your own - called external - scanner to 
>> process the tokens starting at the one which $start points to (presumably 
>> #), and when finished, set $pos to the end of this substring, and call 
>> resume($pos).
>>
>
> Right, but I need to inject some other text into the input string to be 
> parsed afterwards. 
>
>>
>> 2: Off-the-top-of-my-head: Consider changing the rule 'word ::= W' to 'word 
>> ::= W | fakecpp', so Marpa finds the # without error, and extend the 
>> grammar to handle all things which follow a #. In this case you 
>> deliberately sidetrack Marpa to process #ifdef and then let it (with 
>> resume($pos) ) naturally return to process the next token, here operator.
>>
>
> I think this strategy would be completely infeasible for a real grammar.  
>

Not at all. I do it :-).
 

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