fix: single line function definitions, expose special characters

pull/504/merge
Amaan Qureshi 2023-08-21 18:41:47 +07:00
parent c0f5797a72
commit 4868ce43e2
3 changed files with 63 additions and 21 deletions

@ -28,6 +28,7 @@ module.exports = grammar({
conflicts: $ => [
[$._expression, $.command_name],
[$.command, $.variable_assignments],
[$.compound_statement],
],
inline: $ => [
@ -306,8 +307,8 @@ module.exports = grammar({
compound_statement: $ => seq(
'{',
optional($._statements2),
'}',
optional(choice($._statements2, seq($._statement, optional($._terminator)))),
alias(token(prec(-1, '}')), '}'),
),
subshell: $ => seq(
@ -537,16 +538,16 @@ module.exports = grammar({
concatenation: $ => prec(-1, seq(
choice(
$._primary_expression,
$._special_character,
alias($._special_character, $.word),
),
repeat1(prec(-1, seq(
repeat1(seq(
$._concat,
choice(
$._primary_expression,
$._special_character,
alias($._special_character, $.word),
alias($._comment_word, $.word),
),
))),
)),
optional(seq($._concat, '$')),
)),

@ -33,16 +33,26 @@ echo ]]] ===
(command_name
(word))
(concatenation
(word)
(word)
(word)
(word)
(word)
(word)))
(command
(command_name
(word))
(concatenation))
(concatenation
(word)
(word)
(word)))
(command
(command_name
(word))
(concatenation)
(concatenation
(word)
(word)
(word))
(word)))
================================================================================
@ -338,6 +348,8 @@ cat ${BAR} ${ABC=def} ${GHI:?jkl}
(expansion
(variable_name)
(concatenation
(word)
(word)
(word)))))))
================================================================================

@ -463,7 +463,8 @@ fi
argument: (word)
argument: (word)))
(command
name: (command_name (word))
name: (command_name
(word))
argument: (raw_string))))
================================================================================
@ -484,7 +485,8 @@ fi
argument: (word)
argument: (word))
(command
name: (command_name (word))
name: (command_name
(word))
argument: (raw_string))))
================================================================================
@ -500,10 +502,15 @@ fi
(program
(if_statement
condition: (variable_assignment
name: (variable_name)
value: (command_substitution (command name: (command_name (word)) argument: (raw_string))))
name: (variable_name)
value: (command_substitution
(command
name: (command_name
(word))
argument: (raw_string))))
(command
name: (command_name (word))
name: (command_name
(word))
argument: (raw_string))))
================================================================================
@ -518,7 +525,7 @@ fi
(program
(if_statement
condition: (negated_command
condition: (negated_command
(variable_assignment
name: (variable_name)
value: (command_substitution
@ -527,7 +534,8 @@ fi
(word))
argument: (raw_string)))))
(command
name: (command_name (word))
name: (command_name
(word))
argument: (raw_string))))
================================================================================
@ -543,10 +551,11 @@ fi
(program
(if_statement
condition: (variable_assignment
name: (variable_name)
value: (number))
name: (variable_name)
value: (number))
(command
name: (command_name (word))
name: (command_name
(word))
argument: (raw_string))))
================================================================================
@ -566,7 +575,8 @@ fi
name: (variable_name)
value: (number)))
(command
name: (command_name (word))
name: (command_name
(word))
argument: (raw_string))))
================================================================================
@ -674,7 +684,9 @@ esac
(case_item
(concatenation
(word)
(number))
(word)
(number)
(word))
(command
(command_name
(word))
@ -913,6 +925,8 @@ function do_yet_another_thing {
echo ok
} 2>&1
do_nothing() { return 0 }
--------------------------------------------------------------------------------
(program
@ -946,9 +960,13 @@ function do_yet_another_thing {
(command_name
(word))
(concatenation
(word)
(word)
(word))
(word)
(concatenation
(word)
(word)
(word))
(word)
(word)))))
@ -962,7 +980,14 @@ function do_yet_another_thing {
(word))))
(file_redirect
(file_descriptor)
(number))))
(number)))
(function_definition
(word)
(compound_statement
(command
(command_name
(word))
(number)))))
================================================================================
Variable declaration: declare & typeset
@ -1124,8 +1149,12 @@ export "$(echo ${key} | tr [:lower:] [:upper:])=${p_key#*=}"
(command_name
(word))
(concatenation
(word)
(word)
(word))
(concatenation
(word)
(word)
(word)))))
(expansion
(variable_name)