C Parser

Lex Spoon lex at cc.gatech.edu
Fri Jan 26 07:19:11 UTC 2001

"Eric Arseneau" <eat at huv.com> wrote:
> Does anyone know of a C parser written in Squeak that I could use ?
> I have some C stuff to do with Pocket Smalltalk, and I just find it too
> painful to deal with all functions and vars defined in a single file with an
> editor that is not very C aware.

To pick a nit, there are very few editors that correctly parse C in
real.  Besides the fact that parser-editor combos are unpopular nowadays
in general, the C that hasn't been preprocessed is extremely hard to
write tools for -- the preprocessor can make extreme changes to the
syntax, so what's a parser to do?  Most C tools that want to be correct,
analyze code that's been preprocessed already, but that's not a great
option for an editor.

What Emacs does is make good guesses.  For C, I think there is actually
a complicated function that scans around the buffer and tries to figure
out what's happening.  For most other file formats, Emacs simply uses a
list of regular expressions: a variable looks like this, a method header
looks like this, and so on.  (As a bread generalization, regular
expressions are usually wrong, but convenient!)

-Lex, who would dearly love Emacs-ish text windows in Squeak

More information about the Squeak-dev mailing list