digitalmars.D - BNF grammar for D?
- Thomas Koch (12/12) Oct 12 2012 Hi,
- Aziz K. (12/12) Oct 12 2012 Hi,
- Russel Winder (21/38) Oct 12 2012 =20
- Paulo Pinto (6/37) Oct 12 2012 My grammar knowledge is a bit rusty, but isn't EBNF only possible
- Russel Winder (17/21) Oct 12 2012 Mentioning EBNF turns out to be a red herring. Indeed mention of BNF is
- Nick Sabalausky (6/21) Oct 12 2012 I'm pretty sure a correct D grammar is impossible in LALR(1), unless
- Manfred Nowak (6/7) Oct 13 2012 "a^n b^n c^n" is not LALR(1). But "a^n b^n c^m" is---if n and m are not
- Mehrdad (1/1) Oct 12 2012 http://www.dsource.org/projects/visuald/wiki/GrammarComparison
- Rainer Schuetze (4/5) Oct 13 2012 I haven't tried it for some time, but you can generate the text files
Hi, cedet is a collection of emacs dev tools. I understand that it should be relatively easy to enhance the emacs support of D if one just provides cedet with a BNF grammar in a Bison like format, I cite: " You should choose to use the Semantic lexer/grammer format for your language if it has a deterministic grammar. Often times you can download a pre- existing BNF grammar for a language. These BNF grammars can be converted to Wisent grammar format fairly easily. " Is there anything that could be easily translated? Regards, Thomas Koch
Oct 12 2012
Hi, I can give you three options to choose from. There's the official grammar (don't know what the form is called): http://dlang.org/declaration.html A Parser Expression Grammar (PEG): https://github.com/PhilippeSigaud/Pegged/blob/master/pegged/examples/dparser.d The source code comments in my project using a pseudo-BNF format. They shouldn't be too hard to decipher, but keep in mind that they're not 100% complete and exact: http://dl.dropbox.com/u/17101773/next/2/dil/doc/dil.parser.Parser.html#Parser.parseModuleDecl -- My D Compiler: http://code.google.com/p/dil
Oct 12 2012
On Fri, 2012-10-12 at 15:11 +0200, Aziz K. wrote:Hi, =20 I can give you three options to choose from. =20 There's the official grammar (don't know what the form is called): =20 http://dlang.org/declaration.html =20 A Parser Expression Grammar (PEG): =20 https://github.com/PhilippeSigaud/Pegged/blob/master/pegged/examples/dpar=ser.d=20 The source code comments in my project using a pseudo-BNF format. They ==20shouldn't be too hard to decipher, but keep in mind that they're not 100%==20complete and exact: =20 http://dl.dropbox.com/u/17101773/next/2/dil/doc/dil.parser.Parser.html#Pa=rser.parseModuleDecl I think the official grammar rules in, let's call it K&R grammar, is the only choice here. Rather than scrape from the website is there a file in the Git repository with this grammar rule set? If so then a small program in say, Python ;-), would give a EBNF grammar representation fairly straightforwardly =E2=80=93 read grammar ruleset, construct tree representing the ruleset, run visitor over tree to generate EBNF. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Oct 12 2012
On Friday, 12 October 2012 at 14:41:12 UTC, Russel Winder wrote:On Fri, 2012-10-12 at 15:11 +0200, Aziz K. wrote:My grammar knowledge is a bit rusty, but isn't EBNF only possible for LR(K) languages? Is is possible for D? -- PauloHi, I can give you three options to choose from. There's the official grammar (don't know what the form is called): http://dlang.org/declaration.html A Parser Expression Grammar (PEG): https://github.com/PhilippeSigaud/Pegged/blob/master/pegged/examples/dparser.d The source code comments in my project using a pseudo-BNF format. They shouldn't be too hard to decipher, but keep in mind that they're not 100% complete and exact: http://dl.dropbox.com/u/17101773/next/2/dil/doc/dil.parser.Parser.html#Parser.parseModuleDeclI think the official grammar rules in, let's call it K&R grammar, is the only choice here. Rather than scrape from the website is there a file in the Git repository with this grammar rule set? If so then a small program in say, Python ;-), would give a EBNF grammar representation fairly straightforwardly – read grammar ruleset, construct tree representing the ruleset, run visitor over tree to generate EBNF.
Oct 12 2012
On Fri, 2012-10-12 at 16:59 +0200, Paulo Pinto wrote: [=E2=80=A6]=20 My grammar knowledge is a bit rusty, but isn't EBNF only possible=20 for LR(K) languages?Mentioning EBNF turns out to be a red herring. Indeed mention of BNF is a red herring also. What is actually needed is a Wisent grammar file. Wisent is Bison. Bison is YACC. So we are looking for an LALR(1) grammar.Is is possible for D?Pass. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Oct 12 2012
On Fri, 12 Oct 2012 16:16:10 +0100 Russel Winder <russel winder.org.uk> wrote:On Fri, 2012-10-12 at 16:59 +0200, Paulo Pinto wrote: [=E2=80=A6]I'm pretty sure a correct D grammar is impossible in LALR(1), unless maybe there's a way to manually resolve shift-reduce/reduce-reduce conflicts. You might be able to get close, though. LALR(k) or GLR might be possible.=20 My grammar knowledge is a bit rusty, but isn't EBNF only possible=20 for LR(K) languages?=20 Mentioning EBNF turns out to be a red herring. Indeed mention of BNF is a red herring also. What is actually needed is a Wisent grammar file. Wisent is Bison. Bison is YACC. So we are looking for an LALR(1) grammar. =20Is is possible for D?=20 Pass. =20
Oct 12 2012
Nick Sabalausky wrote:I'm pretty sure a correct D grammar is impossible in LALR(1)"a^n b^n c^n" is not LALR(1). But "a^n b^n c^m" is---if n and m are not dependent. I.e.: without specifying the restrictions for the allowed semantic checks there is no sureness for impossibilities. -manfred
Oct 13 2012
http://www.dsource.org/projects/visuald/wiki/GrammarComparison
Oct 12 2012
On 10/13/2012 8:02 AM, Mehrdad wrote:http://www.dsource.org/projects/visuald/wiki/GrammarComparisonI haven't tried it for some time, but you can generate the text files from the current documentation with the script in http://www.dsource.org/projects/visuald/browser/grammar
Oct 13 2012