comp.lang.ada
 help / color / mirror / Atom feed
* Ada 2012 grammar
@ 2013-10-24 15:01 David Pereira
  2013-10-24 16:49 ` G.B.
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: David Pereira @ 2013-10-24 15:01 UTC (permalink / raw)


Hi all,

Does anyone know if there is available a complete grammar for Ada 2012, lets say, in Flex+Bison or similar compiler construction tool-chain? 

I would like to extend it to some new contract constructs, but writing a complete parser is a huge (and extremely time-consuming) task that I would like to avoid :).

Thanks in advance,
David

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada 2012 grammar
  2013-10-24 15:01 Ada 2012 grammar David Pereira
@ 2013-10-24 16:49 ` G.B.
  2013-10-24 21:11   ` David Pereira
  2013-10-24 16:55 ` Dan'l Miller
  2013-10-24 20:19 ` Dmitry A. Kazakov
  2 siblings, 1 reply; 11+ messages in thread
From: G.B. @ 2013-10-24 16:49 UTC (permalink / raw)


On 24.10.13 17:01, David Pereira wrote:
> Hi all,
>
> Does anyone know if there is available a complete grammar for Ada 2012, lets say, in Flex+Bison or similar compiler construction tool-chain?
>
> I would like to extend it to some new contract constructs, but writing a complete parser is a huge (and extremely time-consuming) task that I would like to avoid :).

The latest Emacs Ada Mode (5.00) has a Wisent style grammar
for Ada 2012. "Copyright (C) 2012 Free Software Foundation, Inc."
It could be usable after editing it a little.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada 2012 grammar
  2013-10-24 15:01 Ada 2012 grammar David Pereira
  2013-10-24 16:49 ` G.B.
@ 2013-10-24 16:55 ` Dan'l Miller
  2013-10-24 17:05   ` Marc C
  2013-10-24 21:12   ` David Pereira
  2013-10-24 20:19 ` Dmitry A. Kazakov
  2 siblings, 2 replies; 11+ messages in thread
From: Dan'l Miller @ 2013-10-24 16:55 UTC (permalink / raw)


On Thursday, October 24, 2013 10:01:13 AM UTC-5, David Pereira wrote:
> Hi all,
> Does anyone know if there is available a complete grammar for Ada 2012, lets say, in Flex+Bison or similar compiler construction tool-chain? 

Why not base your tool on ASIS?  What semantic or syntactic information/analysis does your tool need that the Ada2012 parsing in ASIS in GNAT is impractical for?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada 2012 grammar
  2013-10-24 16:55 ` Dan'l Miller
@ 2013-10-24 17:05   ` Marc C
  2013-10-24 21:12   ` David Pereira
  1 sibling, 0 replies; 11+ messages in thread
From: Marc C @ 2013-10-24 17:05 UTC (permalink / raw)


On Thursday, October 24, 2013 11:55:00 AM UTC-5, Dan'l Miller wrote:

> Why not base your tool on ASIS?  What semantic or syntactic information/analysis does your tool need that the Ada2012 parsing in ASIS in GNAT is impractical for?

If I understand the original post, he's looking to extend the language with additional contract-oriented language constructs, not analyze programs.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada 2012 grammar
  2013-10-24 15:01 Ada 2012 grammar David Pereira
  2013-10-24 16:49 ` G.B.
  2013-10-24 16:55 ` Dan'l Miller
@ 2013-10-24 20:19 ` Dmitry A. Kazakov
  2013-10-24 22:29   ` David Pereira
  2 siblings, 1 reply; 11+ messages in thread
From: Dmitry A. Kazakov @ 2013-10-24 20:19 UTC (permalink / raw)


On Thu, 24 Oct 2013 08:01:13 -0700 (PDT), David Pereira wrote:

> I would like to extend it to some new contract constructs, but writing a
> complete parser is a huge (and extremely time-consuming) task that I would
> like to avoid :).

Difficult for parsing are only expressions. The language itself is very
simple to parse using recursive descent parser, e.g. to generate an AST. To
write a table-driven parse would be one-day work or so.

Ada expressions parser can be found here:

http://www.dmitry-kazakov.de/ada/components.htm#12.9

However it is Ada 95. The difference AFAIK to Ada 2005 is reserved words
like "interface" to filter out from identifiers. To Ada 2012 it is
conditional expressions. Not difficult to add.

I would not bother either with grammars.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada 2012 grammar
  2013-10-24 16:49 ` G.B.
@ 2013-10-24 21:11   ` David Pereira
  2013-10-26  2:07     ` Stephen Leake
  0 siblings, 1 reply; 11+ messages in thread
From: David Pereira @ 2013-10-24 21:11 UTC (permalink / raw)


