@@ -11,22 +11,21 @@ const arithmeticOperators = [
11
11
] ;
12
12
13
13
const precedenceOperators = [
14
- '/' , '*' , '%' ,
15
- '-' , '+' ,
16
- '<<' , '>>' ,
17
- '<' , '>' , '<=' , '>=' ,
18
- '==' , '!=' ,
19
- '&' ,
20
- '^' ,
21
- '|' ,
22
- '&&' ,
23
- '^^' ,
24
- '||' ,
25
- '?' ,
26
- '=' ,
27
- '+=' , '-=' , '*=' , '/=' , '%=' , '^=' , '&=' , '|=' , '<<=' , '>>=' ,
28
- ','
29
- ] . reverse ( ) ;
14
+ [ ',' ] ,
15
+ [ '=' , '+=' , '-=' , '*=' , '/=' , '%=' , '^=' , '&=' , '|=' , '<<=' , '>>=' ] ,
16
+ [ '?' ] ,
17
+ [ '||' ] ,
18
+ [ '^^' ] ,
19
+ [ '&&' ] ,
20
+ [ '|' ] ,
21
+ [ '^' ] ,
22
+ [ '&' ] ,
23
+ [ '==' , '!=' ] ,
24
+ [ '<' , '>' , '<=' , '>=' ] ,
25
+ [ '<<' , '>>' ] ,
26
+ [ '+' , '-' ] ,
27
+ [ '*' , '/' , '%' ]
28
+ ] ;
30
29
31
30
const associativityRightToLeft = [
32
31
'=' ,
@@ -334,7 +333,7 @@ class GLSLDecoder {
334
333
335
334
let groupIndex = 0 ;
336
335
337
- for ( const operator of precedenceOperators ) {
336
+ for ( const operators of precedenceOperators ) {
338
337
339
338
const parseToken = ( i , inverse = false ) => {
340
339
@@ -351,7 +350,9 @@ class GLSLDecoder {
351
350
352
351
}
353
352
354
- if ( groupIndex === 0 && token . str === operator ) {
353
+ if ( groupIndex === 0 && operators . includes ( token . str ) ) {
354
+
355
+ const operator = token . str ;
355
356
356
357
if ( operator === '?' ) {
357
358
@@ -396,7 +397,9 @@ class GLSLDecoder {
396
397
397
398
} ;
398
399
399
- if ( associativityRightToLeft . includes ( operator ) ) {
400
+ const isRightAssociative = operators . some ( op => associativityRightToLeft . includes ( op ) ) ;
401
+
402
+ if ( isRightAssociative ) {
400
403
401
404
for ( let i = 0 ; i < tokens . length ; i ++ ) {
402
405
0 commit comments