play around with Scintilla and Lexilla

This commit is contained in:
2024-07-02 23:47:26 +08:00
parent d7c71f41b2
commit 727a2ec214
992 changed files with 281111 additions and 195 deletions

View File

@ -0,0 +1,161 @@
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org" />
<meta name="generator" content="SciTE" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="keywords" content="Scintilla, SciTE, Editing Component, Text Editor" />
<meta name="Description"
content="www.scintilla.org is the home of the Scintilla editing component and SciTE text editor application." />
<meta name="Date.Modified" content="20240423" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
.logo {
background: url(https://www.scintilla.org/LexillaLogo.png) no-repeat;
background-image: image-set(
url(https://www.scintilla.org/LexillaLogo.png) 1x,
url(https://www.scintilla.org/LexillaLogo2x.png) 2x );
height:150px;
}
#versionlist {
margin: 0;
padding: .5em;
list-style-type: none;
color: #FFCC99;
background: #000000;
}
#versionlist li {
margin-bottom: .5em;
}
#menu {
margin: 0;
padding: .5em 0;
list-style-type: none;
font-size: larger;
background: #CCCCCC;
}
#menu li {
margin: 0;
padding: 0 .5em;
display: inline;
}
</style>
<script type="text/javascript">
function IsRemote() {
var loc = '' + window.location;
return (loc.indexOf('http:')) != -1 || (loc.indexOf('https:') != -1);
}
</script>
<title>
Lexilla
</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table bgcolor="#000000" width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="256">
</td>
<td width="40%" align="left">
<font color="#FFCC99" size="4"> A library of language lexers for use with Scintilla</font>
</td>
<td width="40%" align="right">
<font color="#FFCC99" size="3">Release version 5.3.2<br />
Site last modified April 23 2024</font>
</td>
<td width="20%">
&nbsp;
</td>
</tr>
</table>
<table bgcolor="#000000" width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="100%" class="logo">
&nbsp;
</td>
</tr>
</table>
<ul id="versionlist">
<li>Version 5.3.2 improves COBOL, HTML, Lua, Ruby, and Rust.</li>
<li>Version 5.3.1 improves Assembler, Bash, Batch, JavaScript, Python, and Ruby.</li>
<li>Version 5.3.0 improves Bash, HTML, and Lua.</li>
<li>Version 5.2.9 fixes potential problems on macOS 12 and older when built with Xcode 15.0.</li>
<li>Version 5.2.8 improves Python and R.</li>
</ul>
<ul id="menu">
<li id="remote1"><a href="https://www.scintilla.org/SciTEImage.html">Screenshot</a></li>
<li id="remote2"><a href="https://www.scintilla.org/LexillaDownload.html">Download</a></li>
<li><a href="https://www.scintilla.org/LexillaDoc.html">Documentation</a></li>
<li><a href="https://github.com/ScintillaOrg/lexilla/issues">Bugs</a></li>
<li id="remote3"><a href="https://www.scintilla.org/SciTE.html">SciTE</a></li>
<li><a href="https://www.scintilla.org/LexillaHistory.html">History</a></li>
<li><a href="https://www.scintilla.org/ScintillaRelated.html">Related</a></li>
<li id="remote4"><a href="https://www.scintilla.org/Privacy.html">Privacy</a></li>
</ul>
<script type="text/javascript" language="JavaScript"><!--
if (!IsRemote()) { //if NOT remote...
document.getElementById('remote1').style.display='none';
document.getElementById('remote2').style.display='none';
document.getElementById('remote3').style.display='none';
document.getElementById('remote4').style.display='none';
}
//--></script>
<p>
<a href="https://www.scintilla.org/LexillaDoc.html">Lexilla</a> is a free library of language
lexers that can be used with the <a href="https://www.scintilla.org/index.html">Scintilla</a>
editing component.
It comes with complete source code and a <a href="https://www.scintilla.org/License.txt">license</a> that
permits use in any free project or commercial product.
</p>
<p>
Originally, this functionality was incorporated inside Scintilla.
It has been extracted as a separate project to make it easier for contributors to work on
support for new languages and to fix bugs in existing lexers.
It also defines a protocol where projects can implement their own lexers and distribute
them as they wish.
</p>
<p>
Current development requires a recent C++ compiler that supports C++17.
The testing framework uses some C++20 features but the basic library only uses C++17.
</p>
<p>
Lexilla is currently available for Intel Win32, macOS, and Linux compatible operating
systems. It has been run on Windows 10, macOS 10.13+, and on Ubuntu 20.04 but is likely
to run on earlier systems as it has no GUI functionality.
</p>
<p>
You can <a href="https://www.scintilla.org/LexillaDownload.html">download Lexilla.</a>
</p>
<p>
The source code can be downloaded via Git at GitHub
<a href="https://github.com/ScintillaOrg/lexilla">Lexilla project page</a>.<br />
git clone https://github.com/ScintillaOrg/lexilla
</p>
<p>Current repository status:<br />
<a href="https://github.com/ScintillaOrg/lexilla/actions/workflows/build-check.yml"><img src="https://github.com/ScintillaOrg/lexilla/actions/workflows/build-check.yml/badge.svg" /></a><br />
<a href="https://github.com/ScintillaOrg/lexilla/actions/workflows/build-check-win32.yml"><img src="https://github.com/ScintillaOrg/lexilla/actions/workflows/build-check-win32.yml/badge.svg" /></a><br />
<a href="https://github.com/ScintillaOrg/lexilla/actions/workflows/build-check-macos.yml"><img src="https://github.com/ScintillaOrg/lexilla/actions/workflows/build-check-macos.yml/badge.svg" /></a>
</p>
<p>
<a href="https://www.scintilla.org/ScintillaRelated.html">Related sites.</a>
</p>
<p>
<a href="https://github.com/ScintillaOrg/lexilla/issues">Bugs and other issues.</a>
</p>
<p>
<a href="https://www.scintilla.org/LexillaHistory.html">History and contribution credits.</a>
</p>
<p>
Questions and comments about Lexilla should be directed to the
<a href="https://groups.google.com/forum/#!forum/scintilla-interest">scintilla-interest</a>
mailing list,
which is for discussion of Scintilla and related projects, their bugs and future features.
This is a low traffic list, averaging less than 20 messages per week.
To avoid spam, only list members can write to the list.
New versions of Lexilla are announced on scintilla-interest.
<br />
</p>
</body>
</html>

