comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Parsing Ada?
Date: Wed, 3 Jun 2015 17:39:40 -0500
Date: 2015-06-03T17:39:40-05:00	[thread overview]
Message-ID: <mknvnd$j0k$1@loke.gir.dk> (raw)
In-Reply-To: 7cpxfz18lg2r$.ymcopru7qn8x.dlg@40tude.net

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:7cpxfz18lg2r$.ymcopru7qn8x.dlg@40tude.net...
> On Tue, 02 Jun 2015 13:33:07 +0200, Jacob Sparre Andersen wrote:
>
>> I would prefer to compile the grammar to Ada source text,
>> which I then could compile into the program.
>
> That is the core of the problem, then. Why would you do such thing? To
> parse Ada you only need a recursive descent parser which is a couple of
> hours to write.

There's a lot more to the equation than a parse, though. And if you can 
write a correct recursive descent parser for all of Ada in a "couple of 
hours", you're a genius *and* can type at an inhuman rate. It took me more 
than 80 hours to just add the Ada 2012 changes to our existing grammar (a 
lot of that time was keeping the existing stuff from breaking, of course; 
aspect specifications were particularly bad that way, because they are added 
on the right and thus all of the parse stack offsets changed when they were 
added).

One thing is if the target is small (not sure why it would be in this case, 
but anyway), a table-driven parser can be many times smaller. Back in the 
day, I tested redoing our compiler as a recursive descent, and it would have 
been roughly 10 times larger than the table-driven parser (code+table). That 
mattered a lot on the original Z80 compiler; we only had 48K RAM to fit the 
entire parser/lexer, and the vast majority of that space was needed for the 
identifier/reserved word tables, and the string literal tables. Our original 
table-driven parser fit in less than 4K, so that left a lot of room for the 
other stuff. The sample recursive descent parser was over 16K before I gave 
up on it as impractical. (Note that I'm only talking about the parser; the 
lexer was exactly the same for either, and the action routines are 
essentially the same either way.)

Obviously, if you're parsing a small subset of Ada (as appears to be the 
case here), and the target size doesn't matter (likely), then recursive 
descent is probably the best choice. (Using ASIS seems like madness to me, 
unless you intend to use a significant part of the semantic analysis. For 
purely parsing, it's much more work to get information out of ASIS than it 
would be to just parse the text yourself.

                                    Randy. 



  reply	other threads:[~2015-06-03 22:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-02 11:33 Parsing Ada? Jacob Sparre Andersen
2015-06-02 12:09 ` G.B.
2015-06-02 12:36   ` Jacob Sparre Andersen
2015-06-02 14:47   ` Luke A. Guest
2015-06-02 16:36 ` Dmitry A. Kazakov
2015-06-03 22:39   ` Randy Brukardt [this message]
2015-06-04  7:45     ` Dmitry A. Kazakov
2015-06-03  7:58 ` Stephen Leake
2015-06-03  8:36   ` J-P. Rosen
2015-06-03 11:04   ` Simon Wright
2015-06-04  6:59   ` Jacob Sparre Andersen
2015-06-04 10:24     ` J-P. Rosen
2015-06-04 12:15     ` jan.de.kruyf
2015-06-04 12:30       ` jan.de.kruyf
2015-06-05  8:02     ` Simon Wright
2015-06-08  7:53       ` Jacob Sparre Andersen
2015-06-05  9:34     ` Stephen Leake
2015-06-08  8:34       ` Jacob Sparre Andersen
2015-06-08 22:45 ` wowwomenonwheels205
replies disabled

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