Re: Grammars that generate stuff

2009-03-28 Thread Matthew Wilson
On Sat, Mar 28, 2009 at 1:48 AM, Timothy S. Nelson wrote:

>Perl 6 has a general language (grammars) for taking some input and a
> grammar, and separating the data from the formatting, as it were.
>
>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.
>

Tim,

Regarding generative/transforming grammars, you may get some good
syntax/architecture ideas from the OMeta language system see
http://www.tinlizzie.org/ometa-js/#Sample_Project for a selection of
browser-based examples... (it's also the subversion repo).  Also if you
don't mind things Microsoft, there's the (part of Oslo) M language family.

-Matthew


Grammars that generate stuff

2009-03-27 Thread Timothy S. Nelson
	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: wayl...@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-