From 45087f8b2de6b615ea627400b8dd12edc8e0918d Mon Sep 17 00:00:00 2001 From: Iaroslav Date: Mon, 27 Jul 2020 15:37:18 +0700 Subject: [PATCH] Add capital latin letters support --- kmath-ast/reference/ArithmeticsEvaluator.g4 | 3 ++- kmath-ast/src/commonMain/kotlin/scientifik/kmath/ast/parser.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/kmath-ast/reference/ArithmeticsEvaluator.g4 b/kmath-ast/reference/ArithmeticsEvaluator.g4 index 684a9de44..137d42860 100644 --- a/kmath-ast/reference/ArithmeticsEvaluator.g4 +++ b/kmath-ast/reference/ArithmeticsEvaluator.g4 @@ -2,9 +2,10 @@ grammar ArithmeticsEvaluator; fragment DIGIT: '0'..'9'; fragment LETTER: 'a'..'z'; +fragment CAPITAL_LETTER: 'A'..'Z' fragment UNDERSCORE: '_'; -ID: (LETTER | UNDERSCORE) (LETTER | UNDERSCORE | DIGIT)*; +ID: (LETTER | UNDERSCORE | CAPITAL_LETTER) (LETTER | UNDERSCORE | DIGIT | CAPITAL_LETTER)*; NUM: (DIGIT | '.')+ ([eE] MINUS? DIGIT+)?; MUL: '*'; DIV: '/'; diff --git a/kmath-ast/src/commonMain/kotlin/scientifik/kmath/ast/parser.kt b/kmath-ast/src/commonMain/kotlin/scientifik/kmath/ast/parser.kt index ae0b6656d..27f133d6a 100644 --- a/kmath-ast/src/commonMain/kotlin/scientifik/kmath/ast/parser.kt +++ b/kmath-ast/src/commonMain/kotlin/scientifik/kmath/ast/parser.kt @@ -19,7 +19,7 @@ import scientifik.kmath.operations.SpaceOperations */ object ArithmeticsEvaluator : Grammar() { private val num: Token by token("[\\d.]+(?:[eE]-?\\d+)?".toRegex()) - private val id: Token by token("[a-z_][\\da-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 rpar: Token by token("\\)".toRegex()) private val comma: Token by token(",".toRegex())