On Sat, Jun 05, 2010 at 09:19:01AM +1000, Timothy S. Nelson wrote:
>       Hi.  I've been thinking more about reversible grammars.  Specifically,  
> I'm wondering if the following pseudo-code will be possible:
> ## Match a grammar here
> $match = Grammar.match($text)
> ## Need some code here to get $submatch from $match
> ....
> $submatch.Str = "fred"
> ## Reverse Grammar
> $text = Grammar.reverse($match)
>       My idea is that I could read in a file, find the part I wanted in the  
> match tree, change that part, and then write it back to the file.  Is 
> that going to be a possibility?

Look at emit_p5 in viv, where we do basically exactly that (but combined with
a recursive traversal).

>       Also, while I was trying to investigate this, I was wondering about  
> S32/Rules.  I've added a few more lines to it, but there are some things 
> I'm having trouble figuring out (this may be due to a few months absence 
> from the p6 community -- sorry :) ).  Anyway, my questions are:

Higher-numbered synopses are much more speculative, poorly implemented, and
get little love from the janitorial staff; so, in case of disagreement, the
lower number has the correct answer.

> -     I note that, while S32/Rules says that .from returns an Int, S05 has a
>       call $/.from.bytes .  Does this mean that there's a StringSize type

S32 is wrong.

>       that does maybe .bytes, .chars, .graphs, and .codes that's returned by
>       maybe .from, .to, and .pos ?

Yes, it's called StrPos; see S02:813.

> -     I've also noticed that there's a .chars method on the match object;
>       wouldn't this exist by default because of the Str method?


Attachment: signature.asc
Description: Digital signature

Reply via email to