@@ -10,8 +10,8 @@ import com.github.murzagalin.evaluator.Token
1010* logic_or -> logic_and ( ( "or" | "||" ) logic_and )*
1111* logic_and -> equality ( ( "and" | "&&" ) equality )*
1212* equality -> comparison ( ( "!=" | "==" ) comparison )*
13- * comparison -> term ( ( ">" | ">=" | "<" | "<=" ) term )*
14- * term -> factor ( ( "-" | "+" ) factor )*
13+ * comparison -> sum ( ( ">" | ">=" | "<" | "<=" ) sum )*
14+ * sum -> factor ( ( "-" | "+" ) factor )*
1515* factor -> unary ( ( "/" | "*" | "%") unary )*
1616* unary -> ( "!" | "-" | "+" ) unary | exponent
1717* exponent -> identifier ( "^" unary )*
@@ -36,7 +36,7 @@ class Parser {
3636 Token .Operator .LessEqualThan
3737 )
3838
39- private val termTokens = setOf (Token .Operator .Plus , Token .Operator .Minus )
39+ private val sumTokens = setOf (Token .Operator .Plus , Token .Operator .Minus )
4040
4141 private val factorTokens = setOf (Token .Operator .Division , Token .Operator .Multiplication , Token .Operator .Modulo )
4242
@@ -105,21 +105,21 @@ class Parser {
105105 }
106106
107107 private fun comparison (tokens : List <Token >): Expression {
108- var left = term (tokens)
108+ var left = sum (tokens)
109109
110110 while (ix < tokens.size && tokens[ix] in comparisonTokens) {
111111 val operator = tokens[ix++ ]
112- val right = term (tokens)
112+ val right = sum (tokens)
113113 left = Expression .Binary (operator as Token .Operator , left, right)
114114 }
115115
116116 return left
117117 }
118118
119- private fun term (tokens : List <Token >): Expression {
119+ private fun sum (tokens : List <Token >): Expression {
120120 var left = factor(tokens)
121121
122- while (ix < tokens.size && tokens[ix] in termTokens ) {
122+ while (ix < tokens.size && tokens[ix] in sumTokens ) {
123123 val operator = tokens[ix++ ]
124124 val right = factor(tokens)
125125 left = Expression .Binary (operator as Token .Operator , left, right)
0 commit comments