local info = { version = 1.400, comment = "basics for scintilla lpeg lexer for context/metafun", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files", comment = "contains copyrighted code from mitchell.att.foicica.com", } -- todo: hook into context resolver etc -- todo: only old api in lexers, rest in context subnamespace -- todo: make sure we can run in one state .. copies or shared? -- todo: auto-nesting if lpeg.setmaxstack then lpeg.setmaxstack(1000) end local log = false local trace = false local detail = false local show = false -- nice for tracing (also for later) local collapse = false -- can save some 15% (maybe easier on scintilla) local inspect = false -- can save some 15% (maybe easier on scintilla) -- local log = true -- local trace = true -- GET GOING -- -- You need to copy this file over lexer.lua. In principle other lexers could work too but -- not now. Maybe some day. All patterns will move into the patterns name space. I might do -- the same with styles. If you run an older version of SciTE you can take one of the -- archives. Pre 3.41 versions can just be copied to the right path, as there we still use -- part of the normal lexer. -- -- REMARK -- -- We started using lpeg lexing as soon as it came available. Because we had rather demanding -- files and also wanted to use nested lexers, we ended up with our own variant. At least at -- that time this was more robust and also faster (as we have some pretty large lua data files -- and also work with large xml files). As a consequence successive versions had to be adapted -- to changes in the (at that time still unstable) api. In addition to lexing we also have -- spell checking and such. Around version 3.60 things became more stable so I don't expect to -- change much. -- -- STATUS -- -- todo: maybe use a special stripped version of the dll (stable api) and add a bit more -- interfacing to scintilla -- todo: investigate if we can use the already built in lua instance so that we can combine the -- power of lexign with extensions -- todo: play with hotspot and other properties (but no real need now) -- todo: maybe come up with an extension to the api subsystem -- todo: add proper tracing and so .. not too hard as we can run on mtxrun, but we lack a console -- for debugging (ok, chicken-egg as lexers probably need to be loaded before a console can -- kick in) -- todo: get rid of these lexers.STYLE_XX and lexers.XX (hide such details) -- -- wish: access to all scite properties and in fact integrate in scite -- -- -- In the meantime I made the lexer suitable for typesetting sources which was no big deal as we -- already had that in place (ConTeXt used lpeg from the day it showed up so we have several lexing -- options there too). -- -- HISTORY -- -- The fold and lex functions are copied and patched from original code by Mitchell (see lexer.lua). -- All errors are mine. The ability to use lpeg in scintilla is a real nice addition and a brilliant -- move. The code is a byproduct of the (mainly Lua based) textadept (at the time I ran into it was -- a rapidly moving target so I decided to stick ot SciTE). When I played with it, it had no realtime -- output pane but that seems to be dealt with now (2017). I need to have a look at it in more detail -- but a first test again mad the output hang and it was a bit slow too (and I also want the log pane -- as scite has it, on the right, in view). So, for now I stick to SciTE even when it's somewhat -- crippled by the fact that we cannot hook our own (language dependent) lexer into the output pane -- (somehow the errorlist lexer is hard coded into the editor). Hopefully that will change some day. -- So, how did we arrive where we're now. -- -- Starting with SciTE version 3.20 there is an issue with coloring. As we still lack a connection -- with SciTE itself (properties as well as printing to the log pane) and we cannot trace this (on -- windows). As far as I can see, there are no fundamental changes in lexer.lua or LexLPeg.cxx so it -- must be in Scintilla itself. So for the moment I stick to 3.10. Indicators are: no lexing of 'next' -- and 'goto