@@ -119,7 +119,7 @@ module.exports = grammar({
119119 identifier : _ => _identifier_rules ( false ) ,
120120
121121 long_flag_identifier : _ =>
122- token . immediate ( / [ 0 - 9 \p{ XID_Start} _ ] [ \p{ XID_Continue} ? _ - ] * / ) ,
122+ token . immediate ( / [ 0 - 9 \p{ XID_Start} _ ] [ \p{ XID_Continue} ? _ - ] * / u ) ,
123123
124124 _command_name : $ =>
125125 choice (
@@ -146,7 +146,7 @@ module.exports = grammar({
146146 /// Attributes
147147 attribute_list : $ => repeat1 ( seq ( $ . attribute , choice ( ';' , $ . _newline ) ) ) ,
148148 attribute_identifier : _ =>
149- token . immediate ( / [ 0 - 9 \p{ XID_Start} ] [ 0 - 9 \p{ XID_Continue} _ - ] * / ) ,
149+ token . immediate ( / [ 0 - 9 \p{ XID_Start} ] [ 0 - 9 \p{ XID_Continue} _ - ] * / u ) ,
150150 attribute : $ =>
151151 seq (
152152 '@' ,
@@ -359,7 +359,7 @@ module.exports = grammar({
359359 seq ( operator ( ) . minus , field ( 'name' , $ . param_short_flag_identifier ) ) ,
360360
361361 param_short_flag_identifier : _ =>
362- token . immediate ( / [ \p{ Punctuation} \p{ Symbol} \p{ XID_Continue} ] / ) ,
362+ token . immediate ( / [ \p{ Punctuation} \p{ Symbol} \p{ XID_Continue} ] / u ) ,
363363
364364 /// Controls
365365
@@ -545,6 +545,7 @@ module.exports = grammar({
545545 seq ( _env_variable_rule ( false , $ ) , $ . command ) ,
546546 $ . _ctrl_expression ,
547547 $ . where_command ,
548+ $ . assignment ,
548549 alias ( $ . _stmt_let_shortcut , $ . stmt_let ) ,
549550 ) ,
550551
@@ -561,6 +562,7 @@ module.exports = grammar({
561562 ) ,
562563
563564 $ . _ctrl_expression_parenthesized ,
565+ alias ( $ . assignment_parenthesized , $ . assignment ) ,
564566 alias ( $ . where_command_parenthesized , $ . where_command ) ,
565567 alias ( $ . _stmt_let_shortcut , $ . stmt_let ) ,
566568 ) ,
@@ -1170,7 +1172,7 @@ module.exports = grammar({
11701172
11711173 cell_path : $ => repeat1 ( $ . path ) ,
11721174
1173- _path_suffix : $ => choice ( '?' , '!' , seq ( '?' , '!' ) , seq ( '!' , '?' ) ) ,
1175+ _path_suffix : _ $ => choice ( '?' , '!' , seq ( '?' , '!' ) , seq ( '!' , '?' ) ) ,
11741176
11751177 path : $ => {
11761178 const path = choice (
@@ -1249,7 +1251,7 @@ module.exports = grammar({
12491251 ) ,
12501252
12511253 short_flag_identifier : _ =>
1252- token . immediate ( / [ \p{ XID_Continue} : ? @ ! % _ - ] + / ) ,
1254+ token . immediate ( / [ \p{ XID_Continue} : ? @ ! % _ - ] + / u ) ,
12531255
12541256 long_flag : $ =>
12551257 seq (
@@ -1327,7 +1329,7 @@ function _identifier_rules(immediate) {
13271329 * @param {any } entry base build block
13281330 * @param {any } separator separator between entries
13291331 * @param {any } preceding separator before first entry, defaults to separator
1330- * @param {Array } alt_sep array of rules to override default separator
1332+ * @param {any } alt_sep array of rules to override default separator
13311333 * @param {any } empty_unit optional for empty body
13321334 */
13331335function general_body_rules (
@@ -1362,8 +1364,11 @@ function parenthesized_body_rules() {
13621364 return {
13631365 ..._block_body_rules ( '_parenthesized' ) ,
13641366
1365- /// pipeline
1366-
1367+ /**
1368+ * pipeline_parenthesized
1369+ *
1370+ * @param {GrammarSymbols<string> } $
1371+ */
13671372 pipeline_parenthesized : $ =>
13681373 seq (
13691374 repeat (
@@ -1385,8 +1390,11 @@ function block_body_rules() {
13851390 return {
13861391 ..._block_body_rules ( '' ) ,
13871392
1388- /// pipeline
1389-
1393+ /**
1394+ * pipeline
1395+ *
1396+ * @param {GrammarSymbols<string> } $
1397+ */
13901398 pipeline : $ =>
13911399 seq (
13921400 repeat ( seq ( $ . pipe_element , $ . _pipe_separator , optional ( $ . _newline ) ) ) ,
@@ -1466,7 +1474,10 @@ function _block_body_rules(suffix) {
14661474 ) ,
14671475
14681476 [ 'stmt_mut' + suffix ] : ( /** @type {{ [x: string]: RuleOrLiteral; } } */ $ ) =>
1469- prec . right ( 1 , seq ( keyword ( ) . mut , $ [ '_assignment_pattern' + suffix ] ) ) ,
1477+ prec . right (
1478+ prec_map ( ) . assignment ,
1479+ seq ( keyword ( ) . mut , $ [ '_assignment_pattern' + suffix ] ) ,
1480+ ) ,
14701481
14711482 [ 'stmt_const' + suffix ] : (
14721483 /** @type {{ [x: string]: RuleOrLiteral; } } */ $ ,
@@ -1522,7 +1533,6 @@ function _block_body_rules(suffix) {
15221533 [ '_statement' + suffix ] : ( /** @type {any } */ $ ) =>
15231534 choice (
15241535 $ . _ctrl_statement ,
1525- alias_for_suffix ( $ , 'assignment' , suffix ) ,
15261536 alias_for_suffix ( $ , 'stmt_let' , suffix ) ,
15271537 alias_for_suffix ( $ , 'stmt_mut' , suffix ) ,
15281538 alias_for_suffix ( $ , 'stmt_const' , suffix ) ,
@@ -1535,7 +1545,7 @@ function _block_body_rules(suffix) {
15351545 * Insert optional($._repeat_newline) in-between
15361546 *
15371547 * @param {any } $
1538- * @param {Array } sequence
1548+ * @param {Array<any> } sequence
15391549 * @param {boolean } begin allow newline in beginning
15401550 * @param {boolean } end allow newline in end
15411551 */
@@ -1681,7 +1691,7 @@ function _binary_predicate_rule(parenthesized) {
16811691 $ . _binary_predicate_parenthesized :
16821692 $ . _binary_predicate ;
16831693 return choice (
1684- ...binary ( ) . map ( ( [ precedence , opr ] ) => {
1694+ ...binary ( ) . map ( ( { prec : precedence , name : opr } ) => {
16851695 const seq_array = [
16861696 field ( 'lhs' , choice ( $ . where_predicate , _expr ) ) ,
16871697 field ( 'opr' , opr ) ,
@@ -1826,6 +1836,9 @@ function _range_rule(anonymous) {
18261836 * @param {string } type
18271837 */
18281838function _unquoted_with_expr_rule ( type ) {
1839+ /**
1840+ * @param {GrammarSymbols<string> } $
1841+ */
18291842 return $ => {
18301843 let excluded = '' ;
18311844 let unquoted_head = $ . unquoted ;
@@ -1893,10 +1906,14 @@ function _unquoted_rule(type) {
18931906 const pattern = token ( seq ( none_of ( excluded_first ) , repeat ( pattern_once ) ) ) ;
18941907 const pattern_repeat = token ( repeat ( pattern_once ) ) ;
18951908
1896- // because this catches almost anything, we want to ensure it is
1897- // picked as the a last resort after everything else has failed.
1898- // so we give it a ridiculously low precedence and place it at the
1899- // very end
1909+ /**
1910+ * because this catches almost anything, we want to ensure it is
1911+ * picked as the a last resort after everything else has failed.
1912+ * so we give it a ridiculously low precedence and place it at the
1913+ * very end
1914+ *
1915+ * @param {GrammarSymbols<string> } $
1916+ */
19001917 return $ => {
19011918 let pattern_repeat1 = $ . _unquoted_pattern ;
19021919 switch ( type ) {
@@ -2167,17 +2184,17 @@ function table() {
21672184 [ prec_map ( ) . bit_and , operator ( ) . bit_and ] ,
21682185 [ prec_map ( ) . bit_xor , operator ( ) . bit_xor ] ,
21692186 [ prec_map ( ) . bit_or , operator ( ) . bit_or ] ,
2170- ] . concat ( binary ( ) , predicate ( ) ) ;
2187+ ] . concat ( binary ( ) . map ( ( { prec , name } ) => [ prec , name ] ) , predicate ( ) ) ;
21712188}
21722189
21732190/**
21742191 *
21752192 */
21762193function binary ( ) {
21772194 return [
2178- [ prec_map ( ) . and , operator ( ) . and ] ,
2179- [ prec_map ( ) . xor , operator ( ) . xor ] ,
2180- [ prec_map ( ) . or , operator ( ) . or ] ,
2195+ { prec : prec_map ( ) . and , name : operator ( ) . and } ,
2196+ { prec : prec_map ( ) . xor , name : operator ( ) . xor } ,
2197+ { prec : prec_map ( ) . or , name : operator ( ) . or } ,
21812198 ] ;
21822199}
21832200
0 commit comments