Skip to content

Commit

Permalink
Merge pull request #124 (Expose string-content)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Jul 29, 2024
2 parents 9cd6438 + bdedf39 commit 8cf7f01
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 64 deletions.
4 changes: 2 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ module.exports = grammar({
$.multiline_comment,
$._string_start,
$._string_end,
$._string_content,
$.string_content,
],

extras: $ => [
Expand Down Expand Up @@ -764,7 +764,7 @@ module.exports = grammar({

string_literal: $ => seq(
$._string_start,
repeat(choice($._string_content, $._interpolation)),
repeat(choice($.string_content, $._interpolation)),
$._string_end,
),

Expand Down
4 changes: 2 additions & 2 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -3834,7 +3834,7 @@
"members": [
{
"type": "SYMBOL",
"name": "_string_content"
"name": "string_content"
},
{
"type": "SYMBOL",
Expand Down Expand Up @@ -6377,7 +6377,7 @@
},
{
"type": "SYMBOL",
"name": "_string_content"
"name": "string_content"
}
],
"inline": [],
Expand Down
8 changes: 8 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -7828,6 +7828,10 @@
{
"type": "interpolated_identifier",
"named": true
},
{
"type": "string_content",
"named": true
}
]
}
Expand Down Expand Up @@ -9524,6 +9528,10 @@
"type": "setparam",
"named": false
},
{
"type": "string_content",
"named": true
},
{
"type": "super",
"named": false
Expand Down
54 changes: 27 additions & 27 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ enum ts_symbol_identifiers {
sym_multiline_comment = 149,
sym__string_start = 150,
sym__string_end = 151,
sym__string_content = 152,
sym_string_content = 152,
sym_source_file = 153,
sym_shebang_line = 154,
sym_file_annotation = 155,
Expand Down Expand Up @@ -537,7 +537,7 @@ static const char * const ts_symbol_names[] = {
[sym_multiline_comment] = "multiline_comment",
[sym__string_start] = "_string_start",
[sym__string_end] = "_string_end",
[sym__string_content] = "_string_content",
[sym_string_content] = "string_content",
[sym_source_file] = "source_file",
[sym_shebang_line] = "shebang_line",
[sym_file_annotation] = "file_annotation",
Expand Down Expand Up @@ -899,7 +899,7 @@ static const TSSymbol ts_symbol_map[] = {
[sym_multiline_comment] = sym_multiline_comment,
[sym__string_start] = sym__string_start,
[sym__string_end] = sym__string_end,
[sym__string_content] = sym__string_content,
[sym_string_content] = sym_string_content,
[sym_source_file] = sym_source_file,
[sym_shebang_line] = sym_shebang_line,
[sym_file_annotation] = sym_file_annotation,
Expand Down Expand Up @@ -1717,8 +1717,8 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
.visible = false,
.named = true,
},
[sym__string_content] = {
.visible = false,
[sym_string_content] = {
.visible = true,
.named = true,
},
[sym_source_file] = {
Expand Down Expand Up @@ -30427,7 +30427,7 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
[sym_multiline_comment] = ACTIONS(3),
[sym__string_start] = ACTIONS(1),
[sym__string_end] = ACTIONS(1),
[sym__string_content] = ACTIONS(1),
[sym_string_content] = ACTIONS(1),
},
[1] = {
[sym_source_file] = STATE(10064),
Expand Down Expand Up @@ -651559,7 +651559,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(10827), 1,
sym__string_end,
ACTIONS(10829), 1,
sym__string_content,
sym_string_content,
ACTIONS(3), 2,
sym_multiline_comment,
sym_line_comment,
Expand Down Expand Up @@ -651626,7 +651626,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(10834), 1,
sym__string_end,
ACTIONS(10836), 1,
sym__string_content,
sym_string_content,
ACTIONS(3), 2,
sym_multiline_comment,
sym_line_comment,
Expand Down Expand Up @@ -651695,7 +651695,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(10825), 1,
anon_sym_DOLLAR,
ACTIONS(10829), 1,
sym__string_content,
sym_string_content,
ACTIONS(10838), 1,
sym__string_end,
ACTIONS(3), 2,
Expand Down Expand Up @@ -651782,7 +651782,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(10825), 1,
anon_sym_DOLLAR,
ACTIONS(10829), 1,
sym__string_content,
sym_string_content,
ACTIONS(10844), 1,
sym__string_end,
ACTIONS(3), 2,
Expand Down Expand Up @@ -651825,7 +651825,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(10846), 1,
sym__string_end,
ACTIONS(10848), 1,
sym__string_content,
sym_string_content,
ACTIONS(3), 2,
sym_multiline_comment,
sym_line_comment,
Expand Down Expand Up @@ -651855,7 +651855,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(10850), 1,
sym__string_end,
ACTIONS(10852), 1,
sym__string_content,
sym_string_content,
ACTIONS(3), 2,
sym_multiline_comment,
sym_line_comment,
Expand All @@ -651870,7 +651870,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(10860), 1,
sym__string_end,
ACTIONS(10862), 1,
sym__string_content,
sym_string_content,
ACTIONS(3), 2,
sym_multiline_comment,
sym_line_comment,
Expand Down Expand Up @@ -651900,7 +651900,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(10865), 1,
sym__string_end,
ACTIONS(10867), 1,
sym__string_content,
sym_string_content,
ACTIONS(3), 2,
sym_multiline_comment,
sym_line_comment,
Expand Down Expand Up @@ -651988,7 +651988,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(10871), 1,
sym__string_end,
ACTIONS(10873), 1,
sym__string_content,
sym_string_content,
ACTIONS(3), 2,
sym_multiline_comment,
sym_line_comment,
Expand Down Expand Up @@ -652031,7 +652031,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(10825), 1,
anon_sym_DOLLAR,
ACTIONS(10829), 1,
sym__string_content,
sym_string_content,
ACTIONS(10875), 1,
sym__string_end,
ACTIONS(3), 2,
Expand Down Expand Up @@ -652177,7 +652177,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(10825), 1,
anon_sym_DOLLAR,
ACTIONS(10829), 1,
sym__string_content,
sym_string_content,
ACTIONS(10885), 1,
sym__string_end,
ACTIONS(3), 2,
Expand Down Expand Up @@ -652221,7 +652221,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(10890), 1,
sym__string_end,
ACTIONS(10892), 1,
sym__string_content,
sym_string_content,
ACTIONS(3), 2,
sym_multiline_comment,
sym_line_comment,
Expand Down Expand Up @@ -652250,7 +652250,7 @@ static const uint16_t ts_small_parse_table[] = {
ACTIONS(10825), 1,
anon_sym_DOLLAR,
ACTIONS(10829), 1,
sym__string_content,
sym_string_content,
ACTIONS(10894), 1,
sym__string_end,
ACTIONS(3), 2,
Expand Down Expand Up @@ -654722,7 +654722,7 @@ static const uint16_t ts_small_parse_table[] = {
sym_line_comment,
ACTIONS(4035), 3,
sym__string_end,
sym__string_content,
sym_string_content,
anon_sym_DOLLAR_LBRACE,
[213433] = 2,
ACTIONS(3), 2,
Expand All @@ -654741,7 +654741,7 @@ static const uint16_t ts_small_parse_table[] = {
sym_line_comment,
ACTIONS(4192), 3,
sym__string_end,
sym__string_content,
sym_string_content,
anon_sym_DOLLAR_LBRACE,
[213457] = 5,
ACTIONS(8112), 1,
Expand Down Expand Up @@ -655494,7 +655494,7 @@ static const uint16_t ts_small_parse_table[] = {
sym_line_comment,
ACTIONS(11248), 3,
sym__string_end,
sym__string_content,
sym_string_content,
anon_sym_DOLLAR_LBRACE,
[214508] = 4,
ACTIONS(8530), 1,
Expand Down Expand Up @@ -655993,7 +655993,7 @@ static const uint16_t ts_small_parse_table[] = {
sym_line_comment,
ACTIONS(11268), 3,
sym__string_end,
sym__string_content,
sym_string_content,
anon_sym_DOLLAR_LBRACE,
[215205] = 4,
ACTIONS(8530), 1,
Expand Down Expand Up @@ -678311,7 +678311,7 @@ enum ts_external_scanner_symbol_identifiers {
ts_external_token_multiline_comment = 3,
ts_external_token__string_start = 4,
ts_external_token__string_end = 5,
ts_external_token__string_content = 6,
ts_external_token_string_content = 6,
};

static const TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = {
Expand All @@ -678321,7 +678321,7 @@ static const TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = {
[ts_external_token_multiline_comment] = sym_multiline_comment,
[ts_external_token__string_start] = sym__string_start,
[ts_external_token__string_end] = sym__string_end,
[ts_external_token__string_content] = sym__string_content,
[ts_external_token_string_content] = sym_string_content,
};

static const bool ts_external_scanner_states[12][EXTERNAL_TOKEN_COUNT] = {
Expand All @@ -678332,7 +678332,7 @@ static const bool ts_external_scanner_states[12][EXTERNAL_TOKEN_COUNT] = {
[ts_external_token_multiline_comment] = true,
[ts_external_token__string_start] = true,
[ts_external_token__string_end] = true,
[ts_external_token__string_content] = true,
[ts_external_token_string_content] = true,
},
[2] = {
[ts_external_token_multiline_comment] = true,
Expand Down Expand Up @@ -678373,7 +678373,7 @@ static const bool ts_external_scanner_states[12][EXTERNAL_TOKEN_COUNT] = {
[10] = {
[ts_external_token_multiline_comment] = true,
[ts_external_token__string_end] = true,
[ts_external_token__string_content] = true,
[ts_external_token_string_content] = true,
},
[11] = {
[ts_external_token__import_list_delimiter] = true,
Expand Down
2 changes: 1 addition & 1 deletion test/corpus/assignment.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ fun main(){
(simple_identifier)
(indexing_suffix
(integer_literal)))
(string_literal))))))
(string_literal (string_content)))))))
8 changes: 4 additions & 4 deletions test/corpus/classes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ class Strings {
(simple_identifier)
(function_value_parameters)
(function_body
(string_literal)))
(string_literal (string_content))))
(function_declaration
(simple_identifier)
(function_value_parameters)
(function_body
(additive_expression
(additive_expression
(string_literal)
(string_literal))
(string_literal)))))))
(string_literal (string_content))
(string_literal (string_content)))
(string_literal (string_content))))))))

