Skip to content

Commit 989c549

Browse files
committed
#220 Add SCE_ASM_STRINGBACKQUOTE for NASM back-quoted strings.
1 parent 0329ee7 commit 989c549

File tree

8 files changed

+35
-0
lines changed

8 files changed

+35
-0
lines changed

doc/LexillaHistory.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,10 @@ <h3>
605605
Released 26 March 2026.
606606
</li>
607607
<li>
608+
Assembler: Add SCE_ASM_STRINGBACKQUOTE for NASM `back-quoted strings`.
609+
<a href="https://github.com/ScintillaOrg/lexilla/issues/220">Issue #220</a>.
610+
</li>
611+
<li>
608612
C++: Fold for '#pragma region' and '#pragma endregion'.
609613
<a href="https://github.com/ScintillaOrg/lexilla/issues/324">Issue #324</a>.
610614
</li>

include/LexicalStyles.iface

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,7 @@ val SCE_ASM_CHARACTER=12
844844
val SCE_ASM_STRINGEOL=13
845845
val SCE_ASM_EXTINSTRUCTION=14
846846
val SCE_ASM_COMMENTDIRECTIVE=15
847+
val SCE_ASM_STRINGBACKQUOTE=16
847848
# Lexical states for SCLEX_FORTRAN
848849
lex Fortran=SCLEX_FORTRAN SCE_F_
849850
lex F77=SCLEX_F77 SCE_F_

include/SciLexer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@
760760
#define SCE_ASM_STRINGEOL 13
761761
#define SCE_ASM_EXTINSTRUCTION 14
762762
#define SCE_ASM_COMMENTDIRECTIVE 15
763+
#define SCE_ASM_STRINGBACKQUOTE 16
763764
#define SCE_F_DEFAULT 0
764765
#define SCE_F_COMMENT 1
765766
#define SCE_F_NUMBER 2

lexers/LexAsm.cxx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ const LexicalClass lexicalClassesAsm[] = {
143143
13, "SCE_ASM_STRINGEOL", "error literal string", "End of line where string is not closed",
144144
14, "SCE_ASM_EXTINSTRUCTION", "keyword", "Extended Instruction",
145145
15, "SCE_ASM_COMMENTDIRECTIVE", "comment", "Directive Comment",
146+
16, "SCE_ASM_STRINGBACKQUOTE", "literal string", "Back quoted string",
146147
};
147148

148149
const LexicalClass lexicalClassesAs[] = {
@@ -163,6 +164,7 @@ const LexicalClass lexicalClassesAs[] = {
163164
13, "SCE_ASM_STRINGEOL", "error literal string", "End of line where string is not closed",
164165
14, "SCE_ASM_EXTINSTRUCTION", "keyword", "Extended Instruction",
165166
15, "SCE_ASM_COMMENTDIRECTIVE", "comment", "Directive Comment",
167+
16, "SCE_ASM_STRINGBACKQUOTE", "literal string", "Back quoted string",
166168
};
167169

168170
class LexerAsm : public DefaultLexer {
@@ -287,6 +289,7 @@ void SCI_METHOD LexerAsm::Lex(Sci_PositionU startPos, Sci_Position length, int i
287289
switch (sc.state) {
288290
case SCE_ASM_STRING:
289291
case SCE_ASM_CHARACTER:
292+
case SCE_ASM_STRINGBACKQUOTE:
290293
// Prevent SCE_ASM_STRINGEOL from leaking back to previous line
291294
sc.SetState(sc.state);
292295
break;
@@ -390,6 +393,19 @@ void SCI_METHOD LexerAsm::Lex(Sci_PositionU startPos, Sci_Position length, int i
390393
}
391394
break;
392395

396+
case SCE_ASM_STRINGBACKQUOTE:
397+
if (sc.ch == '\\') {
398+
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\' || sc.chNext == '`') {
399+
sc.Forward();
400+
}
401+
} else if (sc.ch == '`') {
402+
sc.ForwardSetState(SCE_ASM_DEFAULT);
403+
} else if (sc.atLineEnd) {
404+
sc.ChangeState(SCE_ASM_STRINGEOL);
405+
sc.ForwardSetState(SCE_ASM_DEFAULT);
406+
}
407+
break;
408+
393409
default:
394410
break;
395411
}
@@ -406,6 +422,8 @@ void SCI_METHOD LexerAsm::Lex(Sci_PositionU startPos, Sci_Position length, int i
406422
sc.SetState(SCE_ASM_STRING);
407423
} else if (sc.ch == '\'') {
408424
sc.SetState(SCE_ASM_CHARACTER);
425+
} else if (sc.ch == '`') {
426+
sc.SetState(SCE_ASM_STRINGBACKQUOTE);
409427
} else if (IsAsmOperator(sc.ch)) {
410428
sc.SetState(SCE_ASM_OPERATOR);
411429
}

test/Metadata/lexerMetadata.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ Lexer as
217217
13 SCE_ASM_STRINGEOL [error literal string] End of line where string is not closed
218218
14 SCE_ASM_EXTINSTRUCTION [keyword] Extended Instruction
219219
15 SCE_ASM_COMMENTDIRECTIVE [comment] Directive Comment
220+
16 SCE_ASM_STRINGBACKQUOTE [literal string] Back quoted string
220221

221222
Lexer asciidoc
222223

@@ -266,6 +267,7 @@ Lexer asm
266267
13 SCE_ASM_STRINGEOL [error literal string] End of line where string is not closed
267268
14 SCE_ASM_EXTINSTRUCTION [keyword] Extended Instruction
268269
15 SCE_ASM_COMMENTDIRECTIVE [comment] Directive Comment
270+
16 SCE_ASM_STRINGBACKQUOTE [literal string] Back quoted string
269271

270272
Lexer asn1
271273
Word Lists:

test/examples/asm/AllStyles.asm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ movq
4949
comment ~ A multiple-line
5050
comment directive~
5151

52+
; back quoted string=16
53+
`back-quoted-string`
54+
5255
; test for folding from segment to ends
5356
data segment
5457
hw db "HW!"

test/examples/asm/AllStyles.asm.folded

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
0 400 400 comment ~ A multiple-line
5050
0 400 400 comment directive~
5151
1 400 400
52+
0 400 400 ; back quoted string=16
53+
0 400 400 `back-quoted-string`
54+
1 400 400
5255
0 400 400 ; test for folding from segment to ends
5356
2 400 401 + data segment
5457
0 401 401 | hw db "HW!"

test/examples/asm/AllStyles.asm.styled

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
{0} {9}comment{0} {15}~ A multiple-line
5050
comment directive~{0}
5151

52+
{1}; back quoted string=16
53+
{16}`back-quoted-string`{0}
54+
5255
{1}; test for folding from segment to ends
5356
{5}data{0} {9}segment{0}
5457
{5}hw{0} {9}db{0} {3}"HW!"{0}

0 commit comments

Comments
 (0)