On Tue, Aug 26, 2008 at 4:48 AM, Jeff Wheeler <[EMAIL PROTECTED]> wrote: > > I think the specifics of the syntax highlighting could work a little > better, if changed a bit. > > Let me start off with TextMate, for which I really like the syntax > highlighting and scoping features. TextMate's bundles define languages > using a hierarchical regular expressions, which is a pretty good > system. The file becomes scoped, in that any part of the file can be > described in various ways. For example (in Python, because the Haskell > bundle doesn't really use this to the fullest potential), the name of > the function in the definition for a class's `__init__` method has > these scopes: > > source.python > meta.function.python > entity.name.function.python > support.function.magic.python > > Syntax highlighting can then be based on all these levels of scope. I > could, for example, define a background by referring to > `source.python` (which would apply a background to the text of the > entire file), or `source.python meta.function.python` (applies to all > of "def ...(...):"). But when writing the style, I usually don't want > to write for a specific language, so I'd write something like > `meta.function` and it would style all functions, no matter the > language.
Interesting, thanks for the info. > I don't think this is quite the right solution for Yi, though. It does > work very well, but it uses regular expressions heavily, and I agree > that lexing with Alex is a smarter solution. I think that is not a > complete solution, though, because it does not provide the > hierarchical scoping that is essential to a good system. > > I know Parsec is used somewhere in Yi, but I'm not exactly sure for > what it is used. 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. > If the syntax highlighters could work with the AST of > a parsed file, I believe this would lead to much more precise and > powerful parsing. This is exactly what we do. See eg. Yi.Syntax.Paren.getStrokes > Regardless, I think the highlighting in Yi is problematic, currently, > because the specific tokens are odd and very Haskell-specific. "cpp", > etc. seem very much out-of-place in this context. 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 ;) Cheers, JP. --~--~---------~--~----~------------~-------~--~----~ Yi development mailing list [email protected] http://groups.google.com/group/yi-devel -~----------~----~----~----~------~----~------~--~---
