mirror of
https://github.com/JellyApple102/tree-sitter-dfraw.git
synced 2024-11-25 23:49:20 +02:00
add punctuation to strings
This commit is contained in:
parent
38dbfcdc11
commit
fdf2097f7f
|
@ -36,7 +36,7 @@ module.exports = grammar({
|
||||||
|
|
||||||
large: $ => /[A-Z_\d]+/,
|
large: $ => /[A-Z_\d]+/,
|
||||||
|
|
||||||
string: $ => /[A-Za-z ]+/,
|
string: $ => /[A-Za-z \-,.']+/,
|
||||||
|
|
||||||
separator: $ => /:/,
|
separator: $ => /:/,
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@
|
||||||
},
|
},
|
||||||
"string": {
|
"string": {
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
"value": "[A-Za-z ]+"
|
"value": "[A-Za-z \\-,.']+"
|
||||||
},
|
},
|
||||||
"separator": {
|
"separator": {
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
|
|
12
src/parser.c
12
src/parser.c
|
@ -181,7 +181,9 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
|
||||||
lookahead == '\r') SKIP(1)
|
lookahead == '\r') SKIP(1)
|
||||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(9);
|
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(9);
|
||||||
if (('A' <= lookahead && lookahead <= 'Z')) ADVANCE(7);
|
if (('A' <= lookahead && lookahead <= 'Z')) ADVANCE(7);
|
||||||
if (('a' <= lookahead && lookahead <= 'z')) ADVANCE(11);
|
if (lookahead == '\'' ||
|
||||||
|
(',' <= lookahead && lookahead <= '.') ||
|
||||||
|
('a' <= lookahead && lookahead <= 'z')) ADVANCE(11);
|
||||||
END_STATE();
|
END_STATE();
|
||||||
case 2:
|
case 2:
|
||||||
if (lookahead == '\t' ||
|
if (lookahead == '\t' ||
|
||||||
|
@ -217,6 +219,8 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
|
||||||
lookahead == '_') ADVANCE(8);
|
lookahead == '_') ADVANCE(8);
|
||||||
if (('A' <= lookahead && lookahead <= 'Z')) ADVANCE(7);
|
if (('A' <= lookahead && lookahead <= 'Z')) ADVANCE(7);
|
||||||
if (lookahead == ' ' ||
|
if (lookahead == ' ' ||
|
||||||
|
lookahead == '\'' ||
|
||||||
|
(',' <= lookahead && lookahead <= '.') ||
|
||||||
('a' <= lookahead && lookahead <= 'z')) ADVANCE(11);
|
('a' <= lookahead && lookahead <= 'z')) ADVANCE(11);
|
||||||
END_STATE();
|
END_STATE();
|
||||||
case 8:
|
case 8:
|
||||||
|
@ -234,11 +238,15 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
|
||||||
if (lookahead == ' ') ADVANCE(10);
|
if (lookahead == ' ') ADVANCE(10);
|
||||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(9);
|
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(9);
|
||||||
if (('A' <= lookahead && lookahead <= 'Z')) ADVANCE(7);
|
if (('A' <= lookahead && lookahead <= 'Z')) ADVANCE(7);
|
||||||
if (('a' <= lookahead && lookahead <= 'z')) ADVANCE(11);
|
if (lookahead == '\'' ||
|
||||||
|
(',' <= lookahead && lookahead <= '.') ||
|
||||||
|
('a' <= lookahead && lookahead <= 'z')) ADVANCE(11);
|
||||||
END_STATE();
|
END_STATE();
|
||||||
case 11:
|
case 11:
|
||||||
ACCEPT_TOKEN(sym_string);
|
ACCEPT_TOKEN(sym_string);
|
||||||
if (lookahead == ' ' ||
|
if (lookahead == ' ' ||
|
||||||
|
lookahead == '\'' ||
|
||||||
|
(',' <= lookahead && lookahead <= '.') ||
|
||||||
('A' <= lookahead && lookahead <= 'Z') ||
|
('A' <= lookahead && lookahead <= 'Z') ||
|
||||||
('a' <= lookahead && lookahead <= 'z')) ADVANCE(11);
|
('a' <= lookahead && lookahead <= 'z')) ADVANCE(11);
|
||||||
END_STATE();
|
END_STATE();
|
||||||
|
|
|
@ -7,6 +7,7 @@ opening_comment
|
||||||
[TEST:BODY_1PART] comment here
|
[TEST:BODY_1PART] comment here
|
||||||
[MULTIPLE:string:123:LARGE]
|
[MULTIPLE:string:123:LARGE]
|
||||||
[SINGLE_TEST]
|
[SINGLE_TEST]
|
||||||
|
[HERE:A string, contating lot's of diffent punctuation.]
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -30,4 +31,9 @@ opening_comment
|
||||||
(large)))
|
(large)))
|
||||||
(bracket_statement
|
(bracket_statement
|
||||||
(parameter_list
|
(parameter_list
|
||||||
(declaration))))
|
(declaration)))
|
||||||
|
(bracket_statement
|
||||||
|
(parameter_list
|
||||||
|
(declaration)
|
||||||
|
(separator)
|
||||||
|
(string))))
|
||||||
|
|
Loading…
Reference in New Issue