develooper Front page | perl.perl6.language | Postings from March 2009

Grammars that generate stuff

Thread Next
From:
Timothy S. Nelson
Date:
March 27, 2009 23:47
Subject:
Grammars that generate stuff
Message ID:
alpine.LRH.1.10.0903281718480.3283@gwalcmai.nelson.org.au
 	Hi all.  I've been thinking about stringification, forms, and things 
like that.

 	As exegesis 7 points out, sprintf, pack, and the forms language all 
essentially take data and specifies how to turn it into a "string" (I'm using 
"string" loosely here).  Likewise with .perl -- it takes some data, and turns 
it into a string formatted in a particular way.

 	Perl 6 has a general language (grammars) for taking some input and a 
grammar, and separating the data from the formatting, as it were.

 	What's made Perl 6 so much more powerful in this area is the grouping 
of regexen into grammars.

 	I'm wondering if we can't come up with a language that does for output 
formatting what grammars do for input formatting.

 	For example, say we could create something called an 
outputgrammar.  We could do something like this:

grammar	XMLIn {...}
outputgrammar XMLout {...}

 	My thought is that you would then be able to read an XML document 
using the XMLin grammar, do a transform or two, and then rewrite it almost 
identically (except the changes) with the outputgrammar.

 	Ideally, it'd be possible to specify one grammar that would act both 
for parsing output and formatting input.  This may not be possible, but I like 
the idea.

 	It may already be possible to mock up some of these things (a hash 
array of sprintf formats?), but I'd be interested in seeing some discussion on 
what's possible.

 	Of course, if this has already been discussed, I'd love to read about 
it -- please send links.

 	:)


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