January 26, 2005
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?



January 26, 2005
Pete, IMHO C++ is not harder to parse than any other modern language, including D.

-- 
...........
Dejan Lekic
  http://dejan.lekic.org

January 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
re-compilation. An even larger C# project takes only a few seconds. This isn't
C# specific. Java is as fast.
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.


January 26, 2005
Pete wrote:
> Hi,
> 
> I don't know much about parsing programming language. But I want to know what
> makes C++ hard to parse

Basically, 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.
January 26, 2005
"Parsing process" != "Compilation (build process)"

-- 
...........
Dejan Lekic
  http://dejan.lekic.org

January 26, 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
January 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.
January 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.


January 26, 2005
On Wed, 26 Jan 2005 16:11:05 +0000, Stewart Gordon <smjg_1998@yahoo.com> wrote:
> JTAI

I 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

January 27, 2005
Regan Heath wrote:
> On Wed, 26 Jan 2005 16:11:05 +0000, Stewart Gordon <smjg_1998@yahoo.com>  wrote:
> 
>> JTAI
> 
> I 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"

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.
« First   ‹ Prev
1 2
Top | Discussion index | About this forum | D home