Skip to content

Commit bccec12

Browse files
committed
correct names of certain rules/nodes (refer #1)
1 parent 1526dbc commit bccec12

File tree

5 files changed

+177
-251
lines changed

5 files changed

+177
-251
lines changed

grammar.pegjs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,24 @@ variableAssignment
4747
= writableVariableName '=' argument
4848

4949
commandName "command name"
50-
= !redirect !keyword name:(concatenation / '[')
50+
= !redirect
51+
!keyword
52+
name:(concatenation / builtinCommandName)
5153

5254
builtinCommandName
5355
= '['
5456
/ '[['
5557

5658
argument "command argument"
5759
= commandName
58-
/ commandSubstitution
60+
/ processSubstitution
5961

6062
concatenation
6163
= pieces:( glob
6264
/ bareword
6365
/ environmentVariable
6466
/ variableSubstitution
65-
/ subshell
66-
/ backticks
67+
/ commandSubstitution
6768
/ singleQuote
6869
/ doubleQuote
6970
)+
@@ -101,10 +102,9 @@ doubleQuoteMeta
101102
= '"' / '$' / '`'
102103

103104
expandsInQuotes
104-
= backticks
105+
= commandSubstitution
105106
/ environmentVariable
106107
/ variableSubstitution
107-
/ subshell
108108

109109
environmentVariable = '$' name:readableVariableName
110110

@@ -113,13 +113,11 @@ readableVariableName = writableVariableName / '?' /* todo, other special vars *
113113

114114
variableSubstitution = '${' expr:[^}]* '}'
115115

116-
backticks
117-
= '`' commands:(!backticks command)+ '`'
118-
119-
subshell
120-
= '$(' commands:statementList ')'
121-
122116
commandSubstitution
117+
= '`' commands:statementList '`'
118+
/ '$(' commands:statementList ')'
119+
120+
processSubstitution
123121
= rw:[<>] '(' commands:statementList ')'
124122

125123
redirect

overrides.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ rules.controlOperator = function (op) {
176176
return op == '\n' ? ';' : op
177177
}
178178

179-
rules.commandSubstitution = function (rw) {
179+
rules.processSubstitution = function (rw) {
180180
return {
181-
type: 'command-substitution',
181+
type: 'process-substitution',
182182
readWrite: rw,
183183
commands: commands,
184184
}
@@ -224,12 +224,17 @@ rules.doubleQuote = function (contents) {
224224
rules.escapedQuote = function (character) {
225225
return character
226226
}
227-
rules.backticks = function (commands) {
228-
return {type: 'backticks', commands: commands.map(second)}
229-
}
230227

231-
rules.subshell = function (commands) {
232-
return {type: 'subshell', commands: commands}
228+
rules.commandSubstitution = [
229+
commandSubstitution,
230+
commandSubstitution,
231+
]
232+
233+
function commandSubstitution (commands) {
234+
return {
235+
type: 'command-substitution',
236+
commands: commands
237+
}
233238
}
234239

235240
/** stdio redirection */

0 commit comments

Comments
 (0)