Name inlined rules as if they were hidden

This commit is contained in:
Max Brunsfeld 2017-07-15 22:23:38 -07:00
parent 5081293f65
commit e9afbb4381
2 changed files with 46 additions and 46 deletions

View File

@ -2,9 +2,9 @@ module.exports = grammar({
name: 'bash',
inline: $ => [
$.statement,
$.terminator,
$.expression,
$._statement,
$._terminator,
$._expression,
$._variable_name
],
@ -26,13 +26,13 @@ module.exports = grammar({
program: $ => repeat($._terminated_statement),
_terminated_statement: $ => seq(
$.statement,
$.terminator
$._statement,
$._terminator
),
// Statements
statement: $ => choice(
_statement: $ => choice(
$.environment_variable_assignment,
$.command,
$.bracket_command,
@ -90,16 +90,16 @@ module.exports = grammar({
case_statement: $ => seq(
'case',
$.expression,
optional($.terminator),
$._expression,
optional($._terminator),
'in',
$.terminator,
$._terminator,
repeat($.case_item),
'esac'
),
case_item: $ => seq(
$.expression,
$._expression,
')',
repeat($._terminated_statement),
';;'
@ -126,20 +126,20 @@ module.exports = grammar({
),
pipeline: $ => prec.left(1, seq(
$.statement,
$._statement,
choice('|', '|&'),
$.statement
$._statement
)),
list: $ => prec.left(seq(
$.statement,
$._statement,
choice('&&', '||'),
$.statement
$._statement
)),
bracket_command: $ => choice(
seq('[', repeat1($.expression), ']'),
seq('[[', repeat1($.expression), ']]')
seq('[', repeat1($._expression), ']'),
seq('[[', repeat1($._expression), ']]')
),
// Commands
@ -158,7 +158,7 @@ module.exports = grammar({
),
optional(seq(
/\s+/,
repeat($.expression)
repeat($._expression)
)),
repeat(choice(
$.file_redirect,
@ -170,7 +170,7 @@ module.exports = grammar({
rename($.leading_word, 'variable_name'),
'=',
choice(
$.expression,
$._expression,
$._empty_value
)
),
@ -178,7 +178,7 @@ module.exports = grammar({
file_redirect: $ => seq(
optional($.file_descriptor),
choice('<', '>', '>>', '&>', '&>>', '<&', '>&'),
$.expression
$._expression
),
heredoc_redirect: $ => seq(
@ -201,7 +201,7 @@ module.exports = grammar({
// Expressions
expression: $ => choice(
_expression: $ => choice(
$.word,
$.string,
$.raw_string,
@ -237,7 +237,7 @@ module.exports = grammar({
$._variable_name,
optional(seq(
choice(':', ':?', '=', ':-'),
$.expression
$._expression
)),
'}'
),
@ -255,7 +255,7 @@ module.exports = grammar({
process_substitution: $ => seq(
choice('<', '>'),
'(',
$.statement,
$._statement,
')'
),
@ -269,6 +269,6 @@ module.exports = grammar({
special_variable_name: $ => choice('*', '@', '#', '?', '-', '$', '!', '0', '_'),
terminator: $ => choice(';', ';;', '\n', '&'),
_terminator: $ => choice(';', ';;', '\n', '&'),
}
});

46
src/grammar.json vendored
View File

@ -13,15 +13,15 @@
"members": [
{
"type": "SYMBOL",
"name": "statement"
"name": "_statement"
},
{
"type": "SYMBOL",
"name": "terminator"
"name": "_terminator"
}
]
},
"statement": {
"_statement": {
"type": "CHOICE",
"members": [
{
@ -228,14 +228,14 @@
},
{
"type": "SYMBOL",
"name": "expression"
"name": "_expression"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "terminator"
"name": "_terminator"
},
{
"type": "BLANK"
@ -248,7 +248,7 @@
},
{
"type": "SYMBOL",
"name": "terminator"
"name": "_terminator"
},
{
"type": "REPEAT",
@ -268,7 +268,7 @@
"members": [
{
"type": "SYMBOL",
"name": "expression"
"name": "_expression"
},
{
"type": "STRING",
@ -372,7 +372,7 @@
"members": [
{
"type": "SYMBOL",
"name": "statement"
"name": "_statement"
},
{
"type": "CHOICE",
@ -389,7 +389,7 @@
},
{
"type": "SYMBOL",
"name": "statement"
"name": "_statement"
}
]
}
@ -402,7 +402,7 @@
"members": [
{
"type": "SYMBOL",
"name": "statement"
"name": "_statement"
},
{
"type": "CHOICE",
@ -419,7 +419,7 @@
},
{
"type": "SYMBOL",
"name": "statement"
"name": "_statement"
}
]
}
@ -438,7 +438,7 @@
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "expression"
"name": "_expression"
}
},
{
@ -458,7 +458,7 @@
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "expression"
"name": "_expression"
}
},
{
@ -539,7 +539,7 @@
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "expression"
"name": "_expression"
}
}
]
@ -588,7 +588,7 @@
"members": [
{
"type": "SYMBOL",
"name": "expression"
"name": "_expression"
},
{
"type": "SYMBOL",
@ -648,7 +648,7 @@
},
{
"type": "SYMBOL",
"name": "expression"
"name": "_expression"
}
]
},
@ -716,7 +716,7 @@
}
]
},
"expression": {
"_expression": {
"type": "CHOICE",
"members": [
{
@ -856,7 +856,7 @@
},
{
"type": "SYMBOL",
"name": "expression"
"name": "_expression"
}
]
},
@ -949,7 +949,7 @@
},
{
"type": "SYMBOL",
"name": "statement"
"name": "_statement"
},
{
"type": "STRING",
@ -1014,7 +1014,7 @@
}
]
},
"terminator": {
"_terminator": {
"type": "CHOICE",
"members": [
{
@ -1086,9 +1086,9 @@
}
],
"inline": [
"statement",
"terminator",
"expression",
"_statement",
"_terminator",
"_expression",
"_variable_name"
]
}