Re: Articles/books that discuss separating the context-free part of a language from the context-sensitive part?

glen herrmannsfeldt <gah@ugcs.caltech.edu>
Sat, 18 May 2013 00:18:54 +0000 (UTC)

          From comp.compilers

Related articles
Articles/books that discuss separating the context-free part of a lang costello@mitre.org (Costello, Roger L.) (2013-05-17)
Re: Articles/books that discuss separating the context-free part of a gah@ugcs.caltech.edu (glen herrmannsfeldt) (2013-05-18)
Re: Articles/books that discuss separating the context-free part of a ademakov@gmail.com (Aleksey Demakov) (2013-05-18)
Re: Articles/books that discuss separating the context-free part of a genew@telus.net (Gene Wirchenko) (2013-05-19)
Re: Articles/books that discuss separating the context-free part of a gah@ugcs.caltech.edu (glen herrmannsfeldt) (2013-05-20)
Re: Articles/books that discuss separating the context-free part of a anton@mips.complang.tuwien.ac.at (2013-05-20)
Re: Articles/books that discuss separating the context-free part of a genew@telus.net (Gene Wirchenko) (2013-05-20)
| List of all articles for this month |
From: glen herrmannsfeldt <gah@ugcs.caltech.edu>
Newsgroups: comp.compilers
Date: Sat, 18 May 2013 00:18:54 +0000 (UTC)
Organization: Aioe.org NNTP Server
References: 13-05-010
Keywords: parse
Posted-Date: 17 May 2013 21:23:53 EDT

Costello, Roger L. <costello@mitre.org> wrote:
> I read this fantastic post on the comp.theory list:


> http://coding.derkeiler.com/Archive/General/comp.theory/2004-03/0189.html


> The poster makes the point that most programming languages define a
> context-free core, and then have additional algorithms which run on the parse
> tree to filter out constructs that are illegal in the language:


(snip)


> [That's been the conventional wisdom at least since I took a compilers
> course in the early 1970s. I believe I mentioned it in lex&yacc and
> later in flex&bison. It's easier, and it also permits much better
> error messages. -John]


As I remember it, it is not so easy to do for recursive descent
parsers. As a result, as noted, you get poor error messages, such as:


      SYNTAX ERROR


somewhere near where the problem is. For languages with reserved works,
it is nice to say exactly what the problem is. It gets more
interesting without reserved words. Yesterday, following a post
in comp.lang.fortran I tried:


TYPE :: DEEP
      TYPE(DEEP) :: POINTER
END TYPE


When compiling it, the error message, pointing right to the
word POINTER, say "must have POINTER attribute".


Fortunately it only took me a few seconds to figure out, and then
laugh at it. But yes, you can get funny messages without reserved
words.


-- glen


Post a followup to this message

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