Skip to content

Commit

Permalink
#83 Visual Prolog: Treat \r\n line ends the same as \n. This makes te…
Browse files Browse the repository at this point in the history
…sting easier.

Add test case.
  • Loading branch information
rdipardo authored and nyamatongwe committed May 27, 2022
1 parent 7458c29 commit 3d02c15
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 6 deletions.
14 changes: 14 additions & 0 deletions doc/LexillaHistory.html
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,20 @@ <h2>Contributors</h2>
</tr>
</table>
<h2>Releases</h2>
<h3>
<a href="https://www.scintilla.org/lexilla519.zip">Release 5.1.8</a>
</h3>
<ul>
<li>
Released 22 May 2022.
</li>
<li>
Visual Prolog: Treat \r\n line ends the same as \n. This makes testing easier.
Add test case.
<a href="https://github.com/ScintillaOrg/lexilla/issues/83">Issue #83</a>.
</li>
</ul>
<h2>Releases</h2>
<h3>
<a href="https://www.scintilla.org/lexilla517.zip">Release 5.1.7</a>
</h3>
Expand Down
14 changes: 8 additions & 6 deletions lexers/LexVisualProlog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ void SCI_METHOD LexerVisualProlog::Lex(Sci_PositionU startPos, Sci_Position leng
}
break;
case SCE_VISUALPROLOG_COMMENT_LINE:
if (sc.atLineEnd) {
if (sc.MatchLineEnd()) {
int nextState = (nestLevel == 0) ? SCE_VISUALPROLOG_DEFAULT : SCE_VISUALPROLOG_COMMENT_BLOCK;
sc.SetState(nextState);
} else if (sc.Match('@')) {
Expand All @@ -342,13 +342,13 @@ void SCI_METHOD LexerVisualProlog::Lex(Sci_PositionU startPos, Sci_Position leng
}
break;
case SCE_VISUALPROLOG_COMMENT_KEY_ERROR:
if (!setDoxygen.Contains(sc.ch) || sc.atLineEnd) {
if (!setDoxygen.Contains(sc.ch) || sc.MatchLineEnd()) {
char s[1000];
sc.GetCurrent(s, sizeof(s));
if (docKeywords.InList(s+1)) {
sc.ChangeState(SCE_VISUALPROLOG_COMMENT_KEY);
}
if (SCE_VISUALPROLOG_COMMENT_LINE == styleBeforeDocKeyword && sc.atLineEnd) {
if (SCE_VISUALPROLOG_COMMENT_LINE == styleBeforeDocKeyword && sc.MatchLineEnd()) {
// end line comment
int nextState = (nestLevel == 0) ? SCE_VISUALPROLOG_DEFAULT : SCE_VISUALPROLOG_COMMENT_BLOCK;
sc.SetState(nextState);
Expand All @@ -372,7 +372,7 @@ void SCI_METHOD LexerVisualProlog::Lex(Sci_PositionU startPos, Sci_Position leng
sc.SetState(SCE_VISUALPROLOG_STRING);
// Falls through.
case SCE_VISUALPROLOG_STRING:
if (sc.atLineEnd) {
if (sc.MatchLineEnd()) {
sc.SetState(SCE_VISUALPROLOG_STRING_EOL_OPEN);
} else if (sc.Match(closingQuote)) {
sc.ForwardSetState(SCE_VISUALPROLOG_DEFAULT);
Expand All @@ -388,11 +388,13 @@ void SCI_METHOD LexerVisualProlog::Lex(Sci_PositionU startPos, Sci_Position leng
break;
case SCE_VISUALPROLOG_STRING_VERBATIM_SPECIAL:
case SCE_VISUALPROLOG_STRING_VERBATIM_EOL:
if(sc.state == SCE_VISUALPROLOG_STRING_VERBATIM_EOL && !sc.atLineStart)
break;
// return to SCE_VISUALPROLOG_STRING_VERBATIM and treat as such (fall-through)
sc.SetState(SCE_VISUALPROLOG_STRING_VERBATIM);
// Falls through.
case SCE_VISUALPROLOG_STRING_VERBATIM:
if (sc.atLineEnd) {
if (sc.MatchLineEnd()) {
sc.SetState(SCE_VISUALPROLOG_STRING_VERBATIM_EOL);
} else if (sc.Match(closingQuote)) {
if (closingQuote == sc.chNext) {
Expand All @@ -405,7 +407,7 @@ void SCI_METHOD LexerVisualProlog::Lex(Sci_PositionU startPos, Sci_Position leng
break;
}

if (sc.atLineEnd) {
if (sc.MatchLineEnd()) {
// Update the line state, so it can be seen by next line
int lineState = 0;
if (SCE_VISUALPROLOG_STRING_VERBATIM_EOL == sc.state) {
Expand Down
52 changes: 52 additions & 0 deletions test/examples/visualprolog/AllStyles.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
% SCE_VISUALPROLOG_KEY_MAJOR (1)
goal

% SCE_VISUALPROLOG_KEY_MINOR (2)
procedure

% SCE_VISUALPROLOG_KEY_DIRECTIVE (3)
#include

% SCE_VISUALPROLOG_COMMENT_BLOCK (4)
/**
SCE_VISUALPROLOG_COMMENT_KEY (6)
@detail
SCE_VISUALPROLOG_COMMENT_KEY_ERROR (7)
@unknown
/* SCE_VISUALPROLOG_IDENTIFIER (8)
SCE_VISUALPROLOG_VARIABLE (9)
SCE_VISUALPROLOG_ANONYMOUS (10)
SCE_VISUALPROLOG_NUMBER (11)
SCE_VISUALPROLOG_OPERATOR (12) */ */
lambda = {
(A) = { (B, _discard) = A*B+1 }
}.

% SCE_VISUALPROLOG_COMMENT_LINE (5)
% @detail
% @unknown

% SCE_VISUALPROLOG_STRING (16)
"string"
'string'

% SCE_VISUALPROLOG_STRING_ESCAPE (17)
"\n"
'\uAB12'

% SCE_VISUALPROLOG_STRING_ESCAPE_ERROR (18)
"\ "

% SCE_VISUALPROLOG_STRING_EOL_OPEN (19)
"open string

% SCE_VISUALPROLOG_STRING_VERBATIM (20)
@"verbatim string"

% SCE_VISUALPROLOG_STRING_VERBATIM_SPECIAL (21)
@"""special"" verbatim string"

% SCE_VISUALPROLOG_STRING_VERBATIM_EOL (22)
@"multi-line
verbatim
string"
53 changes: 53 additions & 0 deletions test/examples/visualprolog/AllStyles.pro.folded
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
0 400 400 % SCE_VISUALPROLOG_KEY_MAJOR (1)
0 400 400 goal
0 400 400
0 400 400 % SCE_VISUALPROLOG_KEY_MINOR (2)
0 400 400 procedure
0 400 400
0 400 400 % SCE_VISUALPROLOG_KEY_DIRECTIVE (3)
0 400 400 #include
0 400 400
0 400 400 % SCE_VISUALPROLOG_COMMENT_BLOCK (4)
0 400 400 /**
0 400 400 SCE_VISUALPROLOG_COMMENT_KEY (6)
0 400 400 @detail
0 400 400 SCE_VISUALPROLOG_COMMENT_KEY_ERROR (7)
0 400 400 @unknown
0 400 400 /* SCE_VISUALPROLOG_IDENTIFIER (8)
0 400 400 SCE_VISUALPROLOG_VARIABLE (9)
0 400 400 SCE_VISUALPROLOG_ANONYMOUS (10)
0 400 400 SCE_VISUALPROLOG_NUMBER (11)
0 400 400 SCE_VISUALPROLOG_OPERATOR (12) */ */
2 400 401 + lambda = {
0 401 401 | (A) = { (B, _discard) = A*B+1 }
0 401 400 | }.
0 400 400
0 400 400 % SCE_VISUALPROLOG_COMMENT_LINE (5)
0 400 400 % @detail
0 400 400 % @unknown
0 400 400
0 400 400 % SCE_VISUALPROLOG_STRING (16)
0 400 400 "string"
0 400 400 'string'
0 400 400
0 400 400 % SCE_VISUALPROLOG_STRING_ESCAPE (17)
0 400 400 "\n"
0 400 400 '\uAB12'
0 400 400
0 400 400 % SCE_VISUALPROLOG_STRING_ESCAPE_ERROR (18)
0 400 400 "\ "
0 400 400
0 400 400 % SCE_VISUALPROLOG_STRING_EOL_OPEN (19)
0 400 400 "open string
0 400 400
0 400 400 % SCE_VISUALPROLOG_STRING_VERBATIM (20)
0 400 400 @"verbatim string"
0 400 400
0 400 400 % SCE_VISUALPROLOG_STRING_VERBATIM_SPECIAL (21)
0 400 400 @"""special"" verbatim string"
0 400 400
0 400 400 % SCE_VISUALPROLOG_STRING_VERBATIM_EOL (22)
0 400 400 @"multi-line
0 400 400 verbatim
0 400 400 string"
1 400 400
52 changes: 52 additions & 0 deletions test/examples/visualprolog/AllStyles.pro.styled
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{5}% SCE_VISUALPROLOG_KEY_MAJOR (1){0}
{1}goal{0}

{5}% SCE_VISUALPROLOG_KEY_MINOR (2){0}
{2}procedure{0}

{5}% SCE_VISUALPROLOG_KEY_DIRECTIVE (3){0}
{3}#include{0}

{5}% SCE_VISUALPROLOG_COMMENT_BLOCK (4){0}
{4}/**
SCE_VISUALPROLOG_COMMENT_KEY (6)
{6}@detail{4}
SCE_VISUALPROLOG_COMMENT_KEY_ERROR (7)
{7}@unknown{4}
/* SCE_VISUALPROLOG_IDENTIFIER (8)
SCE_VISUALPROLOG_VARIABLE (9)
SCE_VISUALPROLOG_ANONYMOUS (10)
SCE_VISUALPROLOG_NUMBER (11)
SCE_VISUALPROLOG_OPERATOR (12) */ */{0}
{8}lambda{0} {12}={0} {12}{{0}
{12}({9}A{12}){0} {12}={0} {12}{{0} {12}({9}B{12},{0} {10}_discard{12}){0} {12}={0} {9}A{12}*{9}B{12}+{11}1{0} {12}}{0}
{12}}.{0}

{5}% SCE_VISUALPROLOG_COMMENT_LINE (5){0}
{5}% {6}@detail{0}
{5}% {7}@unknown{0}

{5}% SCE_VISUALPROLOG_STRING (16){0}
{16}"string"{0}
{16}'string'{0}

{5}% SCE_VISUALPROLOG_STRING_ESCAPE (17){0}
{16}"{17}\n{16}"{0}
{16}'{17}\uAB12{16}'{0}

{5}% SCE_VISUALPROLOG_STRING_ESCAPE_ERROR (18){0}
{16}"{18}\ {16}"{0}

{5}% SCE_VISUALPROLOG_STRING_EOL_OPEN (19){0}
{16}"open string{19}
{0}
{5}% SCE_VISUALPROLOG_STRING_VERBATIM (20){0}
{20}@"verbatim string"{0}

{5}% SCE_VISUALPROLOG_STRING_VERBATIM_SPECIAL (21){0}
{20}@"{21}""{20}special{21}""{20} verbatim string"{0}

{5}% SCE_VISUALPROLOG_STRING_VERBATIM_EOL (22){0}
{20}@"multi-line{22}
{20} verbatim{22}
{20} string"{0}
19 changes: 19 additions & 0 deletions test/examples/visualprolog/SciTE.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
lexer.*.pro=visualprolog
fold=1

# major keywords
keywords.*.pro=goal namespace interface class implement open inherits supports resolve delegate \
monitor constants domains predicates constructors properties clauses facts

# minor keywords
keywords2.*.pro=any binary binaryNonAtomic boolean char compareResult factDB guard handle integer64 \
integerNative language null pointer real real32 stdcall string8 symbol apicall c thiscall prolog \
digits if then elseif else endif foreach do try catch finally erroneous failure procedure determ multi \
nondeterm anyflow and or externally from div mod rem quot in orelse otherwise unsigned unsigned64 \
unsignedNative

# directives
keywords3.*.pro=include bininclude requires orrequires error message export externally options

# documentation keywords
keywords4.*.pro=short detail end exception withdomain

0 comments on commit 3d02c15

Please sign in to comment.