digitalmars.D - Why is C++ so hard to parse?
- Pete (3/3) Jan 26 2005 Hi,
- Dejan Lekic (7/7) Jan 26 2005 Pete, IMHO C++ is not harder to parse than any other modern language,
- Pete (5/7) Jan 26 2005 A large C++ project here takes mor then three minutes for a complete
- Dejan Lekic (6/6) Jan 26 2005 "Parsing process" != "Compilation (build process)"
- Walter (5/7) Jan 26 2005 I've written a parser for both C++ and D. C++ is a lot harder. In fact, ...
- Stewart Gordon (22/27) Jan 26 2005 Basically, the places where C++ grammar isn't context-free:
- Stewart Gordon (11/14) Jan 26 2005 JTAI, there is at least one bit of C++ that supports forward
- Regan Heath (7/8) Jan 26 2005 I hadn't seen this one before, and googling for it didn't help initially...
- Stewart Gordon (7/18) Jan 27 2005 http://www.acronymfinder.com is a decent source ITR. (Except that it
- Regan Heath (5/19) Jan 27 2005 acronymfinder is where I got JTAI from... I cannot figure out ITR, but i...
- Norbert Nemec (2/3) Jan 27 2005 In This Respect
- Stewart Gordon (6/13) Jan 28 2005 Got it in two.
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (4/6) Jan 26 2005 I have full sympathy for the parser and compiler,
Hi, I don't know much about parsing programming language. But I want to know what makes C++ hard to parse and does D these things right?
Jan 26 2005
Pete, IMHO C++ is not harder to parse than any other modern language, including D. -- ........... Dejan Lekic http://dejan.lekic.org
Jan 26 2005
Pete, IMHO C++ is not harder to parse than any other modern language, including D.A large C++ project here takes mor then three minutes for a complete I did only some _very_ small D programs (if you want to call them programs), so I don't know how fast D will compile.
Jan 26 2005
"Parsing process" != "Compilation (build process)" -- ........... Dejan Lekic http://dejan.lekic.org
Jan 26 2005
"Dejan Lekic" <leka entropy.tmok.com> wrote in message news:ct839i$1iqj$1 digitaldaemon.com...Pete, IMHO C++ is not harder to parse than any other modern language, including D.I've written a parser for both C++ and D. C++ is a lot harder. In fact, C++ is probably the most difficult computer language to parse. D is one of the easier ones.
Jan 26 2005
Pete wrote:Hi, I don't know much about parsing programming language. But I want to know what makes C++ hard to parseBasically, the places where C++ grammar isn't context-free: - cast expressions - template syntax - preprocessor macros to twist the syntactical structure - probably other things.... This means that before C++ can parse something, it must know what the identifiers in it refer to. Consequently, to write a properly-working C++ parser, you almost have to go the whole hog and write a compiler. Consequently, writing code manipulation tools (syntax-directed editors, beautifiers, linters, whatever) becomes tricky. Moreover, parsing engines/parser generators such as yacc expect a context-free grammar. Maybe it's possible using lex/yacc to manipulate the lexer as part of the parsing process, but it must be quite hard to do.and does D these things right?Yes, modulo a few bugs and one legacy waiting to be thrown out. The benefits of context-free grammar don't end there. For example, I think the ability to pre-parse is one thing enabling D to gradually eliminate forward declarations. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Jan 26 2005
Stewart Gordon wrote: <snip>The benefits of context-free grammar don't end there. For example, I think the ability to pre-parse is one thing enabling D to gradually eliminate forward declarations.JTAI, there is at least one bit of C++ that supports forward referencing. Not to mention Java, which has some of the non-context-free grammar from C++. But still, no doubt context-free grammar considerably simplifies the process of supporting forward referencing.... Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Jan 26 2005
On Wed, 26 Jan 2005 16:11:05 +0000, Stewart Gordon <smjg_1998 yahoo.com> wrote:JTAII hadn't seen this one before, and googling for it didn't help initially :) http://www.google.com/search?q=JTAI&sourceid=opera&num=0&ie=utf-8&oe=utf-8 - "Jewish Teen Arts Institue" I now know it means - "Just Thinking About It" Regan
Jan 26 2005
Regan Heath wrote:On Wed, 26 Jan 2005 16:11:05 +0000, Stewart Gordon <smjg_1998 yahoo.com> wrote:http://www.acronymfinder.com is a decent source ITR. (Except that it doesn't list the one I just used ... but hopefully it's understandable FTC.) Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.JTAII hadn't seen this one before, and googling for it didn't help initially :) http://www.google.com/search?q=JTAI&sourceid=opera&num=0&ie=utf-8&oe=utf-8 - "Jewish Teen Arts Institue" I now know it means - "Just Thinking About It"
Jan 27 2005
On Thu, 27 Jan 2005 10:28:20 +0000, Stewart Gordon <smjg_1998 yahoo.com> wrote:Regan Heath wrote:acronymfinder is where I got JTAI from... I cannot figure out ITR, but is FTC (From the context)? ReganOn Wed, 26 Jan 2005 16:11:05 +0000, Stewart Gordon <smjg_1998 yahoo.com> wrote:http://www.acronymfinder.com is a decent source ITR. (Except that it doesn't list the one I just used ... but hopefully it's understandable FTC.)JTAII hadn't seen this one before, and googling for it didn't help initially :) http://www.google.com/search?q=JTAI&sourceid=opera&num=0&ie=utf-8&oe=utf-8 - "Jewish Teen Arts Institue" I now know it means - "Just Thinking About It"
Jan 27 2005
Regan Heath wrote:I cannot figure out ITR,In This Respect
Jan 27 2005
Norbert Nemec wrote:Regan Heath wrote:Got it in two. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.I cannot figure out ITR,In This Respectbut is FTC (From the context)?
Jan 28 2005
Pete wrote:I don't know much about parsing programming language. But I want to know what makes C++ hard to parse and does D these things right?I have full sympathy for the parser and compiler, as I can hardly parse regular C++ code myself :-) --anders
Jan 26 2005