place assignment at the proper grammar level

This commit is contained in:
Rutger van Beusekom 2018-11-14 08:22:12 +01:00
parent 98868392c8
commit 6e88ad23d0
1 changed files with 15 additions and 12 deletions

View File

@ -69,13 +69,27 @@
compound-command <- (subshell / brace-group / for-clause / case-clause /
if-clause / while-clause / until-clause) (sp* io-redirect)*
simple-command <- ((io-redirect / nonreserved) sp*)+
simple-command <- ((io-redirect / assignment) sp*)*
((io-redirect / nonreserved) sp*)+ /
((io-redirect / assignment) sp*)+
((io-redirect / nonreserved) sp*)*
assignment <-- name assign word?
assign < '='
io-redirect <-- [0-9]* (io-here / io-file)
io-file <-- io-op ([0-9]+ / word)
io-op <- '<&' / '>&' / '>>' / '>' / '<>'/ '<' / '>|'
io-here <-- io-here-op io-here-label sp* eol io-here-document
io-here-op <- '<<-' / '<<'
reserved < ('case' / 'esac' / 'in' / 'if' / 'fi' / 'then' / 'else' /
'elif' / 'for' / 'done' / 'do' / 'until' / 'while') &ws
nonreserved <- !reserved word
word <-- test / substitution /
(number / variable / variable-subst / delim / literal)+
function-def <-- name sp* lpar rpar# ws* function-body
name <-- !reserved identifier
function-body <-- brace-group (sp* io-redirect)*
@ -101,14 +115,6 @@
until-clause <-- until-keyword compound do-group
reserved < ('case' / 'esac' / 'in' / 'if' / 'fi' / 'then' / 'else' /
'elif' / 'for' / 'done' / 'do' / 'until' / 'while') &ws
nonreserved <- !reserved word
word <-- test / substitution / assignment /
(number / variable / variable-subst / delim / literal)+
test <-- ltest sp+ (word sp+)+ rtest#
ltest < '['
rtest < ']'
@ -128,9 +134,6 @@
rpar < ')'
bt < [`]
assignment <-- name assign word?
assign < '='
variable <-- dollar ('*' / '@' / [0-9] / name /
lbrace name (variable-literal / &rbrace) rbrace)
variable-subst <- dollar lbrace (variable-or / variable-and / variable-regex / &rbrace) rbrace