character syntax
Simon Marlow
simonmar@microsoft.com
Fri, 8 Feb 2002 11:06:51 -0000
> itz> All this taken together, I mean, _really_, is the lexical
> itz> structure of Haskell a botch, or what?
>=20
> Jon> No. Innovative. All the problems described in this thread reflect
> Jon> unwarranted assumptions inherited in emacs. It's plainly possible
> Jon> to parse Haskell, and not hard either.
>=20
> First, parsing of a complete program (eg. by a compiler) is quite
> different from parsing a buffer that is being edited by a human. The
> latter is hard, even for fairly well-specified languages.
> Irregularities only make it harder.
For syntax highlighting you only need to lexically analyse the buffer, =
not parse it. Haskell's lexical syntax is parseable by regular =
expressions, which means it shouldn't be hard to plug a syntax =
highlighter for Haskell into just about any editor.
I don't understand why you say that parsing a buffer being edited by a =
human is hard - perhaps doing incremental lexing is slightly harder than =
whole-file lexing, but not that much harder. The "state" of a Haskell =
lexer can be represented with a little trickery by an integer, so it =
isn't hard to cache the lexer's state at the beginning of each line. I =
did this once as an experiment when I added Haskell syntax highlighting =
to one of the KDE editors (I forget which).
The problem is not Haskell, it's emacs. Emacs's syntax highlighting has =
fairly deeply-wired-in assumptions about C-like languages (eg. last I =
looked you still couldn't support nested comments properly in =
font-lock).
Cheers,
Simon