================================================================================
Class with modifiers
Expand Down
16 changes: 8 additions & 8 deletions test/corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ sum(1, 2)
(call_suffix
(value_arguments
(value_argument
(string_literal)))))
(string_literal (string_content))))))
(call_expression
(simple_identifier)
(call_suffix
Expand Down Expand Up @@ -162,7 +162,7 @@ val MyDate.s: String get() = "hello"
(type_identifier)))
(getter
(function_body
(string_literal)))))
(string_literal (string_content))))))

================================================================================
Expect as an expression
Expand Down Expand Up @@ -429,7 +429,7 @@ val comments = """ // and here """
(call_suffix
(value_arguments
(value_argument
(string_literal))))))
(string_literal (string_content)))))))
(property_declaration
(variable_declaration
(simple_identifier))
Expand All @@ -438,7 +438,7 @@ val comments = """ // and here """
(call_suffix
(value_arguments
(value_argument
(string_literal))))))
(string_literal (string_content)))))))
(property_declaration
(variable_declaration
(simple_identifier))
Expand All @@ -447,7 +447,7 @@ val comments = """ // and here """
(call_suffix
(value_arguments
(value_argument
(string_literal))))))
(string_literal (string_content)))))))
(property_declaration
(variable_declaration
(simple_identifier))
Expand All @@ -456,15 +456,15 @@ val comments = """ // and here """
(call_suffix
(value_arguments
(value_argument
(string_literal))))))
(string_literal (string_content)))))))
(property_declaration
(variable_declaration
(simple_identifier))
(string_literal))
(string_literal (string_content)))
(property_declaration
(variable_declaration
(simple_identifier))
(string_literal)))
(string_literal (string_content))))

================================================================================
Qualified this/super expressions
Expand Down
Loading

0 comments on commit 8cf7f01

Please sign in to comment.