Skip to content

Commit

Permalink
#265 Backport Dart lexer from Notepad4
Browse files Browse the repository at this point in the history
This patch adds the Dart lexer from the Notepad4 editor originally
created by Zufu Liu.

Some changes have been made to make it compile and work in Scintilla
since Notepad4 contains a modified Scintilla version. Also, some
features of the Notepad4 lexer have been removed/changed:

- folding has been modified to use simple folding like the rest of
  Scintilla lexers and not folding of the previous line based on brace
  presence on the next line like Notepad4
- "semi-syntactic" coloring of Notepad4 which colors words following
  a keyword (such as coloring Foo in "class Foo") has been removed
  as this is not performed in other Scintilla lexers
- coloring of string dict keys has been removed so string keys are
  colored as strings and not as keys
- highlighting of tasks such as TODOs in comments has been removed as
  it isn't present in other Scintilla lexers
- various state arithmetic tricks have been eliminated in favor of
  explicit state comparisons which I find more legible and less
  error-prone
- coloring states and keywords have been renamed slightly - keywords
  at index 3 have been reserved for caller-supplied type names
  using SCI_SETKEYWORDS like in the C lexer (which we use in Geany
  to supply type names obtained using ctags)

Fixes #58.
  • Loading branch information
techee authored and nyamatongwe committed Aug 28, 2024
1 parent 6ac5d7e commit fc57a60
Show file tree
Hide file tree
Showing 14 changed files with 1,673 additions and 0 deletions.
1 change: 1 addition & 0 deletions cppcheck.suppress
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ variableScope:lexilla/lexers/LexCSS.cxx
knownConditionTrueFalse:lexilla/lexers/LexDataflex.cxx
constParameterReference:lexilla/lexers/LexDataflex.cxx
variableScope:lexilla/lexers/LexDataflex.cxx
constParameterReference:lexilla/lexers/LexDart.cxx
knownConditionTrueFalse:lexilla/lexers/LexECL.cxx
variableScope:lexilla/lexers/LexECL.cxx
constParameter:lexilla/lexers/LexEDIFACT.cxx
Expand Down
4 changes: 4 additions & 0 deletions doc/LexillaHistory.html
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,10 @@ <h3>
Released 21 August 2024.
</li>
<li>
Lexer added for Dart "dart".
<a href="https://github.com/ScintillaOrg/lexilla/pull/265">Pull request #265</a>.
</li>
<li>
Lexer added for troff / nroff "troff".
<a href="https://github.com/ScintillaOrg/lexilla/pull/264">Pull request #264</a>.
</li>
Expand Down
30 changes: 30 additions & 0 deletions include/LexicalStyles.iface
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ val SCLEX_ASCIIDOC=134
val SCLEX_GDSCRIPT=135
val SCLEX_TOML=136
val SCLEX_TROFF=137
val SCLEX_DART=138

# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
# value assigned in sequence from SCLEX_AUTOMATIC+1.
Expand Down Expand Up @@ -2359,3 +2360,32 @@ val SCE_TROFF_ESCAPE_WIDTH=24
val SCE_TROFF_ESCAPE_VSPACING=25
val SCE_TROFF_ESCAPE_DEVICE=26
val SCE_TROFF_ESCAPE_NOMOVE=27
# Lexical states for SCLEX_DART
lex Dart=SCLEX_DART SCE_DART_
val SCE_DART_DEFAULT=0
val SCE_DART_COMMENTLINE=1
val SCE_DART_COMMENTLINEDOC=2
val SCE_DART_COMMENTBLOCK=3
val SCE_DART_COMMENTBLOCKDOC=4
val SCE_DART_STRING_SQ=5
val SCE_DART_STRING_DQ=6
val SCE_DART_TRIPLE_STRING_SQ=7
val SCE_DART_TRIPLE_STRING_DQ=8
val SCE_DART_RAWSTRING_SQ=9
val SCE_DART_RAWSTRING_DQ=10
val SCE_DART_TRIPLE_RAWSTRING_SQ=11
val SCE_DART_TRIPLE_RAWSTRING_DQ=12
val SCE_DART_ESCAPECHAR=13
val SCE_DART_IDENTIFIER=14
val SCE_DART_IDENTIFIER_STRING=15
val SCE_DART_OPERATOR=16
val SCE_DART_OPERATOR_STRING=17
val SCE_DART_SYMBOL_IDENTIFIER=18
val SCE_DART_SYMBOL_OPERATOR=19
val SCE_DART_NUMBER=20
val SCE_DART_KEY=21
val SCE_DART_METADATA=22
val SCE_DART_KW_PRIMARY=23
val SCE_DART_KW_SECONDARY=24
val SCE_DART_KW_TERTIARY=25
val SCE_DART_KW_TYPE=26
28 changes: 28 additions & 0 deletions include/SciLexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
#define SCLEX_GDSCRIPT 135
#define SCLEX_TOML 136
#define SCLEX_TROFF 137
#define SCLEX_DART 138
#define SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1
Expand Down Expand Up @@ -2103,6 +2104,33 @@
#define SCE_TROFF_ESCAPE_VSPACING 25
#define SCE_TROFF_ESCAPE_DEVICE 26
#define SCE_TROFF_ESCAPE_NOMOVE 27
#define SCE_DART_DEFAULT 0
#define SCE_DART_COMMENTLINE 1
#define SCE_DART_COMMENTLINEDOC 2
#define SCE_DART_COMMENTBLOCK 3
#define SCE_DART_COMMENTBLOCKDOC 4
#define SCE_DART_STRING_SQ 5
#define SCE_DART_STRING_DQ 6
#define SCE_DART_TRIPLE_STRING_SQ 7
#define SCE_DART_TRIPLE_STRING_DQ 8
#define SCE_DART_RAWSTRING_SQ 9
#define SCE_DART_RAWSTRING_DQ 10
#define SCE_DART_TRIPLE_RAWSTRING_SQ 11
#define SCE_DART_TRIPLE_RAWSTRING_DQ 12
#define SCE_DART_ESCAPECHAR 13
#define SCE_DART_IDENTIFIER 14
#define SCE_DART_IDENTIFIER_STRING 15
#define SCE_DART_OPERATOR 16
#define SCE_DART_OPERATOR_STRING 17
#define SCE_DART_SYMBOL_IDENTIFIER 18
#define SCE_DART_SYMBOL_OPERATOR 19
#define SCE_DART_NUMBER 20
#define SCE_DART_KEY 21
#define SCE_DART_METADATA 22
#define SCE_DART_KW_PRIMARY 23
#define SCE_DART_KW_SECONDARY 24
#define SCE_DART_KW_TERTIARY 25
#define SCE_DART_KW_TYPE 26
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */

#endif
Loading

0 comments on commit fc57a60

Please sign in to comment.