Re: Why context-free? (Nick Maclaren)
27 Oct 2005 02:13:32 -0400

          From comp.compilers

Related articles
[22 earlier articles]
Re: Why context-free? find@my.address.elsewhere (Matthias Blume) (2005-10-23)
Re: Why context-free? (Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen) (2005-10-23)
Re: Why context-free? (2005-10-23)
Re: Why context-free? (2005-10-26)
Re: Why context-free? (SM Ryan) (2005-10-26)
Re: Why context-free? (2005-10-26)
Re: Why context-free? (2005-10-27)
Re: Why context-free? (Tony Finch) (2005-10-27)
Re: Why context-free? (2005-10-29)
Re: Why context-free? (2005-10-29)
Re: Why context-free? (2005-11-01)
| List of all articles for this month |

From: (Nick Maclaren)
Newsgroups: comp.compilers
Date: 27 Oct 2005 02:13:32 -0400
Organization: University of Cambridge, England
References: 05-10-053 05-10-079 05-10-180
Keywords: parse, syntax
Posted-Date: 27 Oct 2005 02:13:32 EDT

Henry Spencer <> wrote:
>Neelakantan Krishnaswami <> wrote:
>>Splitting the task of parsing into phases -- a) lexing, b) parsing,
>>and c) type-checking -- is just plain old good engineering...
>This can apply even to things that are not traditionally thought of as
>languages. ...

Yes, but that is not necessarily the best split. My rule for
deciding whether to split up or join modules in programs or aspects
of specifications is quite simple: if the PRECISE specification of
A, B and their interface is simpler or cleaner than that of A+B,
split them; and conversely. Where the skill comes in is in choosing
a good place to do the split :-)

In your example, splitting was clearly the right solution. There are
others where it could be clearly the wrong one. The mistake made by
the dogmatic splitters (remember the "no routine should exceed 20
lines" brigade?) is to ignore the fact that the interface
specification can be more complex than the entity specifications.

In the case I am thinking of, which started this, I am thinking of at
least three phases: lexing, parsing/type matching, and scope and
inheritance checking. To keep the middle phase within bounds, it is
clearly necessary to keep the type matching really simple and really
just part of the parsing.

But the basic principle is the same as Neelakantan Krishnaswami
suggests - the divisions are just slightly different.

Nick Maclaren.

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.