Extend mathematic operations support in the kmath-ast parser #120
@ -2,11 +2,11 @@ grammar ArithmeticsEvaluator;
|
||||
|
||||
|
||||
fragment DIGIT: '0'..'9';
|
||||
fragment LETTER: 'a'..'z';
|
||||
What about uppercase letters? What about uppercase letters?
Added. Added.
|
||||
fragment CAPITAL_LETTER: 'A'..'Z'
|
||||
`1.23e+3` generally + in exponent is generally allowed
Fixed Fixed
|
||||
fragment CAPITAL_LETTER: 'A'..'Z';
|
||||
`1.23e+3` generally + in exponent is generally allowed
Fixed Fixed
|
||||
fragment UNDERSCORE: '_';
|
||||
|
||||
ID: (LETTER | UNDERSCORE | CAPITAL_LETTER) (LETTER | UNDERSCORE | DIGIT | CAPITAL_LETTER)*;
|
||||
NUM: (DIGIT | '.')+ ([eE] MINUS? DIGIT+)?;
|
||||
`1.23e+3` generally + in exponent is generally allowed
Fixed Fixed
|
||||
NUM: (DIGIT | '.')+ ([eE] (MINUS? | PLUS?) DIGIT+)?;
|
||||
`1.23e+3` generally + in exponent is generally allowed
Fixed Fixed
|
||||
MUL: '*';
|
||||
DIV: '/';
|
||||
PLUS: '+';
|
||||
@ -17,7 +17,7 @@ LPAR: '(';
|
||||
`1.23e+3` generally + in exponent is generally allowed
`1.23e+3` generally + in exponent is generally allowed
Fixed Fixed
Fixed Fixed
|
||||
RPAR: ')';
|
||||
WS: [ \n\t\r]+ -> skip;
|
||||
|
||||
number
|
||||
`1.23e+3` generally + in exponent is generally allowed
Fixed Fixed
|
||||
num
|
||||
`1.23e+3` generally + in exponent is generally allowed
Fixed Fixed
|
||||
: NUM
|
||||
;
|
||||
|
||||
@ -34,7 +34,7 @@ binaryFunction
|
||||
`1.23e+3` generally + in exponent is generally allowed
`1.23e+3` generally + in exponent is generally allowed
Fixed Fixed
Fixed Fixed
|
||||
;
|
||||
|
||||
term
|
||||
: number
|
||||
`1.23e+3` generally + in exponent is generally allowed
Fixed Fixed
|
||||
: num
|
||||
`1.23e+3` generally + in exponent is generally allowed
Fixed Fixed
|
||||
| singular
|
||||
| unaryFunction
|
||||
| binaryFunction
|
||||
|
||||
`1.23e+3` generally + in exponent is generally allowed
`1.23e+3` generally + in exponent is generally allowed
Fixed Fixed
Fixed Fixed
|
@ -18,7 +18,7 @@ import scientifik.kmath.operations.SpaceOperations
|
||||
* TODO move to common
|
||||
*/
|
||||
object ArithmeticsEvaluator : Grammar<MST>() {
|
||||
private val num: Token by token("[\\d.]+(?:[eE]-?\\d+)?".toRegex())
|
||||
private val num: Token by token("[\\d.]+(?:[eE][-+]?\\d+)?".toRegex())
|
||||
private val id: Token by token("[a-z_A-Z][\\da-z_A-Z]*".toRegex())
|
||||
private val lpar: Token by token("\\(".toRegex())
|
||||
private val rpar: Token by token("\\)".toRegex())
|
||||
|
1.23e+3
generally + in exponent is generally allowed1.23e+3
generally + in exponent is generally allowedFixed
Fixed