Skip to content

Commit

Permalink
Support Zig, issue #675.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Jun 29, 2023
1 parent 995eb35 commit 3e76ecd
Show file tree
Hide file tree
Showing 20 changed files with 641 additions and 2 deletions.
2 changes: 2 additions & 0 deletions build/CodeLite/Notepad2.project
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<File Name="../../scintilla/lexers/LexVim.cxx"/>
<File Name="../../scintilla/lexers/LexWASM.cxx"/>
<File Name="../../scintilla/lexers/LexYAML.cxx"/>
<File Name="../../scintilla/lexers/LexZig.cxx"/>
</VirtualDirectory>
<VirtualDirectory Name="lexlib">
<File Name="../../scintilla/lexlib/Accessor.cxx"/>
Expand Down Expand Up @@ -265,6 +266,7 @@
<File Name="../../src/EditLexers/stlWASM.c"/>
<File Name="../../src/EditLexers/stlXML.c"/>
<File Name="../../src/EditLexers/stlYAML.c"/>
<File Name="../../src/EditLexers/stlZig.c"/>
</VirtualDirectory>
<File Name="../../src/Bridge.cpp"/>
<File Name="../../src/Dialogs.c"/>
Expand Down
2 changes: 2 additions & 0 deletions build/VS2017/Notepad2.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@
<ClCompile Include="..\..\scintilla\lexers\LexVim.cxx" />
<ClCompile Include="..\..\scintilla\lexers\LexWASM.cxx" />
<ClCompile Include="..\..\scintilla\lexers\LexYAML.cxx" />
<ClCompile Include="..\..\scintilla\lexers\LexZig.cxx" />
<ClCompile Include="..\..\scintilla\lexlib\Accessor.cxx" />
<ClCompile Include="..\..\scintilla\lexlib\CharacterCategory.cxx" />
<ClCompile Include="..\..\scintilla\lexlib\DefaultLexer.cxx" />
Expand Down Expand Up @@ -667,6 +668,7 @@
<ClCompile Include="..\..\src\EditLexers\stlWASM.c" />
<ClCompile Include="..\..\src\EditLexers\stlXML.c" />
<ClCompile Include="..\..\src\EditLexers\stlYAML.c" />
<ClCompile Include="..\..\src\EditLexers\stlZig.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\scintilla\include\GraphicUtils.h" />
Expand Down
6 changes: 6 additions & 0 deletions build/VS2017/Notepad2.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@
<ClCompile Include="..\..\scintilla\lexers\LexYAML.cxx">
<Filter>Scintilla\lexers</Filter>
</ClCompile>
<ClCompile Include="..\..\scintilla\lexers\LexZig.cxx">
<Filter>Scintilla\lexers</Filter>
</ClCompile>
<ClCompile Include="..\..\scintilla\lexlib\Accessor.cxx">
<Filter>Scintilla\lexlib</Filter>
</ClCompile>
Expand Down Expand Up @@ -609,6 +612,9 @@
<ClCompile Include="..\..\src\EditLexers\stlYAML.c">
<Filter>Source Files\EditLexers</Filter>
</ClCompile>
<ClCompile Include="..\..\src\EditLexers\stlZig.c">
<Filter>Source Files\EditLexers</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\scintilla\include\GraphicUtils.h">
Expand Down
3 changes: 3 additions & 0 deletions doc/FileExt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ MATLAB Code
Nim Script
nim
nimble
nims
nimrod

Nsis Setup Script
Expand Down Expand Up @@ -579,6 +580,8 @@ YAML Document
apinotes Swift API Notes
ifs LLVM IFS (Interface Stubs)

Zig Source
zig