View File

@ -0,0 +1,254 @@
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator"
content="HTML Tidy for Windows (vers 1st August 2002), see www.w3.org" />
<meta name="generator" content="SciTE" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Lexilla Documentation</title>
<style type="text/css">
<!--
/*<![CDATA[*/
CODE { font-weight: bold; font-family: Menlo,Consolas,Bitstream Vera Sans Mono,Courier New,monospace; }
A:visited { color: blue; }
A:hover { text-decoration: underline ! important; }
A.message { text-decoration: none; font-weight: bold; font-family: Menlo,Consolas,Bitstream Vera Sans Mono,Courier New,monospace; }
A.seealso { text-decoration: none; font-weight: bold; font-family: Menlo,Consolas,Bitstream Vera Sans Mono,Courier New,monospace; }
A.toc { text-decoration: none; }
A.jump { text-decoration: none; }
LI.message { text-decoration: none; font-weight: bold; font-family: Menlo,Consolas,Bitstream Vera Sans Mono,Courier New,monospace; }
H2 { background: #E0EAFF; }
table {
border: 0px;
border-collapse: collapse;
}
div.console {
font-family: Menlo,Consolas,Bitstream Vera Sans Mono,Courier New,monospace;
color: #008000;
font-weight: bold;
background: #F7FCF7;
border: 1px solid #C0D7C0;
margin: 0.3em 3em;
padding: 0.3em 0.6em;
}
span.console {
font-family: Menlo,Consolas,Bitstream Vera Sans Mono,Courier New,monospace;
color: #008000;
font-weight: bold;
background: #F7FCF7;
border: 1px solid #C0D7C0;
margin: 0.1em 0em;
padding: 0.1em 0.3em;
}
.name {
color: #B08000;
}
/*]]>*/
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table bgcolor="#000000" width="100%" cellspacing="0" cellpadding="0" border="0"
summary="Banner">
<tr>
<td><img src="SciTEIco.png" border="3" height="64" width="64" alt="Lexilla icon" /></td>
<td><a href="index.html"
style="color:white;text-decoration:none;font-size:200%">Lexilla</a></td>
</tr>
</table>
<h1>Lexilla Documentation</h1>
<p>Last edited 21 April 2021 NH</p>
<h2>Introduction</h2>
<p>Lexilla is a library containing lexers for use with Scintilla. It can be either a static library
that is linked into an application or a shared library that is loaded at runtime.</p>
<p>Lexilla does not interact with the display so there is no need to compile it for a
particular GUI toolkit. Therefore there can be a common library shared by applications using
different GUI toolkits. In some circumstances there may need to be both 32-bit and 64-bit versions
on one system to match different applications.</p>
<p>Different extensions are commonly used for shared libraries: .so on Linux, .dylib on macOS, and .DLL on Windows.
</p>
<h2>The Lexilla protocol</h2>
<p>A set of functions is defined by Lexilla for use by applications. Libraries that provide these functions
can be used as a replacement for Lexilla or to add new lexers beyond those provided by Lexilla.</p>
<p>The Lexilla protocol is a superset of the external lexer protocol and defines these functions that may be exported from a shared library:<br />
<code>int <span class="name">GetLexerCount</span>()</code><br />
<code>void <span class="name">GetLexerName</span>(unsigned int index, char *name, int buflength)</code><br />
<code>LexerFactoryFunction <span class="name">GetLexerFactory</span>(unsigned int index)</code><br />
<code>ILexer5 *<span class="name">CreateLexer</span>(const char *name)</code><br />
<code>const char *<span class="name">LexerNameFromID</span>(int identifier)</code><br />
<code>const char *<span class="name">GetLibraryPropertyNames</span>()</code><br />
<code>void <span class="name">SetLibraryProperty</span>(const char *key, const char *value)</code><br />
<code>const char *<span class="name">GetNameSpace</span>()</code>
</p>
<p><span class="name">ILexer5</span> is defined by Scintilla in include/ILexer.h as the interface provided by lexers which is called by Scintilla.
Many clients do not actually need to call methods on <span class="name">ILexer5</span> - they just take the return from CreateLexer and plug it
straight into Scintilla so it can be treated as a machine pointer (void *).
</p>
<p><span class="name">LexerFactoryFunction</span> is defined as a function that takes no arguments and returns an <span class="name">ILexer5</span> *:
<code>ILexer5 *(*LexerFactoryFunction)()</code> but this can be ignored by most client code.
</p>
<p>The Lexilla protocol is a superset of the earlier external lexer protocol that defined the first 3 functions
(<span class="name">GetLexerCount</span>, <span class="name">GetLexerName</span>, <span class="name">GetLexerFactory</span>)
so Lexilla can be loaded by applications that support that protocol.
<span class="name">GetLexerFactory</span> will rarely be used now as it is easier to call <span class="name">CreateLexer</span>.
</p>
<p><span class="name">CreateLexer</span> is the main call that will create a lexer for a particular language. The returned lexer can then be
set as the current lexer in Scintilla by calling
<a class="seealso" href="ScintillaDoc.html#SCI_SETILEXER">SCI_SETILEXER</a>.</p>
<p><span class="name">LexerNameFromID</span> is an optional function that returns the name for a lexer identifier.
<code>LexerNameFromID(SCLEX_CPP) &rarr; "cpp"</code>.
This is a temporary affordance to make it easier to convert applications to using Lexilla.
Applications should move to using lexer names instead of IDs.
This function is deprecated, showing warnings with some compilers, and will be removed in a future version of Lexilla.</p>
<p><span class="name">SetLibraryProperty</span> and <span class="name">GetLibraryPropertyNames</span>
are optional functions that can be
defined if a library requires initialisation before calling other methods.
For example, a lexer library that reads language definitions from XML files may require that the
directory containing these files be set before a call to CreateLexer.
<code>SetLibraryProperty("definitions.directory", "/usr/share/xeditor/language-definitions")</code>
If a library implements SetLibraryProperty then it may also provide a set of valid property names with
GetLibraryPropertyNames that can then be used by the application to define configuration file property
names or user interface elements for options dialogs.</p>
<p><span class="name">GetNameSpace</span> is an optional function that returns a namespace string
that can be used to disambiguate lexers with the same name from different providers.
If Lexilla and XMLLexers both provide a "cpp" lexer than a request for "cpp" may be satisfied by either but "xmllexers.cpp"
unambiguously refers to the "cpp" lexer from XMLLexers.</p>
<h2>Building Lexilla</h2>
<p>Before using Lexilla it must be built or downloaded.</p>
<p>Lexilla requires some headers from Scintilla to build and expects a directory named
"scintilla" containing a copy of Scintilla 5+ to be a peer of the Lexilla top level
directory conventionally called "lexilla".</p>
<div>To build Lexilla, in the lexilla/src directory, run make (for gcc or clang)</div>
<div class="console">make</div>
<div>or nmake for MSVC</div>
<div class="console">nmake -f lexilla.mak</div>
<br />
<div>After building Lexilla, its test suite can be run with make/nmake in the lexilla/test directory. For gcc or clang</div>
<div class="console">make test</div>
or for MSVC<br />
<div class="console">nmake -f testlexers.mak test</div>
<div>Each test case should show "<code>Lexing ...</code>" and errors will display a diagnostic, commonly showing
a difference between the actual and expected result:<br>
<code>C:\u\hg\lexilla\test\examples\python\x.py:1: is different</code>
</div>
<p>There are also RunTest.sh / RunTest.bat scripts in the scripts directory to build Lexilla and then build and run the tests.
These both use gcc/clang, not MSVC.</p>
<p>There are Microsoft Visual C++ and Xcode projects that can be used to build Lexilla.
For Visual C++: src/Lexilla.vcxproj. For Xcode: src/Lexilla/Lexilla.xcodeproj.
There is also test/TestLexers.vcxproj to build the tests with Visual C++.</p>
<h2>Using Lexilla</h2>
<p>Definitions for using Lexilla from C and C++ are included in lexilla/include/Lexilla.h.
For C++, scintilla/include/ILexer.h should be included before Lexilla.h as the
<code>ILexer5</code> type is used.
For C, ILexer.h should not be included as C does not understand it and from C,
<code>void*</code> is used instead of <code>ILexer5*</code>.
</p>
<p>For many applications the main Lexilla operations are loading the Lexilla library, creating a
lexer and using that lexer in Scintilla.
Applications need to define the location (or locations) they expect
to find Lexilla or libraries that support the Lexilla protocol.
They also need to define how they request particular lexers, perhaps with a mapping from
file extensions to lexer names.</p>
<h3 id="CheckLexilla">From C - CheckLexilla</h3>
<p>An example C program for accessing Lexilla is provided in lexilla/examples/CheckLexilla.
Build with <span class="console">make</span> and run with <span class="console">make check</span>.
</p>
<h3>From C++ - LexillaAccess</h3>
<p>A C++ module, LexillaAccess.cxx / LexillaAccess.h is provided in lexilla/access.
This can either be compiled into the application when it is sufficient
or the source code can be copied into the application and customized when the application has additional requirements
(such as checking code signatures).
SciTE uses LexillaAccess.</p>
<p>LexillaAccess supports loading multiple shared libraries implementing the Lexilla protocol at one time.</p>
<h3>From Qt</h3>
<p>For Qt, use either LexillaAccess from above or Qt's QLibrary class. With 'Call' defined to call Scintilla APIs.<br />
<code>
#if _WIN32<br />
&nbsp;&nbsp;&nbsp;&nbsp;typedef void *(__stdcall *CreateLexerFn)(const char *name);<br />
#else<br />
&nbsp;&nbsp;&nbsp;&nbsp;typedef void *(*CreateLexerFn)(const char *name);<br />
#endif<br />
&nbsp;&nbsp;&nbsp;&nbsp;QFunctionPointer fn = QLibrary::resolve("lexilla", "CreateLexer");<br />
&nbsp;&nbsp;&nbsp;&nbsp;void *lexCpp = ((CreateLexerFn)fn)("cpp");<br />
&nbsp;&nbsp;&nbsp;&nbsp;Call(SCI_SETILEXER, 0, (sptr_t)(void *)lexCpp);<br />
</code></p>
<p>Applications may discover the set of lexers provided by a library by first calling
<span class="name">GetLexerCount</span> to find the number of lexers implemented in the library then looping over calling
<span class="name">GetLexerName</span> with integers 0 to <code>GetLexerCount()-1</code>.</p>
<p>Applications may set properties on a library by calling <span class="name">SetLibraryProperty</span> if provided.
This may be needed for initialisation so should before calling <span class="name">GetLexerCount</span> or <span class="name">CreateLexer</span>.
A set of property names may be available from <span class="name">GetLibraryPropertyNames</span> if provided.
It returns a string pointer where the string contains a list of property names separated by '\n'.
It is up to applications to define how properties are defined and persisted in its user interface
and configuration files.</p>
<h2>Modifying or adding lexers</h2>
<p>Lexilla can be modified or a new library created that can be used to replace or augment Lexilla.</p>
<p>Lexer libraries that provide the same functions as Lexilla may provide lexers for use by Scintilla,
augmenting or replacing those provided by Lexilla.
To allow initialisation of lexer libraries, a <code>SetLibraryProperty(const char *key, const char *value)</code>
may optionally be implemented. For example, a lexer library that uses XML based lexer definitions may
be provided with a directory to search for such definitions.
Lexer libraries should ignore any properties that they do not understand.
The set of properties supported by a lexer library is specified as a '\n' separated list of property names by
an optional <code>const char *GetLibraryPropertyNames()</code> function.
</p>
<p>Lexilla and its contained lexers can be tested with the TestLexers program in lexilla/test.
Read lexilla/test/README for information on building and using TestLexers.</p>
<p>An example of a simple lexer housed in a shared library that is compatible with the
Lexilla protocol can be found in lexilla/examples/SimpleLexer. It is implemented in C++.
Build with <span class="console">make</span> and check by running <a href="#CheckLexilla">CheckLexilla</a> against it with
<span class="console">make check</span>.
</p>
</body>
</html>

View File

@ -0,0 +1,71 @@
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org" />
<meta name="generator" content="SciTE" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>
Download Lexilla
</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table bgcolor="#000000" width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<img src="SciTEIco.png" border="3" height="64" width="64" alt="Scintilla icon" />
</td>
<td>
<a href="index.html" style="color:white;text-decoration:none"><font size="5">Download
Lexilla</font></a>
</td>
</tr>
</table>
<table bgcolor="#CCCCCC" width="100%" cellspacing="0" cellpadding="8" border="0">
<tr>
<td>
<font size="4"> <a href="https://www.scintilla.org/lexilla532.zip">
Windows</a>&nbsp;&nbsp;
<a href="https://www.scintilla.org/lexilla532.tgz">
GTK/Linux</a>&nbsp;&nbsp;
</font>
</td>
</tr>
</table>
<h2>
Download.
</h2>
<p>
The <a href="License.txt">license</a> for using Lexilla is similar to that of Python
containing very few restrictions.
</p>
<h3>
Release 5.3.2
</h3>
<h4>
Source Code
</h4>
The source code package contains all of the source code for Lexilla but no binary
executable code and is available in
<ul>
<li><a href="https://www.scintilla.org/lexilla532.zip">zip format</a> (1.3M) commonly used on Windows</li>
<li><a href="https://www.scintilla.org/lexilla532.tgz">tgz format</a> (0.9M) commonly used on Linux and compatible operating systems</li>
</ul>
Instructions for building on both Windows and Linux are included in the readme file.
<h4>
Windows Executable Code
</h4>
There is no download available containing only the Lexilla DLL.
However, it is included in the <a href="SciTEDownload.html">SciTE
executable full download</a> as Lexilla.DLL.
<p>
<a href="SciTEDownload.html">SciTE</a> is a good demonstration of Lexilla.
</p>
<p>
Previous versions can be downloaded from the <a href="LexillaHistory.html">history
page</a>.
</p>
</body>
</html>

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB