Related articles |
---|
RE: C++ intermediate representation. quinn-j@shaw.ca (Quinn Tyler Jackson) (2005-05-14) |
RE: C++ intermediate representation. quinn-j@shaw.ca (Quinn Tyler Jackson) (2005-05-14) |
RE: C++ intermediate representation. quinn-j@shaw.ca (Quinn Tyler Jackson) (2005-05-14) |
Re: C++ intermediate representation. cfc@shell01.TheWorld.com (Chris F Clark) (2005-05-14) |
RE: C++ intermediate representation. quinn-j@shaw.ca (Quinn Tyler Jackson) (2005-05-15) |
RE: C++ intermediate representation. quinn-j@shaw.ca (Quinn Tyler Jackson) (2005-05-15) |
RE: C++ intermediate representation. quinn-j@shaw.ca (Quinn Tyler Jackson) (2005-05-15) |
From: | Quinn Tyler Jackson <quinn-j@shaw.ca> |
Newsgroups: | comp.compilers |
Date: | 15 May 2005 15:43:31 -0400 |
Organization: | Compilers Central |
References: | 05-05-103 |
Keywords: | C++, parse |
Posted-Date: | 15 May 2005 15:43:31 EDT |
> As Quinn Tyler Jackson mentioned, he wrote one (backtracking LL) for
> his tool Grammar Forge. He even made his job harder by doing it
> without the normal "hacks" one allows oneself, doing it all within
> the formal context of his tool.
I discovered (with the help of a tester) that some of the most
difficult to parse constructions weren't in the strictly C++ things,
but in the legacy C things that one is only likely to find after macro
expansion of headers.
Also, because the $-grammar tries to deal with such things as scope,
typedefs, and so on, it doesn't just blindly accept syntactically
correct but semantically incorrect constructions (well, it blindly
accepts *some* of them, but catches some others).
Mostly, writing a grammar-only C++ parser is an exercise in ironing
out other kinks in the parsing engine. Getting it to perform in linear
time such that it doesn't take a week to parse a file, for instance,
required a lot of optimizing of the engine that a more "graceful"
language wouldn't likely have inspired me to attempt.
For comparison, here is the number of productions in the $-grammars of
various languages:
C++ 316
C# 292
Lua 98
Perl 125
SQL 136
(Some of those productions are placeholders.)
The Perl grammar mentioned above doesn't support all of Perl, but does
support some rather tricky constructions.
It's interesting to note that the C# $-grammar, although it is almost as
large as the C++ $-grammar, doesn't require any adaptive productions --
something that the C++ $-grammar required more than a few of (and the Perl
grammar more or less lives on).
--
Chev. Quinn Tyler Jackson
Computer Scientist, Novelist, Poet
http://members.shaw.ca/qjackson/
Return to the
comp.compilers page.
Search the
comp.compilers archives again.