mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
Merge pull request #3462 from RaiKoHoff/Dev_RC1
Lexilla: improved Julia Lexer
This commit is contained in:
commit
5890a7346f
@ -1 +1 @@
|
||||
1
|
||||
2
|
||||
|
||||
@ -610,6 +610,10 @@
|
||||
On Win32 enable hardware-enforced stack protection.
|
||||
<a href="https://sourceforge.net/p/scintilla/feature-requests/1405/">Feature #1405</a>.
|
||||
</li>
|
||||
<li>
|
||||
On 32-bit Win32 using g++, stop exported functions ending with @n causing failures with GetProcAddress.
|
||||
<a href="https://github.com/ScintillaOrg/lexilla/issues/10">Issue #10</a>.
|
||||
</li>
|
||||
</ul>
|
||||
<h3>
|
||||
<a href="https://www.scintilla.org/lexilla502.zip">Release 5.0.2</a>
|
||||
|
||||
@ -49,15 +49,19 @@ struct OptionsJulia {
|
||||
bool foldComment;
|
||||
bool foldCompact;
|
||||
bool foldDocstring;
|
||||
bool foldSyntaxBased;
|
||||
bool highlightTypeannotation;
|
||||
bool highlightLexerror;
|
||||
bool stringInterpolation;
|
||||
OptionsJulia() {
|
||||
fold = true;
|
||||
foldComment = true;
|
||||
foldCompact = false;
|
||||
foldDocstring = true;
|
||||
foldSyntaxBased = true;
|
||||
highlightTypeannotation = true;
|
||||
highlightLexerror = true;
|
||||
stringInterpolation = true;
|
||||
}
|
||||
};
|
||||
|
||||
@ -77,13 +81,20 @@ struct OptionSetJulia : public OptionSet<OptionsJulia> {
|
||||
|
||||
DefineProperty("fold.comment", &OptionsJulia::foldComment);
|
||||
|
||||
DefineProperty("fold.docstring", &OptionsJulia::foldDocstring);
|
||||
DefineProperty("fold.julia.docstring", &OptionsJulia::foldDocstring,
|
||||
"Fold multiline triple-doublequote strings, usually used to document a function or type above the definition.");
|
||||
|
||||
DefineProperty("highlight.typeannotation", &OptionsJulia::highlightTypeannotation,
|
||||
"This option enables Julia highlighting of type after :: as type annotation instead of parsing from the keyword lists.");
|
||||
DefineProperty("fold.julia.syntax.based", &OptionsJulia::foldSyntaxBased,
|
||||
"Set this property to 0 to disable syntax based folding.");
|
||||
|
||||
DefineProperty("highlight.lexerror", &OptionsJulia::highlightLexerror,
|
||||
"This option enables Julia highlighting of syntax error int character or number definition.");
|
||||
DefineProperty("lexer.julia.highlight.typeannotation", &OptionsJulia::highlightTypeannotation,
|
||||
"This option enables highlighting of type after :: as type annotation instead of parsing from the keyword lists.");
|
||||
|
||||
DefineProperty("lexer.julia.highlight.lexerror", &OptionsJulia::highlightLexerror,
|
||||
"This option enables highlighting of syntax error int character or number definition.");
|
||||
|
||||
DefineProperty("lexer.julia.string.interpolation", &OptionsJulia::stringInterpolation,
|
||||
"Set to 0 to not recognize string interpolation at all");
|
||||
|
||||
DefineWordListSets(juliaWordLists);
|
||||
}
|
||||
@ -591,12 +602,13 @@ static void resumeCharacter(StyleContext &sc, bool lexerror) {
|
||||
if (lexerror) {
|
||||
if (sc.ch != '\'') {
|
||||
error = true;
|
||||
while (sc.ch != '\'' && sc.ch != EOF &&
|
||||
sc.ch != '\r' && sc.ch != '\n') {
|
||||
while (sc.ch != '\'' &&
|
||||
sc.ch != '\r' &&
|
||||
sc.ch != '\n') {
|
||||
sc.Forward();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (error) {
|
||||
sc.ChangeState(SCE_JULIA_LEXERROR);
|
||||
sc.ForwardSetState(SCE_JULIA_DEFAULT);
|
||||
@ -611,13 +623,14 @@ static void resumeCharacter(StyleContext &sc, bool lexerror) {
|
||||
|
||||
if (sc.ch != '\'') {
|
||||
error = true;
|
||||
while (sc.ch != '\'' && sc.ch != EOF &&
|
||||
sc.ch != '\r' && sc.ch != '\n') {
|
||||
while (sc.ch != '\'' &&
|
||||
sc.ch != '\r' &&
|
||||
sc.ch != '\n') {
|
||||
sc.Forward();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (error) {
|
||||
sc.ChangeState(SCE_JULIA_LEXERROR);
|
||||
sc.ForwardSetState(SCE_JULIA_DEFAULT);
|
||||
@ -640,10 +653,10 @@ static inline bool IsACharacter(StyleContext &sc) {
|
||||
|
||||
static void ScanParenInterpolation(StyleContext &sc) {
|
||||
// TODO: no syntax highlighting inside a string interpolation
|
||||
|
||||
|
||||
// Level of nested parenthesis
|
||||
int interp_level = 0;
|
||||
|
||||
|
||||
// If true, it is inside a string and parenthesis are not counted.
|
||||
bool allow_paren_string = false;
|
||||
|
||||
@ -670,10 +683,10 @@ static void ScanParenInterpolation(StyleContext &sc) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Resume parsing a String or Command, bounded by the `quote` character (\" or \`)
|
||||
* The `triple` argument specifies if it is a triple-quote String or Command.
|
||||
* Interpolation is detected (with `$`), and parsed if `allow_interp` is true.
|
||||
* Interpolation is detected (with `$`), and parsed if `allow_interp` is true.
|
||||
*/
|
||||
static void resumeStringLike(StyleContext &sc, int quote, bool triple, bool allow_interp, bool full_highlight) {
|
||||
int stylePrev = sc.state;
|
||||
@ -694,9 +707,9 @@ static void resumeStringLike(StyleContext &sc, int quote, bool triple, bool allo
|
||||
}
|
||||
ScanParenInterpolation(sc);
|
||||
sc.ForwardSetState(stylePrev);
|
||||
|
||||
|
||||
checkcurrent = true;
|
||||
|
||||
|
||||
} else if (full_highlight && IsIdentifierFirstCharacter(sc.chNext)) {
|
||||
sc.SetState(SCE_JULIA_STRINGINTERP);
|
||||
sc.Forward();
|
||||
@ -710,13 +723,13 @@ static void resumeStringLike(StyleContext &sc, int quote, bool triple, bool allo
|
||||
|
||||
checkcurrent = true;
|
||||
}
|
||||
|
||||
|
||||
if (checkcurrent) {
|
||||
// Check that the current character is not a special char,
|
||||
// otherwise it will be skipped
|
||||
resumeStringLike(sc, quote, triple, allow_interp, full_highlight);
|
||||
}
|
||||
|
||||
|
||||
} else if (sc.ch == quote) {
|
||||
if (triple) {
|
||||
if (sc.chNext == quote && sc.GetRelativeCharacter(2) == quote) {
|
||||
@ -743,7 +756,7 @@ static void resumeString(StyleContext &sc, bool triple, bool allow_interp) {
|
||||
|
||||
static void resumeNumber (StyleContext &sc, int base, bool &with_dot, bool lexerror) {
|
||||
if (IsNumberExpon(sc.ch, base)) {
|
||||
if (isdigit(sc.chNext) || sc.chNext == '+' || sc.chNext == '-') {
|
||||
if (IsADigit(sc.chNext) || sc.chNext == '+' || sc.chNext == '-') {
|
||||
sc.Forward();
|
||||
// Capture all digits
|
||||
ScanDigits(sc, 10, false);
|
||||
@ -760,7 +773,7 @@ static void resumeNumber (StyleContext &sc, int base, bool &with_dot, bool lexer
|
||||
ScanDigits(sc, base, true);
|
||||
} else if (IsADigit(sc.ch, base) || sc.ch == '_') {
|
||||
ScanDigits(sc, base, true);
|
||||
} else if (isdigit(sc.ch) && !IsADigit(sc.ch, base)) {
|
||||
} else if (IsADigit(sc.ch) && !IsADigit(sc.ch, base)) {
|
||||
if (lexerror) {
|
||||
sc.ChangeState(SCE_JULIA_LEXERROR);
|
||||
}
|
||||
@ -772,7 +785,7 @@ static void resumeNumber (StyleContext &sc, int base, bool &with_dot, bool lexer
|
||||
}
|
||||
|
||||
static void resumeOperator (StyleContext &sc) {
|
||||
if (sc.chNext == ':' && (sc.ch == ':' || sc.ch == '<' ||
|
||||
if (sc.chNext == ':' && (sc.ch == ':' || sc.ch == '<' ||
|
||||
(sc.ch == '>' && (sc.chPrev != '-' && sc.chPrev != '=')))) {
|
||||
// Case `:a=>:b`
|
||||
sc.Forward();
|
||||
@ -870,10 +883,10 @@ void SCI_METHOD LexerJulia::Lex(Sci_PositionU startPos, Sci_Position length, int
|
||||
} else {
|
||||
israwstring = false;
|
||||
}
|
||||
|
||||
|
||||
sc.ChangeState(SCE_JULIA_STRINGLITERAL);
|
||||
sc.SetState(SCE_JULIA_DEFAULT);
|
||||
|
||||
|
||||
} else if (sc.ch == '`') {
|
||||
sc.ChangeState(SCE_JULIA_COMMANDLITERAL);
|
||||
sc.SetState(SCE_JULIA_DEFAULT);
|
||||
@ -882,13 +895,13 @@ void SCI_METHOD LexerJulia::Lex(Sci_PositionU startPos, Sci_Position length, int
|
||||
} else if (! IsIdentifierCharacter(sc.ch)) {
|
||||
char s[MAX_JULIA_IDENT_CHARS + 1];
|
||||
sc.GetCurrent(s, sizeof(s));
|
||||
|
||||
|
||||
// Treat the keywords differently if we are indexing or not
|
||||
if ( indexing_level > 0 && CheckBoundsIndexing(s)) {
|
||||
// Inside [], (), `begin` and `end` are numbers not block keywords
|
||||
sc.ChangeState(SCE_JULIA_NUMBER);
|
||||
transpose = false;
|
||||
|
||||
|
||||
} else {
|
||||
// Ignore the last index of NUM_JULIA_KEYWORD_LISTS that is
|
||||
// used for Raw string literals.
|
||||
@ -915,22 +928,22 @@ void SCI_METHOD LexerJulia::Lex(Sci_PositionU startPos, Sci_Position length, int
|
||||
resumeCharacter(sc, options.highlightLexerror);
|
||||
break;
|
||||
case SCE_JULIA_DOCSTRING:
|
||||
resumeString(sc, true, !israwstring);
|
||||
resumeString(sc, true, options.stringInterpolation && !israwstring);
|
||||
if (sc.state == SCE_JULIA_DEFAULT && israwstring) {
|
||||
israwstring = false;
|
||||
}
|
||||
break;
|
||||
case SCE_JULIA_STRING:
|
||||
resumeString(sc, false, !israwstring);
|
||||
resumeString(sc, false, options.stringInterpolation && !israwstring);
|
||||
if (sc.state == SCE_JULIA_DEFAULT && israwstring) {
|
||||
israwstring = false;
|
||||
}
|
||||
break;
|
||||
case SCE_JULIA_COMMAND:
|
||||
resumeCommand(sc, triple_backtick, true);
|
||||
resumeCommand(sc, triple_backtick, options.stringInterpolation);
|
||||
break;
|
||||
case SCE_JULIA_MACRO:
|
||||
if (isspace(sc.ch) || ! IsIdentifierCharacter(sc.ch)) {
|
||||
if (IsASpace(sc.ch) || ! IsIdentifierCharacter(sc.ch)) {
|
||||
sc.SetState(SCE_JULIA_DEFAULT);
|
||||
}
|
||||
break;
|
||||
@ -970,13 +983,14 @@ void SCI_METHOD LexerJulia::Lex(Sci_PositionU startPos, Sci_Position length, int
|
||||
// check start of a new state
|
||||
if (sc.state == SCE_JULIA_DEFAULT) {
|
||||
if (sc.ch == '#') {
|
||||
sc.SetState(SCE_JULIA_COMMENT);
|
||||
// increment depth if we are a block comment
|
||||
if(sc.chNext == '=') {
|
||||
commentDepth ++;
|
||||
sc.Forward();
|
||||
}
|
||||
curLine = styler.GetLine(sc.currentPos);
|
||||
styler.SetLineState(curLine, commentDepth);
|
||||
sc.SetState(SCE_JULIA_COMMENT);
|
||||
} else if (sc.ch == '!') {
|
||||
sc.SetState(SCE_JULIA_OPERATOR);
|
||||
} else if (sc.ch == '\'') {
|
||||
@ -1007,7 +1021,7 @@ void SCI_METHOD LexerJulia::Lex(Sci_PositionU startPos, Sci_Position length, int
|
||||
sc.Forward();
|
||||
}
|
||||
}
|
||||
} else if (isdigit(sc.ch) || (sc.ch == '.' && isdigit(sc.chNext))) {
|
||||
} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
|
||||
base = 10;
|
||||
with_dot = false;
|
||||
transpose = true;
|
||||
@ -1095,7 +1109,7 @@ void SCI_METHOD LexerJulia::Fold(Sci_PositionU startPos, Sci_Position length, in
|
||||
|
||||
LexAccessor styler(pAccess);
|
||||
|
||||
// level of nested brackets
|
||||
// level of nested brackets
|
||||
int indexing_level = 0;
|
||||
// level of nested parenthesis or brackets
|
||||
int list_comprehension = 0;
|
||||
@ -1134,47 +1148,49 @@ void SCI_METHOD LexerJulia::Fold(Sci_PositionU startPos, Sci_Position length, in
|
||||
}
|
||||
}
|
||||
|
||||
// list comprehension allow `for`/`if` without `end`
|
||||
if (style == SCE_JULIA_BRACKET) {
|
||||
if (ch == '[') {
|
||||
list_comprehension ++;
|
||||
indexing_level ++;
|
||||
levelNext ++;
|
||||
} else if (ch == ']') {
|
||||
list_comprehension --;
|
||||
indexing_level --;
|
||||
levelNext --;
|
||||
} else if (ch == '(') {
|
||||
list_comprehension ++;
|
||||
levelNext ++;
|
||||
} else if (ch == ')') {
|
||||
list_comprehension --;
|
||||
levelNext --;
|
||||
}
|
||||
// check non-negative
|
||||
if (indexing_level < 0) {
|
||||
indexing_level = 0;
|
||||
}
|
||||
if (list_comprehension < 0) {
|
||||
list_comprehension = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// keyword
|
||||
if (style == SCE_JULIA_KEYWORD1) {
|
||||
word[wordlen++] = static_cast<char>(ch);
|
||||
if (wordlen == 100) { // prevent overflow
|
||||
word[0] = '\0';
|
||||
wordlen = 1;
|
||||
}
|
||||
if (styleNext != SCE_JULIA_KEYWORD1) {
|
||||
word[wordlen] = '\0';
|
||||
wordlen = 0;
|
||||
if (list_comprehension <= 0 && indexing_level <= 0) {
|
||||
levelNext += CheckKeywordFoldPoint(word);
|
||||
// Syntax based folding, accounts for list comprehension
|
||||
if (options.foldSyntaxBased) {
|
||||
// list comprehension allow `for`, `if` and `begin` without `end`
|
||||
if (style == SCE_JULIA_BRACKET) {
|
||||
if (ch == '[') {
|
||||
list_comprehension ++;
|
||||
indexing_level ++;
|
||||
levelNext ++;
|
||||
} else if (ch == ']') {
|
||||
list_comprehension --;
|
||||
indexing_level --;
|
||||
levelNext --;
|
||||
} else if (ch == '(') {
|
||||
list_comprehension ++;
|
||||
levelNext ++;
|
||||
} else if (ch == ')') {
|
||||
list_comprehension --;
|
||||
levelNext --;
|
||||
}
|
||||
// check non-negative
|
||||
if (indexing_level < 0) {
|
||||
indexing_level = 0;
|
||||
}
|
||||
if (list_comprehension < 0) {
|
||||
list_comprehension = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// keyword
|
||||
if (style == SCE_JULIA_KEYWORD1) {
|
||||
word[wordlen++] = static_cast<char>(ch);
|
||||
if (wordlen == 100) { // prevent overflow
|
||||
word[0] = '\0';
|
||||
wordlen = 1;
|
||||
}
|
||||
if (styleNext != SCE_JULIA_KEYWORD1) {
|
||||
word[wordlen] = '\0';
|
||||
wordlen = 0;
|
||||
if (list_comprehension <= 0 && indexing_level <= 0) {
|
||||
levelNext += CheckKeywordFoldPoint(word);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Docstring
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
<assemblyIdentity
|
||||
name="Rizonesoft.Notepad3"
|
||||
processorArchitecture="*"
|
||||
version="5.21.527.1"
|
||||
version="5.21.527.2"
|
||||
type="win32"
|
||||
/>
|
||||
<description>Notepad3 beta</description>
|
||||
<description>Notepad3 alpha</description>
|
||||
</assembly>
|
||||
|
||||
@ -9,12 +9,12 @@
|
||||
#define VERSION_MAJOR 5
|
||||
#define VERSION_MINOR 21
|
||||
#define VERSION_REV 527
|
||||
#define VERSION_BUILD 1
|
||||
#define VERSION_BUILD 2
|
||||
#define SCINTILLA_VER 502
|
||||
#define LEXILLA_VER 502
|
||||
#define ONIGURUMA_REGEX_VER 7.0.0
|
||||
#define UCHARDET_VER 2018.09.27
|
||||
#define TINYEXPR_VER 2018.05.11
|
||||
#define UTHASH_VER 2.1.0
|
||||
#define VERSION_PATCH beta
|
||||
#define VERSION_COMMIT_ID dkt1-amr
|
||||
#define VERSION_PATCH alpha
|
||||
#define VERSION_COMMIT_ID nebukadn
|
||||
|
||||
Loading…
Reference in New Issue
Block a user