On Aug 26, 2:21 am, "Jean-Philippe Bernardy" <[EMAIL PROTECTED]>
wrote:

> We have our own proper parsing library for source files: Yi.IncrementalParse. 
> As its name indicates this allows support for incremental parsing, and error 
> correction, which Parsec lacks.

Ah, my bad. Same idea, though: actually parsing the files. Good. :)

> This is exactly what we do. See eg. Yi.Syntax.Paren.getStrokes

Hmm, when is this used? I was under the impression that the lexer
actions indicated to Yi what style should be used, and this was all
that happened. E.g., in the Python lexer, there is [EMAIL PROTECTED] { c
keywordStyle }`, which seems to the exact style name used when
highlighting (`keywordStyle` is used in the Yi.Style.Library style
definitions). It seems, then, that the styles aren't working with a
parsed file, but the direct output of Alex: just a token stream,
right?

Yi.IncrementalParsing seems to do a lot of the right stuff, but I'm
not sure how this is used currently. It looks like Yi may be using
this with the lexing, although I'm not exactly sure how this
integrates with Alex.

To me, the styles in Yi.Styles.Library should be referencing the
hierarchy, not token names. A style might define "source > haskell >
function > name" to a certain color, or "source > function > name",
"function > name", or even just "name" to apply to all function names,
variable names, etc.

> Cpp has its own Alex file. It was copy-pasted/hacked from the Haskell one,
> which explains why it's so odd. So, that Cpp looks strange does not
> undermine Yi's principle for highlighting. eg. Corey wrote a proper
> python lexer.
>
> Feel free to fix Cpp ;)

Ah, I wrote the Python lexer. :)

I'm not complaining about the implementation of cppStyle, but rather
that it is a required definition for all styles (do we want to call
these stylesheets? uistyles?), even though it doesn't make sense in
many languages. It is very Haskell-specific, and it is odd to require
specific tokens for all style definitions. With a hierarchical
definition, only a default style for "source" or whatever root is
chosen would be needed, and then other styles that are more specific
could be used in place of that. "source" can be defined to black text
on a white background, and "source > function > name" can be defined
to red text (the background could cascade or just be left undefined
and fall back to the previously defined color, it doesn't really
matter).

It shouldn't be necessary to style all possible tokens, as many
languages have specific syntax which only makes sense when
highlighting those, like Haskell's cpp (the token "upperIdStyle" is
similarly problematic, but only in that most languages would merely
use "idStyle").

Please forgive me if I'm being silly, I'm far from an expert in either
Yi or syntax highlighting.

Jeff Wheeler
--~--~---------~--~----~------------~-------~--~----~
Yi development mailing list
[email protected]
http://groups.google.com/group/yi-devel
-~----------~----~----~----~------~----~------~--~---

Reply via email to