www.digitalmars.com         C & C++   DMDScript  

D - current D grammar

reply "Peter Hercek" <vvp no.post.spam.sk> writes:
Hi all,

where can I find most current D grammar?
It may be a source file or some documentation.
Please, download location and filename.
If the process could be reasonably automated
I would like to put it in an xml format just to test
one xslt I have, which transforms grammar
descriptions to a nice html.
Result would be interesting :) I hope.
I believe result may be available to public then.
I mean: is this allowed from the legal point of
view?

Peter.
Feb 13 2003
parent reply "Walter" <walter digitalmars.com> writes:
"Peter Hercek" <vvp no.post.spam.sk> wrote in message
news:b2hler$64r$1 digitaldaemon.com...
 where can I find most current D grammar?
 It may be a source file or some documentation.

There's both at www.digitalmars.com/d/ Download the compiler, which comes with source for the parser.
 Please, download location and filename.
 If the process could be reasonably automated
 I would like to put it in an xml format just to test
 one xslt I have, which transforms grammar
 descriptions to a nice html.
 Result would be interesting :) I hope.
 I believe result may be available to public then.
 I mean: is this allowed from the legal point of
 view?

Yes.
Feb 14 2003
parent reply "Peter Hercek" <vvp no.post.spam.sk> writes:
Hi Walter,

Thanks for info. Although I was not delighted when I
 found you have completely custom parser implementation.
