JSON Lexer

347 views
Skip to first unread message

Mike Lischke

unread,
Sep 16, 2013, 9:06:29 AM9/16/13
to scintilla...@googlegroups.com
Hey Neil,

my search in the archive or google hasn't brought up anything useful, so a question is due: it seems there is no dedicated JSON lexer for scintilla, only the Javascript handling in the HTML lexer (though I doubt this can be used to colorize standalone JSON text). So what can we do about this? I guess, if all fails, we have to write a new lexer, right?

Lex Trotman

unread,
Sep 16, 2013, 9:25:55 AM9/16/13
to scintilla...@googlegroups.com
Hi Mike,

Look inside LexCPP.cxx for the "standalone" js lexer :)

I'm told it works fine for JSON.

Cheers
Lex


--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-inter...@googlegroups.com.
To post to this group, send email to scintilla...@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.

Mike Lischke

unread,
Sep 16, 2013, 9:36:17 AM9/16/13
to scintilla...@googlegroups.com

Look inside LexCPP.cxx for the "standalone" js lexer :)

Ugh, how on earth did a javascript lexer end up in the c++ lexer? There's another one in the HTML lexer, so .. duplicate code probably.

Thanks, Lex,


Lex Trotman

unread,
Sep 16, 2013, 9:53:07 AM9/16/13
to scintilla...@googlegroups.com
On 16 September 2013 23:36, Mike Lischke <mike.l...@googlemail.com> wrote:

Look inside LexCPP.cxx for the "standalone" js lexer :)

Ugh, how on earth did a javascript lexer end up in the c++ lexer? There's another one in the HTML lexer, so .. duplicate code probably.

It is common (but bad IMHO) to mix together languages that have a superficial syntactic similarity, for example ctags has *parsers* for most of the { } languages in one totally unmaintainable file.

Calling one lexer from another is complicated by questions like making sure styles don't overlap between the languages and when the embedded lexer returns to the embedding one.  So it is just simpler to just have another version of the embedded language as part of the embedding one.

Cheers
Lex
 

Thanks, Lex,


Philippe Lhoste

unread,
Sep 19, 2013, 3:34:21 AM9/19/13
to scintilla...@googlegroups.com
On 16/09/2013 15:53, Lex Trotman wrote:
> On 16 September 2013 23:36, Mike Lischke <mike.l...@googlemail.com
> <mailto:mike.l...@googlemail.com>> wrote:
>> Look inside LexCPP.cxx for the "standalone" js lexer :)
>
> Ugh, how on earth did a javascript lexer end up in the c++ lexer? There's another one
> in the HTML lexer, so .. duplicate code probably.
>
> It is common (but bad IMHO) to mix together languages that have a superficial syntactic
> similarity, for example ctags has *parsers* for most of the { } languages in one totally
> unmaintainable file.

There is no LexJava either, for example. Indeed, a number of "C-like languages" have been
put in this lexer, mostly because a Scintilla lexer acts only on a superficial level, so
it is OK for all these languages. If you look at it, it doesn't has so much contortions to
address a specific flavor. If a language differs too much (like allowing to nest block
comments, etc.), it forks this lexer (but now, indeed, we have to remove some fluff).

--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --

Reply all
Reply to author
Forward
0 new messages