https://en.wikipedia.org/wiki/List_of_filename_extensions
https://fileinfo.com/
Expand Down
3 changes: 3 additions & 0 deletions doc/Notepad2 DarkTheme.ini
Original file line number Diff line number Diff line change
Expand Up @@ -415,3 +415,6 @@ Keyword=fore:#00B050
Document=bold; back:#404030; eolfilled
Number=fore:#F84C4C
Operator=fore:#A349A4
[Zig Source]
Number=fore:#F84C4C
Operator=fore:#A349A4
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ Latest development builds (artifacts in Release configuration for each compiler
* Apple Property List
* Android Manifest
* [YAML Document](https://yaml.org/)
* [Zig](tools/lang/Zig.zig), up to Zig 0.11.
* Many Others
* Toggle fold for specific level, shortcuts: <kbd>Alt</kbd>+<kbd>Number</kbd>
* Toggle fold for current block without scrolling back to the block start line, shortcut: <kbd>Alt</kbd>+<kbd>C</kbd>, or context menu "Toggle Fold"
Expand Down
19 changes: 19 additions & 0 deletions scintilla/include/SciLexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
#define SCLEX_JAMFILE 221
#define SCLEX_AWK 222
#define SCLEX_CSV 223
#define SCLEX_ZIG 224
#define SCLEX_AUTOMATIC 1000
#define SCE_PY_DEFAULT 0
#define SCE_PY_COMMENTLINE 1
Expand Down Expand Up @@ -1740,4 +1741,22 @@
#define SCE_CSV_COLUMN_8 9
#define SCE_CSV_COLUMN_9 10
#define SCE_CSV_DELIMITER 11
#define SCE_ZIG_DEFAULT 0
#define SCE_ZIG_COMMENTLINE 1
#define SCE_ZIG_COMMENTLINEDOC 2
#define SCE_ZIG_TASKMARKER 3
#define SCE_ZIG_NUMBER 4
#define SCE_ZIG_OPERATOR 5
#define SCE_ZIG_CHARACTER 6
#define SCE_ZIG_STRING 7
#define SCE_ZIG_MULTISTRING 8
#define SCE_ZIG_ESCAPECHAR 9
#define SCE_ZIG_FORMAT_SPECIFIER 10
#define SCE_ZIG_PLACEHOLDER 11
#define SCE_ZIG_IDENTIFIER 12
#define SCE_ZIG_BUILTIN_FUNCTION 13
#define SCE_ZIG_WORD 14
#define SCE_ZIG_TYPE 15
#define SCE_ZIG_FUNCTION 16
#define SCE_ZIG_FUNCTION_DEFINITION 17
/* --Autogenerated -- end of section automatically generated from SciLexer.iface */
21 changes: 21 additions & 0 deletions scintilla/include/SciLexer.iface
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ val SCLEX_GROOVY=220
val SCLEX_JAMFILE=221
val SCLEX_AWK=222
val SCLEX_CSV=223
val SCLEX_ZIG=224

# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
# value assigned in sequence from SCLEX_AUTOMATIC+1.
Expand Down Expand Up @@ -3128,3 +3129,23 @@ val SCE_CSV_COLUMN_7=
val SCE_CSV_COLUMN_8=
val SCE_CSV_COLUMN_9=
val SCE_CSV_DELIMITER=
# Lexical states for SCLEX_ZIG
lex Zig=SCLEX_ZIG SCE_ZIG_
val SCE_ZIG_DEFAULT=
val SCE_ZIG_COMMENTLINE=
val SCE_ZIG_COMMENTLINEDOC=
val SCE_ZIG_TASKMARKER=
val SCE_ZIG_NUMBER=
val SCE_ZIG_OPERATOR=
val SCE_ZIG_CHARACTER=
val SCE_ZIG_STRING=
val SCE_ZIG_MULTISTRING=
val SCE_ZIG_ESCAPECHAR=
val SCE_ZIG_FORMAT_SPECIFIER=
val SCE_ZIG_PLACEHOLDER=
val SCE_ZIG_IDENTIFIER=
val SCE_ZIG_BUILTIN_FUNCTION=
val SCE_ZIG_WORD=
val SCE_ZIG_TYPE=
val SCE_ZIG_FUNCTION=
val SCE_ZIG_FUNCTION_DEFINITION=
2 changes: 1 addition & 1 deletion scintilla/lexers/LexNim.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ constexpr bool IsTripleString(int state) noexcept {

// https://nim-lang.org/docs/manual.html#lexical-analysis-string-literals
struct EscapeSequence {
int outerState = SCE_PY_DEFAULT;
int outerState = SCE_NIM_DEFAULT;
int digitsLeft = 0;
bool hex = false;
bool brace = false;
Expand Down
Loading

0 comments on commit 3e76ecd

Please sign in to comment.