@@ -6,6 +6,8 @@ import * as pexprs from './pexprs-main.js';
66// Operations
77// --------------------------------------------------------------------
88
9+ // v18 (boolean, default false) is passed through to getArity().
10+
911pexprs . PExpr . prototype . assertChoicesHaveUniformArity = abstract (
1012 'assertChoicesHaveUniformArity'
1113) ;
@@ -17,54 +19,54 @@ pexprs.any.assertChoicesHaveUniformArity =
1719 pexprs . Param . prototype . assertChoicesHaveUniformArity =
1820 pexprs . Lex . prototype . assertChoicesHaveUniformArity =
1921 pexprs . UnicodeChar . prototype . assertChoicesHaveUniformArity =
20- function ( ruleName ) {
22+ function ( ruleName , v18 = false ) {
2123 // no-op
2224 } ;
2325
24- pexprs . Alt . prototype . assertChoicesHaveUniformArity = function ( ruleName ) {
26+ pexprs . Alt . prototype . assertChoicesHaveUniformArity = function ( ruleName , v18 = false ) {
2527 if ( this . terms . length === 0 ) {
2628 return ;
2729 }
28- const arity = this . terms [ 0 ] . getArity ( ) ;
30+ const arity = this . terms [ 0 ] . getArity ( v18 ) ;
2931 for ( let idx = 0 ; idx < this . terms . length ; idx ++ ) {
3032 const term = this . terms [ idx ] ;
31- term . assertChoicesHaveUniformArity ( ) ;
32- const otherArity = term . getArity ( ) ;
33+ term . assertChoicesHaveUniformArity ( ruleName , v18 ) ;
34+ const otherArity = term . getArity ( v18 ) ;
3335 if ( arity !== otherArity ) {
3436 throw errors . inconsistentArity ( ruleName , arity , otherArity , term ) ;
3537 }
3638 }
3739} ;
3840
39- pexprs . Extend . prototype . assertChoicesHaveUniformArity = function ( ruleName ) {
41+ pexprs . Extend . prototype . assertChoicesHaveUniformArity = function ( ruleName , v18 = false ) {
4042 // Extend is a special case of Alt that's guaranteed to have exactly two
4143 // cases: [extensions, origBody].
42- const actualArity = this . terms [ 0 ] . getArity ( ) ;
43- const expectedArity = this . terms [ 1 ] . getArity ( ) ;
44+ const actualArity = this . terms [ 0 ] . getArity ( v18 ) ;
45+ const expectedArity = this . terms [ 1 ] . getArity ( v18 ) ;
4446 if ( actualArity !== expectedArity ) {
4547 throw errors . inconsistentArity ( ruleName , expectedArity , actualArity , this . terms [ 0 ] ) ;
4648 }
4749} ;
4850
49- pexprs . Seq . prototype . assertChoicesHaveUniformArity = function ( ruleName ) {
51+ pexprs . Seq . prototype . assertChoicesHaveUniformArity = function ( ruleName , v18 = false ) {
5052 for ( let idx = 0 ; idx < this . factors . length ; idx ++ ) {
51- this . factors [ idx ] . assertChoicesHaveUniformArity ( ruleName ) ;
53+ this . factors [ idx ] . assertChoicesHaveUniformArity ( ruleName , v18 ) ;
5254 }
5355} ;
5456
55- pexprs . Iter . prototype . assertChoicesHaveUniformArity = function ( ruleName ) {
56- this . expr . assertChoicesHaveUniformArity ( ruleName ) ;
57+ pexprs . Iter . prototype . assertChoicesHaveUniformArity = function ( ruleName , v18 = false ) {
58+ this . expr . assertChoicesHaveUniformArity ( ruleName , v18 ) ;
5759} ;
5860
59- pexprs . Not . prototype . assertChoicesHaveUniformArity = function ( ruleName ) {
61+ pexprs . Not . prototype . assertChoicesHaveUniformArity = function ( ruleName , v18 = false ) {
6062 // no-op (not required b/c the nested expr doesn't show up in the CST)
6163} ;
6264
63- pexprs . Lookahead . prototype . assertChoicesHaveUniformArity = function ( ruleName ) {
64- this . expr . assertChoicesHaveUniformArity ( ruleName ) ;
65+ pexprs . Lookahead . prototype . assertChoicesHaveUniformArity = function ( ruleName , v18 = false ) {
66+ this . expr . assertChoicesHaveUniformArity ( ruleName , v18 ) ;
6567} ;
6668
67- pexprs . Apply . prototype . assertChoicesHaveUniformArity = function ( ruleName ) {
69+ pexprs . Apply . prototype . assertChoicesHaveUniformArity = function ( ruleName , v18 = false ) {
6870 // The arities of the parameter expressions is required to be 1 by
6971 // `assertAllApplicationsAreValid()`.
7072} ;
0 commit comments