develooper Front page | perl.perl6.language | Postings from June 2010

Reversible grammars

Thread Next
From:
Timothy S. Nelson
Date:
June 4, 2010 16:46
Subject:
Reversible grammars
Message ID:
alpine.LRH.2.00.1006050842330.22232@gwalchavad.nelson.org.au
 	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?

 	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:
-	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
 	that does maybe .bytes, .chars, .graphs, and .codes that's returned by
 	maybe .from, .to, and .pos ?
-	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?

 	HTH, :)


---------------------------------------------------------------------
| Name: Tim Nelson                 | Because the Creator is,        |
| E-mail: wayland@wayland.id.au    | I am                           |
---------------------------------------------------------------------

----BEGIN GEEK CODE BLOCK----
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- 
PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y-
-----END GEEK CODE BLOCK-----


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About