Merge pull request #6 from returntocorp/mj-explicit-extra
Disambiguate between two kinds of line continuations
This commit is contained in:
commit
7af32bc04a
|
@ -248,13 +248,17 @@ module.exports = grammar({
|
||||||
seq(
|
seq(
|
||||||
$.shell_fragment,
|
$.shell_fragment,
|
||||||
repeat(
|
repeat(
|
||||||
seq($.line_continuation, repeat($._comment_line), $.shell_fragment)
|
seq(
|
||||||
|
alias($.required_line_continuation, $.line_continuation),
|
||||||
|
repeat($._comment_line), $.shell_fragment
|
||||||
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
shell_fragment: ($) => repeat1(choice(/[^\\\[\n#\s][^\\\n]*/, /\\[^\n]/)),
|
shell_fragment: ($) => repeat1(choice(/[^\\\[\n#\s][^\\\n]*/, /\\[^\n]/)),
|
||||||
|
|
||||||
line_continuation: ($) => "\\\n",
|
line_continuation: ($) => "\\\n",
|
||||||
|
required_line_continuation: ($) => "\\\n",
|
||||||
|
|
||||||
_comment_line: ($) => seq(alias($._anon_comment, $.comment), "\n"),
|
_comment_line: ($) => seq(alias($._anon_comment, $.comment), "\n"),
|
||||||
|
|
||||||
|
|
34
src/parser.c
34
src/parser.c
|
@ -142,7 +142,7 @@ enum {
|
||||||
aux_sym_unquoted_string_repeat1 = 123,
|
aux_sym_unquoted_string_repeat1 = 123,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *ts_symbol_names[] = {
|
static const char * const ts_symbol_names[] = {
|
||||||
[ts_builtin_sym_end] = "end",
|
[ts_builtin_sym_end] = "end",
|
||||||
[anon_sym_LF] = "\n",
|
[anon_sym_LF] = "\n",
|
||||||
[aux_sym_from_instruction_token1] = "FROM",
|
[aux_sym_from_instruction_token1] = "FROM",
|
||||||
|
@ -269,7 +269,7 @@ static const char *ts_symbol_names[] = {
|
||||||
[aux_sym_unquoted_string_repeat1] = "unquoted_string_repeat1",
|
[aux_sym_unquoted_string_repeat1] = "unquoted_string_repeat1",
|
||||||
};
|
};
|
||||||
|
|
||||||
static TSSymbol ts_symbol_map[] = {
|
static const TSSymbol ts_symbol_map[] = {
|
||||||
[ts_builtin_sym_end] = ts_builtin_sym_end,
|
[ts_builtin_sym_end] = ts_builtin_sym_end,
|
||||||
[anon_sym_LF] = anon_sym_LF,
|
[anon_sym_LF] = anon_sym_LF,
|
||||||
[aux_sym_from_instruction_token1] = aux_sym_from_instruction_token1,
|
[aux_sym_from_instruction_token1] = aux_sym_from_instruction_token1,
|
||||||
|
@ -907,7 +907,7 @@ enum {
|
||||||
field_value = 9,
|
field_value = 9,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *ts_field_names[] = {
|
static const char * const ts_field_names[] = {
|
||||||
[0] = NULL,
|
[0] = NULL,
|
||||||
[field_as] = "as",
|
[field_as] = "as",
|
||||||
[field_default] = "default",
|
[field_default] = "default",
|
||||||
|
@ -978,7 +978,7 @@ static const TSFieldMapEntry ts_field_map_entries[] = {
|
||||||
{field_as, 4},
|
{field_as, 4},
|
||||||
};
|
};
|
||||||
|
|
||||||
static TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = {
|
static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = {
|
||||||
[0] = {0},
|
[0] = {0},
|
||||||
[3] = {
|
[3] = {
|
||||||
[1] = sym_unquoted_string,
|
[1] = sym_unquoted_string,
|
||||||
|
@ -989,7 +989,7 @@ static TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGT
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint16_t ts_non_terminal_alias_map[] = {
|
static const uint16_t ts_non_terminal_alias_map[] = {
|
||||||
aux_sym__user_name_or_group, 2,
|
aux_sym__user_name_or_group, 2,
|
||||||
aux_sym__user_name_or_group,
|
aux_sym__user_name_or_group,
|
||||||
sym_unquoted_string,
|
sym_unquoted_string,
|
||||||
|
@ -2563,7 +2563,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static TSLexMode ts_lex_modes[STATE_COUNT] = {
|
static const TSLexMode ts_lex_modes[STATE_COUNT] = {
|
||||||
[0] = {.lex_state = 0},
|
[0] = {.lex_state = 0},
|
||||||
[1] = {.lex_state = 158},
|
[1] = {.lex_state = 158},
|
||||||
[2] = {.lex_state = 158},
|
[2] = {.lex_state = 158},
|
||||||
|
@ -2794,7 +2794,7 @@ static TSLexMode ts_lex_modes[STATE_COUNT] = {
|
||||||
[227] = {.lex_state = 50},
|
[227] = {.lex_state = 50},
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
|
static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
|
||||||
[0] = {
|
[0] = {
|
||||||
[ts_builtin_sym_end] = ACTIONS(1),
|
[ts_builtin_sym_end] = ACTIONS(1),
|
||||||
[anon_sym_COLON] = ACTIONS(1),
|
[anon_sym_COLON] = ACTIONS(1),
|
||||||
|
@ -2861,7 +2861,7 @@ static uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint16_t ts_small_parse_table[] = {
|
static const uint16_t ts_small_parse_table[] = {
|
||||||
[0] = 24,
|
[0] = 24,
|
||||||
ACTIONS(3), 1,
|
ACTIONS(3), 1,
|
||||||
sym_line_continuation,
|
sym_line_continuation,
|
||||||
|
@ -5039,7 +5039,7 @@ static uint16_t ts_small_parse_table[] = {
|
||||||
aux_sym_param_token1,
|
aux_sym_param_token1,
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint32_t ts_small_parse_table_map[] = {
|
static const uint32_t ts_small_parse_table_map[] = {
|
||||||
[SMALL_STATE(2)] = 0,
|
[SMALL_STATE(2)] = 0,
|
||||||
[SMALL_STATE(3)] = 92,
|
[SMALL_STATE(3)] = 92,
|
||||||
[SMALL_STATE(4)] = 184,
|
[SMALL_STATE(4)] = 184,
|
||||||
|
@ -5268,7 +5268,7 @@ static uint32_t ts_small_parse_table_map[] = {
|
||||||
[SMALL_STATE(227)] = 3025,
|
[SMALL_STATE(227)] = 3025,
|
||||||
};
|
};
|
||||||
|
|
||||||
static TSParseActionEntry ts_parse_actions[] = {
|
static const TSParseActionEntry ts_parse_actions[] = {
|
||||||
[0] = {.entry = {.count = 0, .reusable = false}},
|
[0] = {.entry = {.count = 0, .reusable = false}},
|
||||||
[1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(),
|
[1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(),
|
||||||
[3] = {.entry = {.count = 1, .reusable = true}}, SHIFT_EXTRA(),
|
[3] = {.entry = {.count = 1, .reusable = true}}, SHIFT_EXTRA(),
|
||||||
|
@ -5632,7 +5632,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern const TSLanguage *tree_sitter_dockerfile(void) {
|
extern const TSLanguage *tree_sitter_dockerfile(void) {
|
||||||
static TSLanguage language = {
|
static const TSLanguage language = {
|
||||||
.version = LANGUAGE_VERSION,
|
.version = LANGUAGE_VERSION,
|
||||||
.symbol_count = SYMBOL_COUNT,
|
.symbol_count = SYMBOL_COUNT,
|
||||||
.alias_count = ALIAS_COUNT,
|
.alias_count = ALIAS_COUNT,
|
||||||
|
@ -5643,18 +5643,18 @@ extern const TSLanguage *tree_sitter_dockerfile(void) {
|
||||||
.production_id_count = PRODUCTION_ID_COUNT,
|
.production_id_count = PRODUCTION_ID_COUNT,
|
||||||
.field_count = FIELD_COUNT,
|
.field_count = FIELD_COUNT,
|
||||||
.max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH,
|
.max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH,
|
||||||
.parse_table = (const uint16_t *)ts_parse_table,
|
.parse_table = &ts_parse_table[0][0],
|
||||||
.small_parse_table = (const uint16_t *)ts_small_parse_table,
|
.small_parse_table = ts_small_parse_table,
|
||||||
.small_parse_table_map = (const uint32_t *)ts_small_parse_table_map,
|
.small_parse_table_map = ts_small_parse_table_map,
|
||||||
.parse_actions = ts_parse_actions,
|
.parse_actions = ts_parse_actions,
|
||||||
.symbol_names = ts_symbol_names,
|
.symbol_names = ts_symbol_names,
|
||||||
.field_names = ts_field_names,
|
.field_names = ts_field_names,
|
||||||
.field_map_slices = (const TSFieldMapSlice *)ts_field_map_slices,
|
.field_map_slices = ts_field_map_slices,
|
||||||
.field_map_entries = (const TSFieldMapEntry *)ts_field_map_entries,
|
.field_map_entries = ts_field_map_entries,
|
||||||
.symbol_metadata = ts_symbol_metadata,
|
.symbol_metadata = ts_symbol_metadata,
|
||||||
.public_symbol_map = ts_symbol_map,
|
.public_symbol_map = ts_symbol_map,
|
||||||
.alias_map = ts_non_terminal_alias_map,
|
.alias_map = ts_non_terminal_alias_map,
|
||||||
.alias_sequences = (const TSSymbol *)ts_alias_sequences,
|
.alias_sequences = &ts_alias_sequences[0][0],
|
||||||
.lex_modes = ts_lex_modes,
|
.lex_modes = ts_lex_modes,
|
||||||
.lex_fn = ts_lex,
|
.lex_fn = ts_lex,
|
||||||
};
|
};
|
||||||
|
|
|
@ -102,8 +102,8 @@ struct TSLanguage {
|
||||||
const uint16_t *small_parse_table;
|
const uint16_t *small_parse_table;
|
||||||
const uint32_t *small_parse_table_map;
|
const uint32_t *small_parse_table_map;
|
||||||
const TSParseActionEntry *parse_actions;
|
const TSParseActionEntry *parse_actions;
|
||||||
const char **symbol_names;
|
const char * const *symbol_names;
|
||||||
const char **field_names;
|
const char * const *field_names;
|
||||||
const TSFieldMapSlice *field_map_slices;
|
const TSFieldMapSlice *field_map_slices;
|
||||||
const TSFieldMapEntry *field_map_entries;
|
const TSFieldMapEntry *field_map_entries;
|
||||||
const TSSymbolMetadata *symbol_metadata;
|
const TSSymbolMetadata *symbol_metadata;
|
||||||
|
|
Loading…
Reference in a new issue