On Wed, Apr 29, 2009 at 6:46 PM, R. Bastian <rbastian@free.fr> wrote:
On Wed, 29 Apr 2009 17:55:05 +0200
luigi scarso <luigi.scarso@gmail.com> scribit:

> >
> >
> > May be that ConTeXt is not a 'context free language'  ;-)
> > than it will be difficult to express something in a BNF grammar
> > http://en.wikipedia.org/wiki/Backus-Naur_form.
> >
> hmm.
> Context is a macro package in TeX language which is Turing Complete.
>
>
> > But if (ConTeXt == formal_language), it should be possible to
> > develop TEXT, NUMBER, DIMENSION, REFERENCE, etc
> > and also to add examples for "[optional user data]".
> >
> hmm
> I'm not sure that ConTeXt == TeX (but it seems YES) ,
> I'm nor sure that TeX is a context free language too,
> in the sense that I never see a BNF grammar of TeX .
(chap.24-26 of the Texbook are embryos of a grammar, but they are not usable
like the grammar of Pascal or Python)
> I suspect that TeX is not a cfl .
>
> Anyway,
> lpeg can make the thing easier
>
> --
> luigi
 

I think that something user-friendly could be do in a cooperative wiki (in the between, i found
http://texshow.contextgarden.net/) beginning with

CONTEXT_SOURCE ::= PREAMBLE "\starttext" TEXT "\stoptext" | CONTEXT_SOURCE
TEXT ::= STARTSTOPS | SETUPS | DEFINES | OTHERS [ TEXT

and so on.
Consider that one can always make some dirty tricks in PREAMBLE to render useless 
"\starttext"
or "\stoptext"

To be general, i think
MY_CONTEXT_SOURCE ::= MACRO* END

For example , let's try
$>context test
where
test.tex ::="\end"
or
test.tex ::="FOO\end"

Are there any errors ? No
Is test.tex  in {CONTEXT_SOURCE } ? No
Is test.tex in {MY_CONTEXT_SOURCE} Yes
so MY_CONTEXT_SOURCE includes CONTEXT_SOURCE
(of course
test.tex ::="\end""\starttext""\stoptext" is also in {CONTEXT_SOURCE }
)

I think that a bnf or lpeg grammar is really useful for a sort of standard-ConTeXt
or minimal-ConTeXt or light-ConTeXt
ie a ConTeXt to use as "reference"
but can be a bit hard to define

--
luigi