Added || shorthand for abs and snorm
This commit is contained in:
@@ -18,14 +18,14 @@ You can also get the node from comfy manager under the name of More math.
|
||||
- Nodes for CONDITIONING, LATENT, IMAGE, NOISE, FLOAT, VIDEO and AUDIO
|
||||
|
||||
## Operators
|
||||
- Math: `+`, `-`, `*`, `/`, `%`, `^`
|
||||
- Math: `+`, `-`, `*`, `/`, `%`, `^`, `||`
|
||||
- Boolean: `<`, `<=`, `>`, `>=`, `==`, `!=`
|
||||
(`false = 0.0`, `true = 1.0`)
|
||||
|
||||
## Functions
|
||||
|
||||
### Basic Math
|
||||
- `abs(x)`: Absolute value.
|
||||
- `abs(x)` or `|x|`: Absolute value. For **float** `abs(x)` and `|x|` are the same. For **tensor** `abs(x)` calculates element-wise absolute value and for `|x|` it calculates L2 norm (euclidean norm).
|
||||
- `sqrt(x)`: Square root.
|
||||
- `ln(x)`: Natural logarithm (base e).
|
||||
- `log(x)`: Logarithm base 10.
|
||||
|
||||
@@ -105,6 +105,7 @@ class FloatEvalVisitor(MathExprVisitor):
|
||||
def visitAcoshFunc(self, ctx): return math.acosh(self.visit(ctx.expr()))
|
||||
def visitAtanhFunc(self, ctx): return math.atanh(self.visit(ctx.expr()))
|
||||
def visitAbsFunc(self, ctx): return math.abs(self.visit(ctx.expr()))
|
||||
def visitAbsExp(self, ctx): return math.abs(self.visit(ctx.expr()))
|
||||
def visitSqrtFunc(self, ctx): return math.sqrt(self.visit(ctx.expr()))
|
||||
def visitLnFunc(self, ctx): return math.log(self.visit(ctx.expr()))
|
||||
def visitLogFunc(self, ctx): return math.log10(self.visit(ctx.expr()))
|
||||
|
||||
@@ -50,6 +50,7 @@ atom
|
||||
| NUMBER # NumberExp
|
||||
| CONSTANT # ConstantExp
|
||||
| '(' expr ')' # ParenExp
|
||||
| PIPE expr PIPE # AbsExp
|
||||
;
|
||||
|
||||
// Single-argument functions
|
||||
@@ -174,6 +175,7 @@ LE : '<=';
|
||||
LT : '<';
|
||||
EQ : '==';
|
||||
NE : '!=';
|
||||
PIPE : '|';
|
||||
|
||||
CONSTANT : ('pi'|'PI'|'e'|'E');
|
||||
NUMBER : [0-9]+ ('.' [0-9]+)?;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -57,10 +57,11 @@ LE=56
|
||||
LT=57
|
||||
EQ=58
|
||||
NE=59
|
||||
CONSTANT=60
|
||||
NUMBER=61
|
||||
VARIABLE=62
|
||||
WS=63
|
||||
PIPE=60
|
||||
CONSTANT=61
|
||||
NUMBER=62
|
||||
VARIABLE=63
|
||||
WS=64
|
||||
'('=1
|
||||
')'=2
|
||||
','=3
|
||||
@@ -120,3 +121,4 @@ WS=63
|
||||
'<'=57
|
||||
'=='=58
|
||||
'!='=59
|
||||
'|'=60
|
||||
|
||||
File diff suppressed because one or more lines are too long
+178
-174
@@ -1,5 +1,6 @@
|
||||
# Generated from src/more_math/Parser/MathExpr.g4 by ANTLR 4.13.2
|
||||
from antlr4 import ATNDeserializer, LexerATNSimulator, PredictionContextCache, Lexer,DFA
|
||||
# Generated from ./MathExpr.g4 by ANTLR 4.13.2
|
||||
from antlr4 import *
|
||||
from io import StringIO
|
||||
import sys
|
||||
if sys.version_info[1] > 5:
|
||||
from typing import TextIO
|
||||
@@ -9,7 +10,7 @@ else:
|
||||
|
||||
def serializedATN():
|
||||
return [
|
||||
4,0,63,428,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,
|
||||
4,0,64,432,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,
|
||||
2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,
|
||||
13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,
|
||||
19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,
|
||||
@@ -18,147 +19,149 @@ def serializedATN():
|
||||
39,7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,
|
||||
45,2,46,7,46,2,47,7,47,2,48,7,48,2,49,7,49,2,50,7,50,2,51,7,51,2,
|
||||
52,7,52,2,53,7,53,2,54,7,54,2,55,7,55,2,56,7,56,2,57,7,57,2,58,7,
|
||||
58,2,59,7,59,2,60,7,60,2,61,7,61,2,62,7,62,1,0,1,0,1,1,1,1,1,2,1,
|
||||
2,1,3,1,3,1,3,1,3,1,4,1,4,1,4,1,4,1,5,1,5,1,5,1,5,1,6,1,6,1,6,1,
|
||||
6,1,6,1,7,1,7,1,7,1,7,1,7,1,8,1,8,1,8,1,8,1,8,1,9,1,9,1,9,1,9,1,
|
||||
9,1,9,1,10,1,10,1,10,1,10,1,10,1,11,1,11,1,11,1,11,1,11,1,12,1,12,
|
||||
1,12,1,12,1,12,1,13,1,13,1,13,1,13,1,13,1,13,1,14,1,14,1,14,1,14,
|
||||
1,14,1,14,1,15,1,15,1,15,1,15,1,15,1,15,1,16,1,16,1,16,1,16,1,17,
|
||||
1,17,1,17,1,17,1,17,1,18,1,18,1,18,1,19,1,19,1,19,1,19,1,20,1,20,
|
||||
1,20,1,20,1,21,1,21,1,21,1,21,1,21,1,22,1,22,1,22,1,22,1,22,1,23,
|
||||
1,23,1,23,1,23,1,23,1,24,1,24,1,24,1,24,1,24,1,25,1,25,1,25,1,25,
|
||||
1,25,1,25,1,26,1,26,1,26,1,26,1,26,1,26,1,27,1,27,1,27,1,27,1,27,
|
||||
1,27,1,28,1,28,1,28,1,28,1,28,1,29,1,29,1,29,1,29,1,29,1,29,1,30,
|
||||
1,30,1,30,1,30,1,30,1,30,1,31,1,31,1,31,1,31,1,32,1,32,1,32,1,32,
|
||||
1,32,1,33,1,33,1,33,1,33,1,33,1,33,1,34,1,34,1,34,1,34,1,35,1,35,
|
||||
1,35,1,35,1,35,1,36,1,36,1,36,1,36,1,36,1,36,1,37,1,37,1,37,1,37,
|
||||
1,37,1,37,1,38,1,38,1,38,1,38,1,38,1,39,1,39,1,39,1,39,1,39,1,40,
|
||||
1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,41,1,41,1,41,
|
||||
1,41,1,41,1,41,1,42,1,42,1,42,1,42,1,42,1,43,1,43,1,43,1,43,1,43,
|
||||
1,43,1,43,1,43,1,43,1,44,1,44,1,44,1,44,1,44,1,45,1,45,1,45,1,45,
|
||||
1,45,1,46,1,46,1,46,1,46,1,46,1,47,1,47,1,48,1,48,1,49,1,49,1,50,
|
||||
1,50,1,51,1,51,1,52,1,52,1,53,1,53,1,53,1,54,1,54,1,55,1,55,1,55,
|
||||
1,56,1,56,1,57,1,57,1,57,1,58,1,58,1,58,1,59,1,59,1,59,1,59,1,59,
|
||||
3,59,400,8,59,1,60,4,60,403,8,60,11,60,12,60,404,1,60,1,60,4,60,
|
||||
409,8,60,11,60,12,60,410,3,60,413,8,60,1,61,1,61,5,61,417,8,61,10,
|
||||
61,12,61,420,9,61,1,62,4,62,423,8,62,11,62,12,62,424,1,62,1,62,0,
|
||||
0,63,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,
|
||||
13,27,14,29,15,31,16,33,17,35,18,37,19,39,20,41,21,43,22,45,23,47,
|
||||
24,49,25,51,26,53,27,55,28,57,29,59,30,61,31,63,32,65,33,67,34,69,
|
||||
35,71,36,73,37,75,38,77,39,79,40,81,41,83,42,85,43,87,44,89,45,91,
|
||||
46,93,47,95,48,97,49,99,50,101,51,103,52,105,53,107,54,109,55,111,
|
||||
56,113,57,115,58,117,59,119,60,121,61,123,62,125,63,1,0,5,2,0,69,
|
||||
69,101,101,1,0,48,57,3,0,65,90,95,95,97,122,4,0,48,57,65,90,95,95,
|
||||
97,122,3,0,9,10,13,13,32,32,434,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,
|
||||
0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,
|
||||
0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,
|
||||
0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,
|
||||
0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,
|
||||
0,0,47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,
|
||||
0,0,57,1,0,0,0,0,59,1,0,0,0,0,61,1,0,0,0,0,63,1,0,0,0,0,65,1,0,0,
|
||||
0,0,67,1,0,0,0,0,69,1,0,0,0,0,71,1,0,0,0,0,73,1,0,0,0,0,75,1,0,0,
|
||||
0,0,77,1,0,0,0,0,79,1,0,0,0,0,81,1,0,0,0,0,83,1,0,0,0,0,85,1,0,0,
|
||||
0,0,87,1,0,0,0,0,89,1,0,0,0,0,91,1,0,0,0,0,93,1,0,0,0,0,95,1,0,0,
|
||||
0,0,97,1,0,0,0,0,99,1,0,0,0,0,101,1,0,0,0,0,103,1,0,0,0,0,105,1,
|
||||
0,0,0,0,107,1,0,0,0,0,109,1,0,0,0,0,111,1,0,0,0,0,113,1,0,0,0,0,
|
||||
115,1,0,0,0,0,117,1,0,0,0,0,119,1,0,0,0,0,121,1,0,0,0,0,123,1,0,
|
||||
0,0,0,125,1,0,0,0,1,127,1,0,0,0,3,129,1,0,0,0,5,131,1,0,0,0,7,133,
|
||||
1,0,0,0,9,137,1,0,0,0,11,141,1,0,0,0,13,145,1,0,0,0,15,150,1,0,0,
|
||||
0,17,155,1,0,0,0,19,160,1,0,0,0,21,166,1,0,0,0,23,171,1,0,0,0,25,
|
||||
176,1,0,0,0,27,181,1,0,0,0,29,187,1,0,0,0,31,193,1,0,0,0,33,199,
|
||||
1,0,0,0,35,203,1,0,0,0,37,208,1,0,0,0,39,211,1,0,0,0,41,215,1,0,
|
||||
0,0,43,219,1,0,0,0,45,224,1,0,0,0,47,229,1,0,0,0,49,234,1,0,0,0,
|
||||
51,239,1,0,0,0,53,245,1,0,0,0,55,251,1,0,0,0,57,257,1,0,0,0,59,262,
|
||||
1,0,0,0,61,268,1,0,0,0,63,274,1,0,0,0,65,278,1,0,0,0,67,283,1,0,
|
||||
0,0,69,289,1,0,0,0,71,293,1,0,0,0,73,298,1,0,0,0,75,304,1,0,0,0,
|
||||
77,310,1,0,0,0,79,315,1,0,0,0,81,320,1,0,0,0,83,331,1,0,0,0,85,337,
|
||||
1,0,0,0,87,342,1,0,0,0,89,351,1,0,0,0,91,356,1,0,0,0,93,361,1,0,
|
||||
0,0,95,366,1,0,0,0,97,368,1,0,0,0,99,370,1,0,0,0,101,372,1,0,0,0,
|
||||
103,374,1,0,0,0,105,376,1,0,0,0,107,378,1,0,0,0,109,381,1,0,0,0,
|
||||
111,383,1,0,0,0,113,386,1,0,0,0,115,388,1,0,0,0,117,391,1,0,0,0,
|
||||
119,399,1,0,0,0,121,402,1,0,0,0,123,414,1,0,0,0,125,422,1,0,0,0,
|
||||
127,128,5,40,0,0,128,2,1,0,0,0,129,130,5,41,0,0,130,4,1,0,0,0,131,
|
||||
132,5,44,0,0,132,6,1,0,0,0,133,134,5,115,0,0,134,135,5,105,0,0,135,
|
||||
136,5,110,0,0,136,8,1,0,0,0,137,138,5,99,0,0,138,139,5,111,0,0,139,
|
||||
140,5,115,0,0,140,10,1,0,0,0,141,142,5,116,0,0,142,143,5,97,0,0,
|
||||
143,144,5,110,0,0,144,12,1,0,0,0,145,146,5,97,0,0,146,147,5,115,
|
||||
0,0,147,148,5,105,0,0,148,149,5,110,0,0,149,14,1,0,0,0,150,151,5,
|
||||
97,0,0,151,152,5,99,0,0,152,153,5,111,0,0,153,154,5,115,0,0,154,
|
||||
16,1,0,0,0,155,156,5,97,0,0,156,157,5,116,0,0,157,158,5,97,0,0,158,
|
||||
159,5,110,0,0,159,18,1,0,0,0,160,161,5,97,0,0,161,162,5,116,0,0,
|
||||
162,163,5,97,0,0,163,164,5,110,0,0,164,165,5,50,0,0,165,20,1,0,0,
|
||||
0,166,167,5,115,0,0,167,168,5,105,0,0,168,169,5,110,0,0,169,170,
|
||||
5,104,0,0,170,22,1,0,0,0,171,172,5,99,0,0,172,173,5,111,0,0,173,
|
||||
174,5,115,0,0,174,175,5,104,0,0,175,24,1,0,0,0,176,177,5,116,0,0,
|
||||
177,178,5,97,0,0,178,179,5,110,0,0,179,180,5,104,0,0,180,26,1,0,
|
||||
0,0,181,182,5,97,0,0,182,183,5,115,0,0,183,184,5,105,0,0,184,185,
|
||||
5,110,0,0,185,186,5,104,0,0,186,28,1,0,0,0,187,188,5,97,0,0,188,
|
||||
189,5,99,0,0,189,190,5,111,0,0,190,191,5,115,0,0,191,192,5,104,0,
|
||||
0,192,30,1,0,0,0,193,194,5,97,0,0,194,195,5,116,0,0,195,196,5,97,
|
||||
0,0,196,197,5,110,0,0,197,198,5,104,0,0,198,32,1,0,0,0,199,200,5,
|
||||
97,0,0,200,201,5,98,0,0,201,202,5,115,0,0,202,34,1,0,0,0,203,204,
|
||||
5,115,0,0,204,205,5,113,0,0,205,206,5,114,0,0,206,207,5,116,0,0,
|
||||
207,36,1,0,0,0,208,209,5,108,0,0,209,210,5,110,0,0,210,38,1,0,0,
|
||||
0,211,212,5,108,0,0,212,213,5,111,0,0,213,214,5,103,0,0,214,40,1,
|
||||
0,0,0,215,216,5,101,0,0,216,217,5,120,0,0,217,218,5,112,0,0,218,
|
||||
42,1,0,0,0,219,220,5,115,0,0,220,221,5,109,0,0,221,222,5,105,0,0,
|
||||
222,223,5,110,0,0,223,44,1,0,0,0,224,225,5,115,0,0,225,226,5,109,
|
||||
0,0,226,227,5,97,0,0,227,228,5,120,0,0,228,46,1,0,0,0,229,230,5,
|
||||
116,0,0,230,231,5,109,0,0,231,232,5,105,0,0,232,233,5,110,0,0,233,
|
||||
48,1,0,0,0,234,235,5,116,0,0,235,236,5,109,0,0,236,237,5,97,0,0,
|
||||
237,238,5,120,0,0,238,50,1,0,0,0,239,240,5,116,0,0,240,241,5,110,
|
||||
0,0,241,242,5,111,0,0,242,243,5,114,0,0,243,244,5,109,0,0,244,52,
|
||||
1,0,0,0,245,246,5,115,0,0,246,247,5,110,0,0,247,248,5,111,0,0,248,
|
||||
249,5,114,0,0,249,250,5,109,0,0,250,54,1,0,0,0,251,252,5,102,0,0,
|
||||
252,253,5,108,0,0,253,254,5,111,0,0,254,255,5,111,0,0,255,256,5,
|
||||
114,0,0,256,56,1,0,0,0,257,258,5,99,0,0,258,259,5,101,0,0,259,260,
|
||||
5,105,0,0,260,261,5,108,0,0,261,58,1,0,0,0,262,263,5,114,0,0,263,
|
||||
264,5,111,0,0,264,265,5,117,0,0,265,266,5,110,0,0,266,267,5,100,
|
||||
0,0,267,60,1,0,0,0,268,269,5,103,0,0,269,270,5,97,0,0,270,271,5,
|
||||
109,0,0,271,272,5,109,0,0,272,273,5,97,0,0,273,62,1,0,0,0,274,275,
|
||||
5,112,0,0,275,276,5,111,0,0,276,277,5,119,0,0,277,64,1,0,0,0,278,
|
||||
279,5,115,0,0,279,280,5,105,0,0,280,281,5,103,0,0,281,282,5,109,
|
||||
0,0,282,66,1,0,0,0,283,284,5,99,0,0,284,285,5,108,0,0,285,286,5,
|
||||
97,0,0,286,287,5,109,0,0,287,288,5,112,0,0,288,68,1,0,0,0,289,290,
|
||||
5,102,0,0,290,291,5,102,0,0,291,292,5,116,0,0,292,70,1,0,0,0,293,
|
||||
294,5,105,0,0,294,295,5,102,0,0,295,296,5,102,0,0,296,297,5,116,
|
||||
0,0,297,72,1,0,0,0,298,299,5,97,0,0,299,300,5,110,0,0,300,301,5,
|
||||
103,0,0,301,302,5,108,0,0,302,303,5,101,0,0,303,74,1,0,0,0,304,305,
|
||||
5,112,0,0,305,306,5,114,0,0,306,307,5,105,0,0,307,308,5,110,0,0,
|
||||
308,309,5,116,0,0,309,76,1,0,0,0,310,311,5,108,0,0,311,312,5,101,
|
||||
0,0,312,313,5,114,0,0,313,314,5,112,0,0,314,78,1,0,0,0,315,316,5,
|
||||
115,0,0,316,317,5,116,0,0,317,318,5,101,0,0,318,319,5,112,0,0,319,
|
||||
80,1,0,0,0,320,321,5,115,0,0,321,322,5,109,0,0,322,323,5,111,0,0,
|
||||
323,324,5,111,0,0,324,325,5,116,0,0,325,326,5,104,0,0,326,327,5,
|
||||
115,0,0,327,328,5,116,0,0,328,329,5,101,0,0,329,330,5,112,0,0,330,
|
||||
82,1,0,0,0,331,332,5,102,0,0,332,333,5,114,0,0,333,334,5,97,0,0,
|
||||
334,335,5,99,0,0,335,336,5,116,0,0,336,84,1,0,0,0,337,338,5,114,
|
||||
0,0,338,339,5,101,0,0,339,340,5,108,0,0,340,341,5,117,0,0,341,86,
|
||||
1,0,0,0,342,343,5,115,0,0,343,344,5,111,0,0,344,345,5,102,0,0,345,
|
||||
346,5,116,0,0,346,347,5,112,0,0,347,348,5,108,0,0,348,349,5,117,
|
||||
0,0,349,350,5,115,0,0,350,88,1,0,0,0,351,352,5,103,0,0,352,353,5,
|
||||
101,0,0,353,354,5,108,0,0,354,355,5,117,0,0,355,90,1,0,0,0,356,357,
|
||||
5,115,0,0,357,358,5,105,0,0,358,359,5,103,0,0,359,360,5,110,0,0,
|
||||
360,92,1,0,0,0,361,362,5,115,0,0,362,363,5,119,0,0,363,364,5,97,
|
||||
0,0,364,365,5,112,0,0,365,94,1,0,0,0,366,367,5,43,0,0,367,96,1,0,
|
||||
0,0,368,369,5,45,0,0,369,98,1,0,0,0,370,371,5,42,0,0,371,100,1,0,
|
||||
0,0,372,373,5,47,0,0,373,102,1,0,0,0,374,375,5,37,0,0,375,104,1,
|
||||
0,0,0,376,377,5,94,0,0,377,106,1,0,0,0,378,379,5,62,0,0,379,380,
|
||||
5,61,0,0,380,108,1,0,0,0,381,382,5,62,0,0,382,110,1,0,0,0,383,384,
|
||||
5,60,0,0,384,385,5,61,0,0,385,112,1,0,0,0,386,387,5,60,0,0,387,114,
|
||||
1,0,0,0,388,389,5,61,0,0,389,390,5,61,0,0,390,116,1,0,0,0,391,392,
|
||||
5,33,0,0,392,393,5,61,0,0,393,118,1,0,0,0,394,395,5,112,0,0,395,
|
||||
400,5,105,0,0,396,397,5,80,0,0,397,400,5,73,0,0,398,400,7,0,0,0,
|
||||
399,394,1,0,0,0,399,396,1,0,0,0,399,398,1,0,0,0,400,120,1,0,0,0,
|
||||
401,403,7,1,0,0,402,401,1,0,0,0,403,404,1,0,0,0,404,402,1,0,0,0,
|
||||
404,405,1,0,0,0,405,412,1,0,0,0,406,408,5,46,0,0,407,409,7,1,0,0,
|
||||
408,407,1,0,0,0,409,410,1,0,0,0,410,408,1,0,0,0,410,411,1,0,0,0,
|
||||
411,413,1,0,0,0,412,406,1,0,0,0,412,413,1,0,0,0,413,122,1,0,0,0,
|
||||
414,418,7,2,0,0,415,417,7,3,0,0,416,415,1,0,0,0,417,420,1,0,0,0,
|
||||
418,416,1,0,0,0,418,419,1,0,0,0,419,124,1,0,0,0,420,418,1,0,0,0,
|
||||
421,423,7,4,0,0,422,421,1,0,0,0,423,424,1,0,0,0,424,422,1,0,0,0,
|
||||
424,425,1,0,0,0,425,426,1,0,0,0,426,427,6,62,0,0,427,126,1,0,0,0,
|
||||
7,0,399,404,410,412,418,424,1,6,0,0
|
||||
58,2,59,7,59,2,60,7,60,2,61,7,61,2,62,7,62,2,63,7,63,1,0,1,0,1,1,
|
||||
1,1,1,2,1,2,1,3,1,3,1,3,1,3,1,4,1,4,1,4,1,4,1,5,1,5,1,5,1,5,1,6,
|
||||
1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,7,1,7,1,8,1,8,1,8,1,8,1,8,1,9,1,9,
|
||||
1,9,1,9,1,9,1,9,1,10,1,10,1,10,1,10,1,10,1,11,1,11,1,11,1,11,1,11,
|
||||
1,12,1,12,1,12,1,12,1,12,1,13,1,13,1,13,1,13,1,13,1,13,1,14,1,14,
|
||||
1,14,1,14,1,14,1,14,1,15,1,15,1,15,1,15,1,15,1,15,1,16,1,16,1,16,
|
||||
1,16,1,17,1,17,1,17,1,17,1,17,1,18,1,18,1,18,1,19,1,19,1,19,1,19,
|
||||
1,20,1,20,1,20,1,20,1,21,1,21,1,21,1,21,1,21,1,22,1,22,1,22,1,22,
|
||||
1,22,1,23,1,23,1,23,1,23,1,23,1,24,1,24,1,24,1,24,1,24,1,25,1,25,
|
||||
1,25,1,25,1,25,1,25,1,26,1,26,1,26,1,26,1,26,1,26,1,27,1,27,1,27,
|
||||
1,27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,29,1,29,1,29,1,29,1,29,
|
||||
1,29,1,30,1,30,1,30,1,30,1,30,1,30,1,31,1,31,1,31,1,31,1,32,1,32,
|
||||
1,32,1,32,1,32,1,33,1,33,1,33,1,33,1,33,1,33,1,34,1,34,1,34,1,34,
|
||||
1,35,1,35,1,35,1,35,1,35,1,36,1,36,1,36,1,36,1,36,1,36,1,37,1,37,
|
||||
1,37,1,37,1,37,1,37,1,38,1,38,1,38,1,38,1,38,1,39,1,39,1,39,1,39,
|
||||
1,39,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,41,
|
||||
1,41,1,41,1,41,1,41,1,41,1,42,1,42,1,42,1,42,1,42,1,43,1,43,1,43,
|
||||
1,43,1,43,1,43,1,43,1,43,1,43,1,44,1,44,1,44,1,44,1,44,1,45,1,45,
|
||||
1,45,1,45,1,45,1,46,1,46,1,46,1,46,1,46,1,47,1,47,1,48,1,48,1,49,
|
||||
1,49,1,50,1,50,1,51,1,51,1,52,1,52,1,53,1,53,1,53,1,54,1,54,1,55,
|
||||
1,55,1,55,1,56,1,56,1,57,1,57,1,57,1,58,1,58,1,58,1,59,1,59,1,60,
|
||||
1,60,1,60,1,60,1,60,3,60,404,8,60,1,61,4,61,407,8,61,11,61,12,61,
|
||||
408,1,61,1,61,4,61,413,8,61,11,61,12,61,414,3,61,417,8,61,1,62,1,
|
||||
62,5,62,421,8,62,10,62,12,62,424,9,62,1,63,4,63,427,8,63,11,63,12,
|
||||
63,428,1,63,1,63,0,0,64,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,
|
||||
19,10,21,11,23,12,25,13,27,14,29,15,31,16,33,17,35,18,37,19,39,20,
|
||||
41,21,43,22,45,23,47,24,49,25,51,26,53,27,55,28,57,29,59,30,61,31,
|
||||
63,32,65,33,67,34,69,35,71,36,73,37,75,38,77,39,79,40,81,41,83,42,
|
||||
85,43,87,44,89,45,91,46,93,47,95,48,97,49,99,50,101,51,103,52,105,
|
||||
53,107,54,109,55,111,56,113,57,115,58,117,59,119,60,121,61,123,62,
|
||||
125,63,127,64,1,0,5,2,0,69,69,101,101,1,0,48,57,3,0,65,90,95,95,
|
||||
97,122,4,0,48,57,65,90,95,95,97,122,3,0,9,10,13,13,32,32,438,0,1,
|
||||
1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,
|
||||
0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,
|
||||
0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,
|
||||
0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,
|
||||
0,0,0,43,1,0,0,0,0,45,1,0,0,0,0,47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,
|
||||
0,0,0,53,1,0,0,0,0,55,1,0,0,0,0,57,1,0,0,0,0,59,1,0,0,0,0,61,1,0,
|
||||
0,0,0,63,1,0,0,0,0,65,1,0,0,0,0,67,1,0,0,0,0,69,1,0,0,0,0,71,1,0,
|
||||
0,0,0,73,1,0,0,0,0,75,1,0,0,0,0,77,1,0,0,0,0,79,1,0,0,0,0,81,1,0,
|
||||
0,0,0,83,1,0,0,0,0,85,1,0,0,0,0,87,1,0,0,0,0,89,1,0,0,0,0,91,1,0,
|
||||
0,0,0,93,1,0,0,0,0,95,1,0,0,0,0,97,1,0,0,0,0,99,1,0,0,0,0,101,1,
|
||||
0,0,0,0,103,1,0,0,0,0,105,1,0,0,0,0,107,1,0,0,0,0,109,1,0,0,0,0,
|
||||
111,1,0,0,0,0,113,1,0,0,0,0,115,1,0,0,0,0,117,1,0,0,0,0,119,1,0,
|
||||
0,0,0,121,1,0,0,0,0,123,1,0,0,0,0,125,1,0,0,0,0,127,1,0,0,0,1,129,
|
||||
1,0,0,0,3,131,1,0,0,0,5,133,1,0,0,0,7,135,1,0,0,0,9,139,1,0,0,0,
|
||||
11,143,1,0,0,0,13,147,1,0,0,0,15,152,1,0,0,0,17,157,1,0,0,0,19,162,
|
||||
1,0,0,0,21,168,1,0,0,0,23,173,1,0,0,0,25,178,1,0,0,0,27,183,1,0,
|
||||
0,0,29,189,1,0,0,0,31,195,1,0,0,0,33,201,1,0,0,0,35,205,1,0,0,0,
|
||||
37,210,1,0,0,0,39,213,1,0,0,0,41,217,1,0,0,0,43,221,1,0,0,0,45,226,
|
||||
1,0,0,0,47,231,1,0,0,0,49,236,1,0,0,0,51,241,1,0,0,0,53,247,1,0,
|
||||
0,0,55,253,1,0,0,0,57,259,1,0,0,0,59,264,1,0,0,0,61,270,1,0,0,0,
|
||||
63,276,1,0,0,0,65,280,1,0,0,0,67,285,1,0,0,0,69,291,1,0,0,0,71,295,
|
||||
1,0,0,0,73,300,1,0,0,0,75,306,1,0,0,0,77,312,1,0,0,0,79,317,1,0,
|
||||
0,0,81,322,1,0,0,0,83,333,1,0,0,0,85,339,1,0,0,0,87,344,1,0,0,0,
|
||||
89,353,1,0,0,0,91,358,1,0,0,0,93,363,1,0,0,0,95,368,1,0,0,0,97,370,
|
||||
1,0,0,0,99,372,1,0,0,0,101,374,1,0,0,0,103,376,1,0,0,0,105,378,1,
|
||||
0,0,0,107,380,1,0,0,0,109,383,1,0,0,0,111,385,1,0,0,0,113,388,1,
|
||||
0,0,0,115,390,1,0,0,0,117,393,1,0,0,0,119,396,1,0,0,0,121,403,1,
|
||||
0,0,0,123,406,1,0,0,0,125,418,1,0,0,0,127,426,1,0,0,0,129,130,5,
|
||||
40,0,0,130,2,1,0,0,0,131,132,5,41,0,0,132,4,1,0,0,0,133,134,5,44,
|
||||
0,0,134,6,1,0,0,0,135,136,5,115,0,0,136,137,5,105,0,0,137,138,5,
|
||||
110,0,0,138,8,1,0,0,0,139,140,5,99,0,0,140,141,5,111,0,0,141,142,
|
||||
5,115,0,0,142,10,1,0,0,0,143,144,5,116,0,0,144,145,5,97,0,0,145,
|
||||
146,5,110,0,0,146,12,1,0,0,0,147,148,5,97,0,0,148,149,5,115,0,0,
|
||||
149,150,5,105,0,0,150,151,5,110,0,0,151,14,1,0,0,0,152,153,5,97,
|
||||
0,0,153,154,5,99,0,0,154,155,5,111,0,0,155,156,5,115,0,0,156,16,
|
||||
1,0,0,0,157,158,5,97,0,0,158,159,5,116,0,0,159,160,5,97,0,0,160,
|
||||
161,5,110,0,0,161,18,1,0,0,0,162,163,5,97,0,0,163,164,5,116,0,0,
|
||||
164,165,5,97,0,0,165,166,5,110,0,0,166,167,5,50,0,0,167,20,1,0,0,
|
||||
0,168,169,5,115,0,0,169,170,5,105,0,0,170,171,5,110,0,0,171,172,
|
||||
5,104,0,0,172,22,1,0,0,0,173,174,5,99,0,0,174,175,5,111,0,0,175,
|
||||
176,5,115,0,0,176,177,5,104,0,0,177,24,1,0,0,0,178,179,5,116,0,0,
|
||||
179,180,5,97,0,0,180,181,5,110,0,0,181,182,5,104,0,0,182,26,1,0,
|
||||
0,0,183,184,5,97,0,0,184,185,5,115,0,0,185,186,5,105,0,0,186,187,
|
||||
5,110,0,0,187,188,5,104,0,0,188,28,1,0,0,0,189,190,5,97,0,0,190,
|
||||
191,5,99,0,0,191,192,5,111,0,0,192,193,5,115,0,0,193,194,5,104,0,
|
||||
0,194,30,1,0,0,0,195,196,5,97,0,0,196,197,5,116,0,0,197,198,5,97,
|
||||
0,0,198,199,5,110,0,0,199,200,5,104,0,0,200,32,1,0,0,0,201,202,5,
|
||||
97,0,0,202,203,5,98,0,0,203,204,5,115,0,0,204,34,1,0,0,0,205,206,
|
||||
5,115,0,0,206,207,5,113,0,0,207,208,5,114,0,0,208,209,5,116,0,0,
|
||||
209,36,1,0,0,0,210,211,5,108,0,0,211,212,5,110,0,0,212,38,1,0,0,
|
||||
0,213,214,5,108,0,0,214,215,5,111,0,0,215,216,5,103,0,0,216,40,1,
|
||||
0,0,0,217,218,5,101,0,0,218,219,5,120,0,0,219,220,5,112,0,0,220,
|
||||
42,1,0,0,0,221,222,5,115,0,0,222,223,5,109,0,0,223,224,5,105,0,0,
|
||||
224,225,5,110,0,0,225,44,1,0,0,0,226,227,5,115,0,0,227,228,5,109,
|
||||
0,0,228,229,5,97,0,0,229,230,5,120,0,0,230,46,1,0,0,0,231,232,5,
|
||||
116,0,0,232,233,5,109,0,0,233,234,5,105,0,0,234,235,5,110,0,0,235,
|
||||
48,1,0,0,0,236,237,5,116,0,0,237,238,5,109,0,0,238,239,5,97,0,0,
|
||||
239,240,5,120,0,0,240,50,1,0,0,0,241,242,5,116,0,0,242,243,5,110,
|
||||
0,0,243,244,5,111,0,0,244,245,5,114,0,0,245,246,5,109,0,0,246,52,
|
||||
1,0,0,0,247,248,5,115,0,0,248,249,5,110,0,0,249,250,5,111,0,0,250,
|
||||
251,5,114,0,0,251,252,5,109,0,0,252,54,1,0,0,0,253,254,5,102,0,0,
|
||||
254,255,5,108,0,0,255,256,5,111,0,0,256,257,5,111,0,0,257,258,5,
|
||||
114,0,0,258,56,1,0,0,0,259,260,5,99,0,0,260,261,5,101,0,0,261,262,
|
||||
5,105,0,0,262,263,5,108,0,0,263,58,1,0,0,0,264,265,5,114,0,0,265,
|
||||
266,5,111,0,0,266,267,5,117,0,0,267,268,5,110,0,0,268,269,5,100,
|
||||
0,0,269,60,1,0,0,0,270,271,5,103,0,0,271,272,5,97,0,0,272,273,5,
|
||||
109,0,0,273,274,5,109,0,0,274,275,5,97,0,0,275,62,1,0,0,0,276,277,
|
||||
5,112,0,0,277,278,5,111,0,0,278,279,5,119,0,0,279,64,1,0,0,0,280,
|
||||
281,5,115,0,0,281,282,5,105,0,0,282,283,5,103,0,0,283,284,5,109,
|
||||
0,0,284,66,1,0,0,0,285,286,5,99,0,0,286,287,5,108,0,0,287,288,5,
|
||||
97,0,0,288,289,5,109,0,0,289,290,5,112,0,0,290,68,1,0,0,0,291,292,
|
||||
5,102,0,0,292,293,5,102,0,0,293,294,5,116,0,0,294,70,1,0,0,0,295,
|
||||
296,5,105,0,0,296,297,5,102,0,0,297,298,5,102,0,0,298,299,5,116,
|
||||
0,0,299,72,1,0,0,0,300,301,5,97,0,0,301,302,5,110,0,0,302,303,5,
|
||||
103,0,0,303,304,5,108,0,0,304,305,5,101,0,0,305,74,1,0,0,0,306,307,
|
||||
5,112,0,0,307,308,5,114,0,0,308,309,5,105,0,0,309,310,5,110,0,0,
|
||||
310,311,5,116,0,0,311,76,1,0,0,0,312,313,5,108,0,0,313,314,5,101,
|
||||
0,0,314,315,5,114,0,0,315,316,5,112,0,0,316,78,1,0,0,0,317,318,5,
|
||||
115,0,0,318,319,5,116,0,0,319,320,5,101,0,0,320,321,5,112,0,0,321,
|
||||
80,1,0,0,0,322,323,5,115,0,0,323,324,5,109,0,0,324,325,5,111,0,0,
|
||||
325,326,5,111,0,0,326,327,5,116,0,0,327,328,5,104,0,0,328,329,5,
|
||||
115,0,0,329,330,5,116,0,0,330,331,5,101,0,0,331,332,5,112,0,0,332,
|
||||
82,1,0,0,0,333,334,5,102,0,0,334,335,5,114,0,0,335,336,5,97,0,0,
|
||||
336,337,5,99,0,0,337,338,5,116,0,0,338,84,1,0,0,0,339,340,5,114,
|
||||
0,0,340,341,5,101,0,0,341,342,5,108,0,0,342,343,5,117,0,0,343,86,
|
||||
1,0,0,0,344,345,5,115,0,0,345,346,5,111,0,0,346,347,5,102,0,0,347,
|
||||
348,5,116,0,0,348,349,5,112,0,0,349,350,5,108,0,0,350,351,5,117,
|
||||
0,0,351,352,5,115,0,0,352,88,1,0,0,0,353,354,5,103,0,0,354,355,5,
|
||||
101,0,0,355,356,5,108,0,0,356,357,5,117,0,0,357,90,1,0,0,0,358,359,
|
||||
5,115,0,0,359,360,5,105,0,0,360,361,5,103,0,0,361,362,5,110,0,0,
|
||||
362,92,1,0,0,0,363,364,5,115,0,0,364,365,5,119,0,0,365,366,5,97,
|
||||
0,0,366,367,5,112,0,0,367,94,1,0,0,0,368,369,5,43,0,0,369,96,1,0,
|
||||
0,0,370,371,5,45,0,0,371,98,1,0,0,0,372,373,5,42,0,0,373,100,1,0,
|
||||
0,0,374,375,5,47,0,0,375,102,1,0,0,0,376,377,5,37,0,0,377,104,1,
|
||||
0,0,0,378,379,5,94,0,0,379,106,1,0,0,0,380,381,5,62,0,0,381,382,
|
||||
5,61,0,0,382,108,1,0,0,0,383,384,5,62,0,0,384,110,1,0,0,0,385,386,
|
||||
5,60,0,0,386,387,5,61,0,0,387,112,1,0,0,0,388,389,5,60,0,0,389,114,
|
||||
1,0,0,0,390,391,5,61,0,0,391,392,5,61,0,0,392,116,1,0,0,0,393,394,
|
||||
5,33,0,0,394,395,5,61,0,0,395,118,1,0,0,0,396,397,5,124,0,0,397,
|
||||
120,1,0,0,0,398,399,5,112,0,0,399,404,5,105,0,0,400,401,5,80,0,0,
|
||||
401,404,5,73,0,0,402,404,7,0,0,0,403,398,1,0,0,0,403,400,1,0,0,0,
|
||||
403,402,1,0,0,0,404,122,1,0,0,0,405,407,7,1,0,0,406,405,1,0,0,0,
|
||||
407,408,1,0,0,0,408,406,1,0,0,0,408,409,1,0,0,0,409,416,1,0,0,0,
|
||||
410,412,5,46,0,0,411,413,7,1,0,0,412,411,1,0,0,0,413,414,1,0,0,0,
|
||||
414,412,1,0,0,0,414,415,1,0,0,0,415,417,1,0,0,0,416,410,1,0,0,0,
|
||||
416,417,1,0,0,0,417,124,1,0,0,0,418,422,7,2,0,0,419,421,7,3,0,0,
|
||||
420,419,1,0,0,0,421,424,1,0,0,0,422,420,1,0,0,0,422,423,1,0,0,0,
|
||||
423,126,1,0,0,0,424,422,1,0,0,0,425,427,7,4,0,0,426,425,1,0,0,0,
|
||||
427,428,1,0,0,0,428,426,1,0,0,0,428,429,1,0,0,0,429,430,1,0,0,0,
|
||||
430,431,6,63,0,0,431,128,1,0,0,0,7,0,403,408,414,416,422,428,1,6,
|
||||
0,0
|
||||
]
|
||||
|
||||
class MathExprLexer(Lexer):
|
||||
@@ -226,45 +229,46 @@ class MathExprLexer(Lexer):
|
||||
LT = 57
|
||||
EQ = 58
|
||||
NE = 59
|
||||
CONSTANT = 60
|
||||
NUMBER = 61
|
||||
VARIABLE = 62
|
||||
WS = 63
|
||||
PIPE = 60
|
||||
CONSTANT = 61
|
||||
NUMBER = 62
|
||||
VARIABLE = 63
|
||||
WS = 64
|
||||
|
||||
channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
|
||||
|
||||
modeNames = [ "DEFAULT_MODE" ]
|
||||
|
||||
literalNames = [ "<INVALID>",
|
||||
"'('", "')'", "','", "'sin'", "'cos'", "'tan'", "'asin'", "'acos'",
|
||||
"'atan'", "'atan2'", "'sinh'", "'cosh'", "'tanh'", "'asinh'",
|
||||
"'acosh'", "'atanh'", "'abs'", "'sqrt'", "'ln'", "'log'", "'exp'",
|
||||
"'smin'", "'smax'", "'tmin'", "'tmax'", "'tnorm'", "'snorm'",
|
||||
"'floor'", "'ceil'", "'round'", "'gamma'", "'pow'", "'sigm'",
|
||||
"'clamp'", "'fft'", "'ifft'", "'angle'", "'print'", "'lerp'",
|
||||
"'step'", "'smoothstep'", "'fract'", "'relu'", "'softplus'",
|
||||
"'gelu'", "'sign'", "'swap'", "'+'", "'-'", "'*'", "'/'", "'%'",
|
||||
"'^'", "'>='", "'>'", "'<='", "'<'", "'=='", "'!='" ]
|
||||
"'('", "')'", "','", "'sin'", "'cos'", "'tan'", "'asin'", "'acos'",
|
||||
"'atan'", "'atan2'", "'sinh'", "'cosh'", "'tanh'", "'asinh'",
|
||||
"'acosh'", "'atanh'", "'abs'", "'sqrt'", "'ln'", "'log'", "'exp'",
|
||||
"'smin'", "'smax'", "'tmin'", "'tmax'", "'tnorm'", "'snorm'",
|
||||
"'floor'", "'ceil'", "'round'", "'gamma'", "'pow'", "'sigm'",
|
||||
"'clamp'", "'fft'", "'ifft'", "'angle'", "'print'", "'lerp'",
|
||||
"'step'", "'smoothstep'", "'fract'", "'relu'", "'softplus'",
|
||||
"'gelu'", "'sign'", "'swap'", "'+'", "'-'", "'*'", "'/'", "'%'",
|
||||
"'^'", "'>='", "'>'", "'<='", "'<'", "'=='", "'!='", "'|'" ]
|
||||
|
||||
symbolicNames = [ "<INVALID>",
|
||||
"SIN", "COS", "TAN", "ASIN", "ACOS", "ATAN", "ATAN2", "SINH",
|
||||
"COSH", "TANH", "ASINH", "ACOSH", "ATANH", "ABS", "SQRT", "LN",
|
||||
"LOG", "EXP", "SMIN", "SMAX", "TMIN", "TMAX", "TNORM", "SNORM",
|
||||
"FLOOR", "CEIL", "ROUND", "GAMMA", "POWE", "SIGM", "CLAMP",
|
||||
"SFFT", "SIFFT", "ANGL", "PRNT", "LERP", "STEP", "SMOOTHSTEP",
|
||||
"FRACT", "RELU", "SOFTPLUS", "GELU", "SIGN", "SWAP", "PLUS",
|
||||
"MINUS", "MULT", "DIV", "MOD", "POW", "GE", "GT", "LE", "LT",
|
||||
"EQ", "NE", "CONSTANT", "NUMBER", "VARIABLE", "WS" ]
|
||||
"SIN", "COS", "TAN", "ASIN", "ACOS", "ATAN", "ATAN2", "SINH",
|
||||
"COSH", "TANH", "ASINH", "ACOSH", "ATANH", "ABS", "SQRT", "LN",
|
||||
"LOG", "EXP", "SMIN", "SMAX", "TMIN", "TMAX", "TNORM", "SNORM",
|
||||
"FLOOR", "CEIL", "ROUND", "GAMMA", "POWE", "SIGM", "CLAMP",
|
||||
"SFFT", "SIFFT", "ANGL", "PRNT", "LERP", "STEP", "SMOOTHSTEP",
|
||||
"FRACT", "RELU", "SOFTPLUS", "GELU", "SIGN", "SWAP", "PLUS",
|
||||
"MINUS", "MULT", "DIV", "MOD", "POW", "GE", "GT", "LE", "LT",
|
||||
"EQ", "NE", "PIPE", "CONSTANT", "NUMBER", "VARIABLE", "WS" ]
|
||||
|
||||
ruleNames = [ "T__0", "T__1", "T__2", "SIN", "COS", "TAN", "ASIN", "ACOS",
|
||||
"ATAN", "ATAN2", "SINH", "COSH", "TANH", "ASINH", "ACOSH",
|
||||
"ATANH", "ABS", "SQRT", "LN", "LOG", "EXP", "SMIN", "SMAX",
|
||||
"TMIN", "TMAX", "TNORM", "SNORM", "FLOOR", "CEIL", "ROUND",
|
||||
"GAMMA", "POWE", "SIGM", "CLAMP", "SFFT", "SIFFT", "ANGL",
|
||||
"PRNT", "LERP", "STEP", "SMOOTHSTEP", "FRACT", "RELU",
|
||||
"SOFTPLUS", "GELU", "SIGN", "SWAP", "PLUS", "MINUS", "MULT",
|
||||
"DIV", "MOD", "POW", "GE", "GT", "LE", "LT", "EQ", "NE",
|
||||
"CONSTANT", "NUMBER", "VARIABLE", "WS" ]
|
||||
ruleNames = [ "T__0", "T__1", "T__2", "SIN", "COS", "TAN", "ASIN", "ACOS",
|
||||
"ATAN", "ATAN2", "SINH", "COSH", "TANH", "ASINH", "ACOSH",
|
||||
"ATANH", "ABS", "SQRT", "LN", "LOG", "EXP", "SMIN", "SMAX",
|
||||
"TMIN", "TMAX", "TNORM", "SNORM", "FLOOR", "CEIL", "ROUND",
|
||||
"GAMMA", "POWE", "SIGM", "CLAMP", "SFFT", "SIFFT", "ANGL",
|
||||
"PRNT", "LERP", "STEP", "SMOOTHSTEP", "FRACT", "RELU",
|
||||
"SOFTPLUS", "GELU", "SIGN", "SWAP", "PLUS", "MINUS", "MULT",
|
||||
"DIV", "MOD", "POW", "GE", "GT", "LE", "LT", "EQ", "NE",
|
||||
"PIPE", "CONSTANT", "NUMBER", "VARIABLE", "WS" ]
|
||||
|
||||
grammarFileName = "MathExpr.g4"
|
||||
|
||||
|
||||
@@ -57,10 +57,11 @@ LE=56
|
||||
LT=57
|
||||
EQ=58
|
||||
NE=59
|
||||
CONSTANT=60
|
||||
NUMBER=61
|
||||
VARIABLE=62
|
||||
WS=63
|
||||
PIPE=60
|
||||
CONSTANT=61
|
||||
NUMBER=62
|
||||
VARIABLE=63
|
||||
WS=64
|
||||
'('=1
|
||||
')'=2
|
||||
','=3
|
||||
@@ -120,3 +121,4 @@ WS=63
|
||||
'<'=57
|
||||
'=='=58
|
||||
'!='=59
|
||||
'|'=60
|
||||
|
||||
+464
-428
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
# Generated from src/more_math/Parser/MathExpr.g4 by ANTLR 4.13.2
|
||||
from antlr4 import ParseTreeVisitor
|
||||
# Generated from ./MathExpr.g4 by ANTLR 4.13.2
|
||||
from antlr4 import *
|
||||
if "." in __name__:
|
||||
from .MathExprParser import MathExprParser
|
||||
else:
|
||||
@@ -154,6 +154,11 @@ class MathExprVisitor(ParseTreeVisitor):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by MathExprParser#AbsExp.
|
||||
def visitAbsExp(self, ctx:MathExprParser.AbsExpContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by MathExprParser#SinFunc.
|
||||
def visitSinFunc(self, ctx:MathExprParser.SinFuncContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
@@ -116,6 +116,7 @@ class TensorEvalVisitor(MathExprVisitor):
|
||||
def visitAcoshFunc(self, ctx): return torch.acosh(self.visit(ctx.expr()))
|
||||
def visitAtanhFunc(self, ctx): return torch.atanh(self.visit(ctx.expr()))
|
||||
def visitAbsFunc(self, ctx): return torch.abs(self.visit(ctx.expr()))
|
||||
def visitNormExp(self, ctx): return torch.full(self.shape, torch.linalg.norm(self.visit(ctx.expr())).item(), device=self.device)
|
||||
def visitSqrtFunc(self, ctx): return torch.sqrt(self.visit(ctx.expr()))
|
||||
def visitLnFunc(self, ctx): return torch.log(self.visit(ctx.expr()))
|
||||
def visitLogFunc(self, ctx): return torch.log10(self.visit(ctx.expr()))
|
||||
|
||||
Reference in New Issue
Block a user