Re: Why is font-lock needed for a mode based on Semantic CFG parser?
"Eric M. Ludlam" <[email protected]>
| Newsgroups | gmane.emacs.cedet |
|---|---|
| Message-ID | <[email protected]> |
On 08/02/2014 04:01 PM, Left Right wrote: > Hi list, > > Please excuse me, if I'm asking something obvious, but this question > bothered me since I've red the guide for making a mode that uses > Semantic. It says that I need to handle font-lock on my own, which, as > far as I can understand uses parsing system based on regular > expressions. It feels self-defeating to have a real CFG parser with > proper syntax analysis and still rely on regular expressions for > coloring. > > So, my question is: why, Font lock came before the Semantic parsers, so it was not able to take advantage of them. Secondly, the colorizing regexps work on fractions of the overall grammar, allowing it to colorize invalid code that would choke one of the semantic parsers. That makes it more robust for simple expressions. >and if really, isn't it possible to employ > Semantic for syntax highlighting as well as completion / syntax > checking / navigation. Yes, I've often thought it would be nice to add coloring convenience information to Semantic to make this work, but have never gotten around to it since font lock works quite well. > Do I need font-lock mode for Semantic to work > (properly)? Semantic uses some key variables such as `comment-start' and the syntax table as a way of bootstrapping it's lexer. There are also a couple hacks that check for a font-lock face at a particular location to decide if it should do something, such as not providing completions while in a text string or comment. >If I may guess: is this because during editing the edited > region may not be syntactically valid and it is hard / not possible / > too costly at the moment to deal with it using Semantic? This is a factor. Semantic does have an incremental parser that is able to keep parts of a buffer up to date even when other parts are not parsable. It is not robust enough to allow colorization while editing code in an incomplete code block though. Other good blocks may colorize, but an incomplete block would not. I hope this helps. Eric ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk