Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > c++ interpreter

Reply
Thread Tools

c++ interpreter

 
 
Steven T. Hatton
Guest
Posts: n/a
 
      04-06-2004
tom_usenet wrote:

> On Mon, 5 Apr 2004 18:02:27 -0700, "Phlip" <(E-Mail Removed)>
> wrote:
>
>>Good luck. At each idle tick, you must collect all the /D command line
>>arguments, read all the header files, expand all the templates, etc. Of
>>course you can borrow the compiler's "program database" file, but that
>>would bond an editor to a specific compiler.
>>
>>Many people want this - not for syntax highlighting, but for a refactoring
>>browser. Their overwhelming lack of progress might indicate "emulating a
>>C++ compiler" is on the hard end of the scale.
>>
>>Ultimately, the compiler emulation must match the destination compiler
>>exactly. Or it will burn engineers, and then they won't use it at all.

>
> There are various projects to write C++ parsers for use in, e.g., code
> refactoring. But as you say, the problem is an order of magnitude or
> two larger that for much simpler languages like Java.
>
> Eclipse has a built in C++ parser, but I expect it will take a long
> time before it is anything like as reliable as the Java one.
>
> Tom


Now, suppose you had a way to represent a C++ program in XML. I know. The
very thought sounds hideous. I will suggest anybody who wants to reject
this idea out-of-hand, take a look at MathML. But even that suggests
something far more painful to look at than what I am suggesting.

Consider that XML is a descendant of SGML which was created to semantically
markup text for electronic processing. The Document Object Model (DOM) is
ostensibly just that, an object model to represent a document. It seems
reasonable in my mind to consider a source file and/or translation unit a
document.

The DOM is intended to support validity checking against some kind of
document definition, be that a DTD, XMLSchema, or other form of document
specification. I believe any properly formed C++ translation unit will be
representable as a tree graph, and thus conform to a DOM representation.

I've spent a good deal of time with the DOM specifications
http://www.w3.org/DOM/ and firmly believe this is, in principle a
reasonable approach to constructing an IDE buffer. There are many powerful
features built into the DOM which would probably be very useful in editing
and manipulating a program.

Why am I saying this here in this newsgroup? Because I think it is
potentially valuable to C++, and i would like to see someone pick it up and
run with it.

The piece I think needs to be created first is the schema representation of
C++ to validate a document against.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
 
Reply With Quote
 
 
 
 
Buster
Guest
Posts: n/a
 
      04-06-2004
Bill Seurer wrote:
> Buster wrote:
>
>> Phlip wrote:
>>
>>> A C++ perspective couldn't do that because a #define may have screwed
>>> with
>>> object or method.

>>
>> Yes it could, if it understood the preprocessor.

>
> And if it can read the user's mind re: the -D option (or equivalent)
> that most compilers provide.


That's silly. The IDE invokes the compiler, so it knows what options
it's going to pass on. These depend on the configuration the user has
selected within the IDE, and on information about the compiler which
will be provided separately (e.g. the 'specs' read by gcc).

BTW, I use emacs and bash as my IDE, just the way God intended, and
when I need to use a word processor (which is rarely), the first thing
I do is disable automatic spell-checking.

--
Regards,
Buster.
 
Reply With Quote
 
 
 
 
Buster
Guest
Posts: n/a
 
      04-06-2004
Phlip wrote:
> Buster wrote:
>>Phlip wrote:
>>
>>>Consider object.method(), where method does not exist yet. The Java
>>>perspective in the Eclipse editor can underline "method" in pink, the
>>>same way a word processor indicates misspelled words.

>>
>>Ugh. Does it underline the 'm' straight away, or does it wait until
>>you finish your word?

>
> It waits for idle ticks.
>
>>>A C++ perspective couldn't do that because a #define may have screwed
>>>with object or method.

>>
>>Yes it could, if it understood the preprocessor.

>
> Tip: read a whole post before replying.


It would have been difficult to respond to every sentence had I done
otherwise.

>>That's true, but we can write stand-alone parsers for C++ and tune
>>them how we wish, just as the Eclipse developers did for Java.

>
> Good luck. At each idle tick, you must collect all the /D command line
> arguments, read all the header files, expand all the templates, etc.
> Of course you can borrow the compiler's "program database" file, but
> that would bond an editor to a specific compiler.


No. The browser's parser can build its own database. Header files and
templates make this more difficult for C++ than for Java, but the basic
problem is not changed. Does Eclipse invoke javac "at each idle tick"?

