diff --git a/src/translator/math/Math.cpp b/src/translator/math/Math.cpp index 81dba3d..f8cd3ed 100644 --- a/src/translator/math/Math.cpp +++ b/src/translator/math/Math.cpp @@ -494,10 +494,6 @@ Draw Parse(MathParser::AtomContext* context, } } - if (context->scientific()) { - return Parse(context->scientific()); - } - if (context->function()) { return Parse(context->function(), style); } @@ -522,10 +518,6 @@ Draw Parse(MathParser::VariableContext* context, Style* style) { return Draw(label); } -Draw Parse(MathParser::ScientificContext* context) { - return Draw(to_wstring(context->SCIENTIFIC_NUMBER()->getText())); -} - Draw Parse(MathParser::MatrixContext* context, Style* style) { // 1) Get matrix content. std::vector> content; diff --git a/src/translator/math/Math.g4 b/src/translator/math/Math.g4 index 14ab813..283008d 100644 --- a/src/translator/math/Math.g4 +++ b/src/translator/math/Math.g4 @@ -49,34 +49,22 @@ factor : valueBang (powop valueBang)* ; valueBang: value | valueBang BANG; value : (PLUS | MINUS)? atom ; atom : STRING - | scientific | variable | function | matrix | LBRACE expression RBRACE | LPAREN expression RPAREN ; -scientific : SCIENTIFIC_NUMBER ; function : variable LPAREN equation (',' equation)* RPAREN ; -variable : VARIABLE ; +variable : VARIABLE; matrix : LBRACKET matrixLine (';' matrixLine)* RBRACKET; matrixLine : expression ( ',' expression ) *; relop : EQ | GT | LT | GE | LE; addop : PLUS | MINUS ; mulop : TIMES | DIV ; powop : POW | SUBSCRIPT ; -VARIABLE : VALID_ID_START VALID_ID_CHAR* | '...' ; STRING: '"' ~('"') * '"' ; -fragment VALID_ID_START : ('a' .. 'z') | ('A' .. 'Z') ; -fragment VALID_ID_CHAR : VALID_ID_START | ('0' .. '9') ; -SCIENTIFIC_NUMBER : NUMBER (E SIGN? NUMBER)? ; - -//The integer part gets its potential sign from the value rule - -fragment NUMBER : ('0' .. '9') + ('.' ('0' .. '9') +)? ; -fragment E : 'E' | 'e' ; -fragment SIGN : ('+' | '-') ; LPAREN : '(' ; RPAREN : ')' ; @@ -100,4 +88,7 @@ SUBSCRIPT: '_' ; EOL : '\r\n' | '\n' ; WS : [ \t] + -> skip ; +fragment CHAR : ~([!+-<>=_^(){}[\] \t\r\n"*]) | [0123456789]; +VARIABLE: CHAR+; + // vim: filetype=antlr diff --git a/src/translator/math/Math.h b/src/translator/math/Math.h index 23ed3ae..92e76b9 100644 --- a/src/translator/math/Math.h +++ b/src/translator/math/Math.h @@ -88,7 +88,6 @@ Draw Parse(MathParser::MatrixContext*, Style*); Draw Parse(MathParser::ValueBangContext* context, Style*, bool); Draw Parse(MathParser::ValueContext*, Style*, bool suppress_parenthesis); Draw Parse(MathParser::AtomContext*, Style*, bool suppress_parenthesis); -Draw Parse(MathParser::ScientificContext*); Draw Parse(MathParser::VariableContext*, Style* style); Draw ComposeHorizontal(const Draw& left, const Draw& right, int spaces); Draw ComposeVertical(const Draw& top, const Draw& down, int spaces); diff --git a/test/Math/variable/input b/test/Math/variable/input index 6437a13..00de0e2 100644 --- a/test/Math/variable/input +++ b/test/Math/variable/input @@ -1 +1,9 @@ variable + +f'(x) + +a123456789°à@çè|#~#& + +2_2m + +2é8fsdmoiuuç diff --git a/test/Math/variable/output b/test/Math/variable/output index 6437a13..86d7443 100644 --- a/test/Math/variable/output +++ b/test/Math/variable/output @@ -1 +1,10 @@ -variable +variable + +f'(x) + +a123456789°à@çè|#~#& + +2 + 2m + +2é8fsdmoiuuç