[Qt-creator] SyntaxHighlighting + Bison/FLex

Eike Ziller Eike.Ziller at qt.io
Thu Nov 23 08:59:37 CET 2017


> On 23. Nov 2017, at 07:29, JeremY Larrieu <adrenalinedj at gmail.com> wrote:
> 
> Hello,
> 
> I'm working on making a plugin to support a specific language: Anubis.
> 
> I've started the highlighting part and I saw that QtCreator is making syntax highlighting line by line instead of making it "globally" for the whole file.
> 
> I just wanna know, how can I use the Bison/Flex files, used to check syntax for Anubis language, to make syntax highlighting in QtCreator.
> Knowing that most of the tokens declared in the Flex file can be multiline, making a lexer, working line by line, able to detect those tokens is hard and the code is too "verbose". 
> 
> I've tried to adapt what I've found in Bison/Flex files to make a syntax highlighter, but it's really painful and it makes further updates harder.
> If I was able to apply highlighting on the whole file (not line by line), it were simpler and I could use it to make some other functionalities at the same time: code completion, code analysis, symbol detection, ...
> 
> Do you have an idea on how I can make syntax highlighting without rewriting a full lexer ?

Usually what you would do is to lex (or create an AST or whatever) the full document on document load and document change (probably asynchronously!), and make the highlighter just access that information based on the line it is supposed to highlight.

> Thanks in advance.
> 
> Jeremy
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator

-- 
Eike Ziller
Principal Software Engineer

The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin
eike.ziller at qt.io
http://qt.io
Geschäftsführer: Mika Pälsi,
Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B



More information about the Qt-creator mailing list