This is the mail archive of the
docbook@lists.oasis-open.org
mailing list for the DocBook project.
RE: [docbook] Using the EBNF module for space-structured languages
- From: "Peter Ring" <PRI at magnus dot dk>
- To: "Ruth Ivimey-Cook" <Ruth dot Ivimey-Cook at ivimey dot org>,"Mauritz Jeanson" <mj at johanneberg dot com>
- Cc: <docbook at lists dot oasis-open dot org>
- Date: Wed, 9 Feb 2005 11:23:39 +0100
- Subject: RE: [docbook] Using the EBNF module for space-structured languages
Have a look at the YAML specification [1]. YAML is a data serialization language that uses whitespace in a fashion similar to what you describe.
The spec are generated from DocBook markup. I suggest that you contact one of the authors [2] to get a copy of the source or to become a member of the YAML project so that you can check it out yourself from CVS. I tried anonymous CVS -- it doesn't work, at least not right now.
[1] http://yaml.org/spec/
[2] http://sourceforge.net/mailarchive/message.php?msg_id=9164910
kind regards
Peter Ring
> -----Original Message-----
> From: Ruth Ivimey-Cook [mailto:Ruth.Ivimey-Cook@ivimey.org]
> Sent: 9. februar 2005 01:35
> To: Mauritz Jeanson
> Cc: 'Ruth Ivimey-Cook'; docbook@lists.oasis-open.org
> Subject: RE: [docbook] Using the EBNF module for space-structured
> languages
>
>
> On Tue, 2005-02-08 at 20:59 +0100, Mauritz Jeanson wrote:
> > > On Mon, 2005-02-07 at 13:45 +0000, Ruth Ivimey-Cook wrote:
> > > > Occam-Pi is a space-structured language, (in the same way
> > > > as Python and occam from which Occam-Pi is derived. How
> can I define
> > > > EBNF grammars for it in DocBook?
> > Or maybe you haven't described the problem clearly enough. Are
> > space-structured languages especially complicated? Is there
> something
> > missing in the DocBook documentation about EBNF
> > (http://docbook.org/tdg/en/html/productionset.html)? (I
> don't know much
> > about grammars and such, I am just curious).
>
> Sorry if I wasn't clear. I'll try again.
>
> What I mean by 'space structured languages' are languages in which the
> layout of the statements (newlines, spaces and so forth) conveys
> information about the context to the compiler. In the C language, for
> example, you could say either:
>
> if(a==b){c=g;printf(e);}
> or
> if (a==b)
> {
> c=g;
> printf(e);
> }
>
> and they mean exactly the same thing. In Occam-Pi, you might write:
>
> IF
> a = b
> SEQ
> c := g
> printf(e)
> TRUE
> SKIP
>
> and you couldn't lay it out any other way: the following code is
> invalid:
>
> IF a = b SEQ
> c := g
> printf(e)
>
> because the condition of an IF must be on a new line, and the SEQ must
> also be on a new line, and even if SEQ were allowed, the indentation
> level of the assignment is wrong.
>
> Now, if I want to describe this sort of language in EBNF, I
> could write:
>
> if-statement := 'IF' newline-indent ( condition newline-indent
> process )+
>
> newline := '\n'
>
> newline-indent := newline increment-level indent-to-current
>
> indent-to-current := ' ' x level # 'level' is current statement
> level
>
> to describe the fact that an IF statement has the sort of structure
> shown above. However, it is very hard to indicate the
> indentation level
> of, say, "process" in the production above - you have to resort to the
> 'tricks' above to do so. Am I making sense here?
>
> In the existing occam books, the authors resorted to a sort of partial
> BNF, in which the layout is presented rather than written. I
> was sort of
> hoping that something of the sort might be reasonably easy in
> DocBook/EBNF.
>
> Is the problem really that I shouldn't be using EBNF at all?
>
> Regards,
>
> Ruth
>
> --
> Ruth Ivimey-Cook <ruth@ivimey.org>
>
>