I wanted to write some small conversion program which
 would select the grammar from sources directly to ensure
 that it is correct and current. I think I would be able to do
 so if you would have used yacc or antlr. I suppose that
 the file parser.c is not generated by some parser generator
 (it was somewhat similar to antlr [http://www.antlr.org/]
 output).
Well, finaly I selected grammar from the web site. I was
 able to automate it only minimaly to get the grammar in a
 text form (see the attached text document). The conversion
 from the text document to the actual html file is automatic.
The grammar has errors: undefined symbols (they apear
 during xml validation); to many top levels (you can see
 them in the resulting html); plus some semantical errors
 probably too. This is mostly because the grammar
 specificiation on the web is not complete and partially
 because of my own errors ... part of  the work was
 manual :(
Please, check the txt file. If you think that there is a way
 to get the text file correct, then the rest is very easy.
 I can provide sw to transform the text file to xml. The
 html form is retrieved using dtd validation and xslt
 transformation. I would be very glad if somebody can
 help me get the text file correct. I would be forced
 to study your custom parser and I do not have enough
 courage for this. One of my reasons to get the D grammar
 correct is to post it to antlr discussion group as example
 - I would like to make them to extend antlr parser
 generator so that it generates the xml file :) I'm not
 successful with this currently :( antlr generates an html
 form of a grammar, but the html file has less features.
The resulting html contains both forward links and also
 backward "multi-links" using popup menus (dhtml). It
 works on win32 IE 6.0 and higher. May be it works
 with something else too, but I never tried so probably
 does not work with different viewers.
Whoever knows, how to make the text file correct, please,
 let me know.


"Walter" <walter digitalmars.com> wrote in message
news:b2idtp$qjf$1 digitaldaemon.com...
 "Peter Hercek" <vvp no.post.spam.sk> wrote in message
 news:b2hler$64r$1 digitaldaemon.com...
 where can I find most current D grammar?
 It may be a source file or some documentation.

There's both at www.digitalmars.com/d/ Download the compiler, which comes with source for the parser.
 Please, download location and filename.
 If the process could be reasonably automated
 I would like to put it in an xml format just to test
 one xslt I have, which transforms grammar
 descriptions to a nice html.
 Result would be interesting :) I hope.
 I believe result may be available to public then.
 I mean: is this allowed from the legal point of
 view?

Yes.

Feb 14 2003
parent reply "Walter" <walter digitalmars.com> writes:
"Peter Hercek" <vvp no.post.spam.sk> wrote in message
news:b2kf62$16mh$1 digitaldaemon.com...
 Thanks for info. Although I was not delighted when I
  found you have completely custom parser implementation.
 I wanted to write some small conversion program which
  would select the grammar from sources directly to ensure
  that it is correct and current. I think I would be able to do
  so if you would have used yacc or antlr. I suppose that
  the file parser.c is not generated by some parser generator
  (it was somewhat similar to antlr [http://www.antlr.org/]
  output).

No, it's all written by hand.
 Well, finaly I selected grammar from the web site. I was
  able to automate it only minimaly to get the grammar in a
  text form (see the attached text document). The conversion
  from the text document to the actual html file is automatic.
 The grammar has errors: undefined symbols (they apear
  during xml validation); to many top levels (you can see
  them in the resulting html); plus some semantical errors
  probably too. This is mostly because the grammar
  specificiation on the web is not complete and partially
  because of my own errors ... part of  the work was
  manual :(

I know the documentation incomplete. But it's nice that you've found a way to automatically find those errors.
 Please, check the txt file. If you think that there is a way
  to get the text file correct, then the rest is very easy.
  I can provide sw to transform the text file to xml. The
  html form is retrieved using dtd validation and xslt
  transformation. I would be very glad if somebody can
  help me get the text file correct. I would be forced
  to study your custom parser and I do not have enough
  courage for this. One of my reasons to get the D grammar
  correct is to post it to antlr discussion group as example

The parser isn't too hard to figure out. It's not LALR(1), some of the constructs require arbitrary lookahead. That's the only tricky part, but that stuff yacc should be able to handle in its sleep.
  - I would like to make them to extend antlr parser
  generator so that it generates the xml file :) I'm not
  successful with this currently :( antlr generates an html
  form of a grammar, but the html file has less features.
 The resulting html contains both forward links and also
  backward "multi-links" using popup menus (dhtml). It
  works on win32 IE 6.0 and higher. May be it works
  with something else too, but I never tried so probably
  does not work with different viewers.
 Whoever knows, how to make the text file correct, please,
  let me know.

ok.
Feb 15 2003
parent reply "Peter Hercek" <vvp no.post.spam.sk> writes:
"Walter" <walter digitalmars.com> wrote in message
news:b2l2oh$1o27$2 digitaldaemon.com...

 I know the documentation incomplete. But it's nice that you've found a way
 to automatically find those errors.

It's quite easy to find easy errors of the grammar itself. I do not have any chance to locate errors in semantics :( I think I could also find some more hiden errors, like grammar conflicts (I can update the xslt so that it generates antlr compliant output and then send the output into antlr - it would find more hidden problems).
 The parser isn't too hard to figure out. It's not LALR(1), some of the
 constructs require arbitrary lookahead. That's the only tricky part, but
 that stuff yacc should be able to handle in its sleep.

Looks, just like LL(k) grammar, which is recognized by antlr (it has also syntactic/semantic predicates to handle situations when arbitrary lookahead is required.
 Whoever knows, how to make the text file correct, please,
  let me know.

ok.

I have added list of undefined symbols (the attached text file). Some of the erros are trivial (like symbol physicalEndOfTheFile should be in backticks, so that it is treated as terminal). Some may represent a missing stuff. I can provide you with tools I used, but they are all in c sharp, so they require net framework installed (it is free). To translate it one needs also a complete antlr instalation (free too), which requires java runtime instalation :( ........ again free, but in summary a lot of installing. Anyway if you have net framework already instaled I can send you only executable files and it would work (well first I should make the programs more user friendly - this would take a while). Or if somebody just sends me the updated text file (the one in my previous post, not the error listing in this post) I can check and fix some trivial errors and return back the results.
Feb 15 2003
parent reply "Walter" <walter digitalmars.com> writes:
"Peter Hercek" <vvp no.post.spam.sk> wrote in message
news:b2luu1$2e59$1 digitaldaemon.com...
 I have added list of undefined symbols (the attached text file). Some of

  erros are trivial (like symbol physicalEndOfTheFile should be in

  so that it is treated as terminal). Some may represent a missing stuff.
 I can provide you with tools I used, but they are all in c sharp, so they
  require net framework installed (it is free). To translate it one needs

  a complete antlr instalation (free too), which requires java runtime
  instalation :( ........ again free, but in summary a lot of installing.
 Anyway if you have net framework already instaled I can send you
  only executable files and it would work (well first I should make the
  programs more user friendly - this would take a while).
 Or if somebody just sends me the updated text file (the one in my previous
  post, not the error listing in this post) I can check and fix some

  errors and return back the results.

I've been trying to avoid the gigantic runtimes for the java and C# vm's. One of the great features of D is none of that is required!
Feb 15 2003
parent "Peter Hercek" <vvp no.post.spam.sk> writes:
"Walter" <walter digitalmars.com> wrote in message
news:b2m52q$2k9d$2 digitaldaemon.com...
 I've been trying to avoid the gigantic runtimes for the java and C# vm's.
 One of the great features of D is none of that is required!

I really do understand this :), also I do not consider it important for PC aplications, I like IL virtual machine and it has also good points. But D has three really good assets against C#: 1) no virtual machine 2) pssibility to manualy alocate 3) no dependence on the "erratic" company It has good chances to get videly adopted (at least I hope - one may need quick startup times or something embedded, small disk usage or backup when MS gets crazy again :) ... whatever). Ok, sorry, I should not continue this thread this way, it is supposed to be about the grammar.
Feb 15 2003