Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news.snarked.org!news.linkpendium.com!news.linkpendium.com!news.iecc.com!.POSTED!nerds-end From: glen herrmannsfeldt Newsgroups: comp.compilers Subject: Re: Articles/books that discuss separating the context-free part of a language from the context-sensitive part? Date: Sat, 18 May 2013 00:18:54 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 38 Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <13-05-011@comp.compilers> References: <13-05-010@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: leila.iecc.com 1368840233 90234 64.57.183.58 (18 May 2013 01:23:53 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Sat, 18 May 2013 01:23:53 +0000 (UTC) Keywords: parse Posted-Date: 17 May 2013 21:23:53 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:897 Costello, Roger L. 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