> Many people want this - not for syntax highlighting, but for a
> refactoring browser. Their overwhelming lack of progress might
> indicate "emulating a C++ compiler" is on the hard end of the scale.


Yes, but obviously not impossible, since it can be no harder than
writing a C++ compiler.

> Ultimately, the compiler emulation must match the destination compiler
> exactly. Or it will burn engineers, and then they won't use it at all.


You're probably right. The simple solution is to bundle the IDE and
compiler together.

I seem to be drawing myself in deeper than I wanted. I'm not offering
to write a refactoring browser for C++ and I can see that it would be
difficult to do so. Phlip wrote, "But C++ can't use this feature,
because our compilers _can_ build executables with errors!". The
inference may be valid but its premise is false for a large class of
syntax errors. That was the only point I tried to make with my first two
posts on this thread.

--
Regards,
Buster.
 
Reply With Quote
 
tom_usenet
Guest
Posts: n/a
 
      04-06-2004
On Tue, 06 Apr 2004 17:40:26 +0100, Buster <(E-Mail Removed)> wrote:

> > Many people want this - not for syntax highlighting, but for a
> > refactoring browser. Their overwhelming lack of progress might
> > indicate "emulating a C++ compiler" is on the hard end of the scale.

>
>Yes, but obviously not impossible, since it can be no harder than
>writing a C++ compiler.


That is very very hard. Even a parser is hard to write (e.g. the new
hand-written parser in GCC 3.4). The arcane translation unit rules of
C++ (affecting name lookup, templates, overloading, etc.) make it
rather hard to parse quickly, and even harder to analyse correctly.

EDG wrote a Java front end (full parser and semantic analysis) and
compiler in less time than it took them to implement 1 C++ feature
(export). It is possible to parse C++ in realtime, but the
difficulties of doing this efficiently should not be underestimated.

Diagnosing link time type errors in realtime with squiggly underlines
would be nearly impossible.

Tom
--
C++ FAQ: http://www.parashift.com/c++-faq-lite/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
 
Reply With Quote
 
Buster
Guest
Posts: n/a
 
      04-06-2004
tom_usenet wrote:

> On Tue, 06 Apr 2004 17:40:26 +0100, Buster <(E-Mail Removed)> wrote:
>
>>Yes, but obviously not impossible, since it can be no harder than
>>writing a C++ compiler.

>
> That is very very hard.


Yes but [...]

--
Regards,
Buster.
 
Reply With Quote
 
Peter Nolan
Guest
Posts: n/a
 
      04-08-2004
"Pete" <(E-Mail Removed)> wrote in message news:<Cgdcc.15717$(E-Mail Removed) hlink.net>...
> tom_usenet wrote:
> > On Sun, 04 Apr 2004 17:28:03 GMT, "Pete" <(E-Mail Removed)> wrote:
> >> Besides, VC++2003 is a great IDE + compiler, anyway.

> >
> > The compiler is fine, but the IDE is not. I've never found a good C++
> > ide - good ones for other languages (such as Java - IntelliJ and
> > Eclipse) are common.
> >
> > C++'s TU-based rather than module-based approach (not to mention other
> > features of the preprocessor) makes it almost impossible to write what
> > I would consider a good IDE for C++.
> >
> > Tom

>
> I've always thought it was a great IDE. What can the Java ones that you
> mentioned do that C++ ones cannot?
>
> - Pete


Tom,
I've been using Visual Studio for about 18 months now...can't imagine
a better IDE....it does everything I want....if I am careful I can
make sure that all the code I write runs on variuos flavours of unix
as well....

The VS.net IDE (my opinion) makes the desirability of an interpreter
almost go away.....there is very little need to set up some sample
code in an interpreter to trace it before compile execute because the
VS IDE is good enough to do much of what you want.....about the only
thing missing is the self declaring variables that the IBM rexx
interpreter used to have....but I have always thought declaring
variables before you use them was the better way to go.....self
declaring variables sometimes giev you the wrong data type....

Peter Nolan
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash: ./firefox-installer: /bin/sh: bad interpreter: Permission denied damon Firefox 7 08-29-2007 08:50 PM
Python embedded interpreter: how to initialize the interpreter ? ycollet@freesurf.fr Python 3 01-03-2007 01:00 AM
defining subroutines when using interpreter interactively? MackS Perl 0 03-11-2005 01:26 AM
Need a good book help me do interpreter adam Perl 0 09-01-2003 03:38 PM
bash: /root/remstats.pl: /usr/bin/perl: bad interpreter: Permission denied Goblin Perl 1 08-14-2003 11:11 AM



Advertisments