Quinta-feira, 24 de Outubro de 2013 17:49:17 UTC+1, G.B. escreveu:
> On 24.10.13 17:01, David Pereira wrote:
> 
> > Hi all,
> 
> >
> 
> > Does anyone know if there is available a complete grammar for Ada 2012, lets say, in Flex+Bison or similar compiler construction tool-chain?
> 
> >
> 
> > I would like to extend it to some new contract constructs, but writing a complete parser is a huge (and extremely time-consuming) task that I would like to avoid :).
> 
> 
> 
> The latest Emacs Ada Mode (5.00) has a Wisent style grammar
> 
> for Ada 2012. "Copyright (C) 2012 Free Software Foundation, Inc."
> 
> It could be usable after editing it a little.

Dear G.B,

Very nice hint! I am a Emacs user, but didn't occurred that to me (shame on me :p). 

Thanks,
David



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada 2012 grammar
  2013-10-24 16:55 ` Dan'l Miller
  2013-10-24 17:05   ` Marc C
@ 2013-10-24 21:12   ` David Pereira
  1 sibling, 0 replies; 11+ messages in thread
From: David Pereira @ 2013-10-24 21:12 UTC (permalink / raw)


Quinta-feira, 24 de Outubro de 2013 17:55:00 UTC+1, Dan'l Miller escreveu:
> On Thursday, October 24, 2013 10:01:13 AM UTC-5, David Pereira wrote:
> 
> > Hi all,
> 
> > Does anyone know if there is available a complete grammar for Ada 2012, lets say, in Flex+Bison or similar compiler construction tool-chain? 
> 
> 
> 
> Why not base your tool on ASIS?  What semantic or syntactic information/analysis does your tool need that the Ada2012 parsing in ASIS in GNAT is impractical for?

Hi,
The reason is exactly the one put forward by Marc: I am looking for something done for the current grammar of Ada 2012, so that I can easily extend it to further contract constructions.

Thanks anyway :)

Regards,
David


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada 2012 grammar
  2013-10-24 20:19 ` Dmitry A. Kazakov
@ 2013-10-24 22:29   ` David Pereira
  0 siblings, 0 replies; 11+ messages in thread
From: David Pereira @ 2013-10-24 22:29 UTC (permalink / raw)


Quinta-feira, 24 de Outubro de 2013 21:19:28 UTC+1, Dmitry A. Kazakov escreveu:
> On Thu, 24 Oct 2013 08:01:13 -0700 (PDT), David Pereira wrote:
> 
> 
> 
> > I would like to extend it to some new contract constructs, but writing a
> 
> > complete parser is a huge (and extremely time-consuming) task that I would
> 
> > like to avoid :).
> 
> 
> 
> Difficult for parsing are only expressions. The language itself is very
> 
> simple to parse using recursive descent parser, e.g. to generate an AST. To
> 
> write a table-driven parse would be one-day work or so.
> 
> 
> 
> Ada expressions parser can be found here:
> 
> 
> 
> http://www.dmitry-kazakov.de/ada/components.htm#12.9
> 
> 
> 
> However it is Ada 95. The difference AFAIK to Ada 2005 is reserved words
> 
> like "interface" to filter out from identifiers. To Ada 2012 it is
> 
> conditional expressions. Not difficult to add.
> 
> 
> 
> I would not bother either with grammars.
> 
> 
> 
> -- 
> 
> Regards,
> 
> Dmitry A. Kazakov
> 
> http://www.dmitry-kazakov.de

Hi Dmitry,
Thanks for the pointer. I will carefully look at it.

Regards,
David


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada 2012 grammar
  2013-10-24 21:11   ` David Pereira
@ 2013-10-26  2:07     ` Stephen Leake
  2013-10-26  5:57       ` Shark8
  0 siblings, 1 reply; 11+ messages in thread
From: Stephen Leake @ 2013-10-26  2:07 UTC (permalink / raw)


David Pereira <dmrpereira@gmail.com> writes:

> Quinta-feira, 24 de Outubro de 2013 17:49:17 UTC+1, G.B. escreveu:
>> On 24.10.13 17:01, David Pereira wrote:
>> 
>> > Does anyone know if there is available a complete grammar for Ada
>> > 2012, lets say, in Flex+Bison or similar compiler construction
>> > tool-chain?
>> 
>> The latest Emacs Ada Mode (5.00) has a Wisent style grammar
>> 
>> for Ada 2012. "Copyright (C) 2012 Free Software Foundation, Inc."
>> 
>> It could be usable after editing it a little.
>
> Dear G.B,
>
> Very nice hint! I am a Emacs user, but didn't occurred that to me
> (shame on me :p). 

It is very new.

Website: http://stephe-leake.org/emacs/ada-mode/emacs-ada-mode.html

