Dev #127
@ -2,11 +2,11 @@ grammar ArithmeticsEvaluator;
|
|||||||
|
|
||||||
fragment DIGIT: '0'..'9';
|
fragment DIGIT: '0'..'9';
|
||||||
fragment LETTER: 'a'..'z';
|
fragment LETTER: 'a'..'z';
|
||||||
fragment CAPITAL_LETTER: 'A'..'Z'
|
fragment CAPITAL_LETTER: 'A'..'Z';
|
||||||
fragment UNDERSCORE: '_';
|
fragment UNDERSCORE: '_';
|
||||||
|
|
||||||
ID: (LETTER | UNDERSCORE | CAPITAL_LETTER) (LETTER | UNDERSCORE | DIGIT | CAPITAL_LETTER)*;
|
ID: (LETTER | UNDERSCORE | CAPITAL_LETTER) (LETTER | UNDERSCORE | DIGIT | CAPITAL_LETTER)*;
|
||||||
NUM: (DIGIT | '.')+ ([eE] MINUS? DIGIT+)?;
|
NUM: (DIGIT | '.')+ ([eE] (MINUS? | PLUS?) DIGIT+)?;
|
||||||
MUL: '*';
|
MUL: '*';
|
||||||
DIV: '/';
|
DIV: '/';
|
||||||
PLUS: '+';
|
PLUS: '+';
|
||||||
@ -17,7 +17,7 @@ LPAR: '(';
|
|||||||
RPAR: ')';
|
RPAR: ')';
|
||||||
WS: [ \n\t\r]+ -> skip;
|
WS: [ \n\t\r]+ -> skip;
|
||||||
|
|
||||||
number
|
num
|
||||||
: NUM
|
: NUM
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ binaryFunction
|
|||||||
;
|
;
|
||||||
|
|
||||||
term
|
term
|
||||||
: number
|
: num
|
||||||
| singular
|
| singular
|
||||||
| unaryFunction
|
| unaryFunction
|
||||||
| binaryFunction
|
| binaryFunction
|
||||||
|
@ -18,7 +18,7 @@ import scientifik.kmath.operations.SpaceOperations
|
|||||||
* TODO move to common
|
* TODO move to common
|
||||||
*/
|
*/
|
||||||
object ArithmeticsEvaluator : Grammar<MST>() {
|
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 id: Token by token("[a-z_A-Z][\\da-z_A-Z]*".toRegex())
|
||||||
private val lpar: Token by token("\\(".toRegex())
|
private val lpar: Token by token("\\(".toRegex())
|
||||||
private val rpar: Token by token("\\)".toRegex())
|
private val rpar: Token by token("\\)".toRegex())
|
||||||
|
Loading…
Reference in New Issue
Block a user