OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

docbook message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

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)

and they mean exactly the same thing. In Occam-Pi,  you might write:

      a = b
          c := g

and you couldn't lay it out any other way: the following code is

    IF a = b SEQ
      c := g

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

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

Is the problem really that I shouldn't  be using EBNF at all?



Ruth Ivimey-Cook <ruth@ivimey.org>

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]