Add support for double-quotes inside strings
This commit is contained in:
parent
ec82f7b2cf
commit
d6ea15a3e0
|
|
@ -115,7 +115,7 @@ module.exports = grammar({
|
||||||
identifier: $ =>
|
identifier: $ =>
|
||||||
/[a-zA-Z\u{80}-\u{10FFFF}][0-9a-zA-Z_\u{80}-\u{10FFFF}]*/u,
|
/[a-zA-Z\u{80}-\u{10FFFF}][0-9a-zA-Z_\u{80}-\u{10FFFF}]*/u,
|
||||||
comment: $ => token(seq('--', /.*/)),
|
comment: $ => token(seq('--', /.*/)),
|
||||||
string_literal: $ => token(/"[^"]*"/),
|
string_literal: $ => token(/"(""|[^"])*"/),
|
||||||
character_literal: $ => token(/'.'/),
|
character_literal: $ => token(/'.'/),
|
||||||
numeric_literal: $ => token(
|
numeric_literal: $ => token(
|
||||||
choice(
|
choice(
|
||||||
|
|
|
||||||
|
|
@ -113,8 +113,8 @@
|
||||||
(use_clause "use" @include "type" @include)
|
(use_clause "use" @include "type" @include)
|
||||||
(with_clause "private" @include)
|
(with_clause "private" @include)
|
||||||
(with_clause "limited" @include)
|
(with_clause "limited" @include)
|
||||||
(use_clause (identifier) @namespace)
|
(use_clause (_) @namespace)
|
||||||
(with_clause (identifier) @namespace)
|
(with_clause (_) @namespace)
|
||||||
|
|
||||||
(loop_statement "end" @keyword.repeat)
|
(loop_statement "end" @keyword.repeat)
|
||||||
(if_statement "end" @conditional)
|
(if_statement "end" @conditional)
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
"type": "TOKEN",
|
"type": "TOKEN",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
"value": "\"[^\"]*\""
|
"value": "\"(\"\"|[^\"])*\""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"character_literal": {
|
"character_literal": {
|
||||||
|
|
|
||||||
|
|
@ -5854,6 +5854,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
|
||||||
END_STATE();
|
END_STATE();
|
||||||
case 37:
|
case 37:
|
||||||
ACCEPT_TOKEN(sym_string_literal);
|
ACCEPT_TOKEN(sym_string_literal);
|
||||||
|
if (lookahead == '"') ADVANCE(8);
|
||||||
END_STATE();
|
END_STATE();
|
||||||
case 38:
|
case 38:
|
||||||
ACCEPT_TOKEN(sym_character_literal);
|
ACCEPT_TOKEN(sym_character_literal);
|
||||||
|
|
|
||||||
34
test/corpus/literals.txt
Normal file
34
test/corpus/literals.txt
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
================================================================================
|
||||||
|
String literals
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
A : String := "12'34";
|
||||||
|
|
||||||
|
--------
|
||||||
|
|
||||||
|
(compilation
|
||||||
|
(compilation_unit
|
||||||
|
(object_declaration
|
||||||
|
(identifier)
|
||||||
|
(identifier)
|
||||||
|
(expression
|
||||||
|
(term
|
||||||
|
(string_literal))))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
String literals with quotes
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
A : String := "12""23";
|
||||||
|
|
||||||
|
--------
|
||||||
|
|
||||||
|
(compilation
|
||||||
|
(compilation_unit
|
||||||
|
(object_declaration
|
||||||
|
(identifier)
|
||||||
|
(identifier)
|
||||||
|
(expression
|
||||||
|
(term
|
||||||
|
(string_literal))))))
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user