The grammar there has conflicts, so it relies on a generalized LALR
parser (http://en.wikipedia.org/wiki/Generalized_LR_parser), which I
implemented in Emacs lisp.

The grammar file can be parsed by a new OpenToken feature, and it will
generate either Ada OpenToken source code, or Emacs lisp for a parser
table; that version of OpenToken is available on the Ada mode website
(not the OpenToken website http://stephe-leake.org/ada/opentoken.html).

However, OpenToken only has a (non-generalized) LALR parser. It would be
interesting to implement a generalized parser for Opentoken; let me know
if you'd like to use that and/or help implement it.

It might not be too hard to eliminate the conflicts so you can use the
OpenToken parser (or some other parser); I did not do that because it
seemed easier (not to say way more fun) to implement the parser :). In
addition, the grammar source is closer to the Ada LRM Annex P this way.

I've improved Ada mode a bit since the last post on the website; it's
quite usable now. The latest is in monotone; see the Ada mode website
for access info. It is time to post another release; maybe this weekend.

Also note that I fixed several bugs in OpenToken, so if it was not
working for you before, you should try it again.

-- 
-- Stephe


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada 2012 grammar
  2013-10-26  2:07     ` Stephen Leake
@ 2013-10-26  5:57       ` Shark8
  2013-11-11 14:55         ` Stephen Leake
  0 siblings, 1 reply; 11+ messages in thread
From: Shark8 @ 2013-10-26  5:57 UTC (permalink / raw)


On Friday, October 25, 2013 8:07:04 PM UTC-6, Stephen Leake wrote:
> 
> It is very new.
> Website: http://stephe-leake.org/emacs/ada-mode/emacs-ada-mode.html

Nice; I'll have to check it out.

> The grammar there has conflicts, so it relies on a generalized LALR
> parser (http://en.wikipedia.org/wiki/Generalized_LR_parser), which I
> implemented in Emacs lisp.
> 
> The grammar file can be parsed by a new OpenToken feature, and it will
> generate either Ada OpenToken source code, or Emacs lisp for a parser
> table; that version of OpenToken is available on the Ada mode website

Nice to see that OpenToken is getting updated.
I've been kicking around the idea of writing an Ada compiler in Delphi* (it's "in a box sitting in the corner gathering dust" metaphorically speaking), which might be nice to bootstrap a self-hosted compiler. (Plus I'd like to see if the [InterBase] DB would be suitable for implementing source-/library-control.)

* I've got 2007 (the last one to have Delphi for Dotnet), the new version can apparently natively target Macs though.

> (not the OpenToken website http://stephe-leake.org/ada/opentoken.html).
> 
> However, OpenToken only has a (non-generalized) LALR parser. It would be
> interesting to implement a generalized parser for Opentoken; let me know
> if you'd like to use that and/or help implement it.

That sounds pretty cool to me.

> It might not be too hard to eliminate the conflicts so you can use the
> OpenToken parser (or some other parser); I did not do that because it
> seemed easier (not to say way more fun) to implement the parser :).


> In addition, the grammar source is closer to the Ada LRM Annex P this way.

Nice.

> Also note that I fixed several bugs in OpenToken, so if it was not
> working for you before, you should try it again.

Version 4.0b 29 Jun 2010?


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Ada 2012 grammar
  2013-10-26  5:57       ` Shark8
@ 2013-11-11 14:55         ` Stephen Leake
  0 siblings, 0 replies; 11+ messages in thread
From: Stephen Leake @ 2013-11-11 14:55 UTC (permalink / raw)


Shark8 <onewingedshark@gmail.com> writes:

> On Friday, October 25, 2013 8:07:04 PM UTC-6, Stephen Leake wrote:
>> Also note that I fixed several bugs in OpenToken, so if it was not
>> working for you before, you should try it again.
>
> Version 4.0b 29 Jun 2010?

That's the "current stable release" version at the OpenToken website
http://stephe-leake.org/ada/opentoken.html, and also in Debian
distributions. 

The experimental, alpha release version that supports creating a parse
table for a generalized parser is at
http://stephe-leake.org/emacs/ada-mode/emacs-ada-mode.html

-- 
-- Stephe

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-11-11 14:55 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-24 15:01 Ada 2012 grammar David Pereira
2013-10-24 16:49 ` G.B.
2013-10-24 21:11   ` David Pereira
2013-10-26  2:07     ` Stephen Leake
2013-10-26  5:57       ` Shark8
2013-11-11 14:55         ` Stephen Leake
2013-10-24 16:55 ` Dan'l Miller
2013-10-24 17:05   ` Marc C
2013-10-24 21:12   ` David Pereira
2013-10-24 20:19 ` Dmitry A. Kazakov
2013-10-24 22:29   ` David Pereira

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox