Пример #1
0
 def visitUnit_infinity(self, ctx: parse.Unit_infinityContext):
     """unit_infinity
     inf=(INFINITY | NEG_INFINITY)"""
     if ctx.inf.type == parse.INFINITY:
         return RealNumber(float("inf"))
     else:
         return RealNumber(float("-inf"))
Пример #2
0
 def visitTex_symb_single(self, ctx: parse.Tex_symb_singleContext):
     """tex_symb_single
     (NON_EI_LETTER | E | I | DIGIT) """
     if ctx.E():
         return RealNumber(np.e)
     if ctx.I():
         return ComplexNumber.create(RealNumber(0), RealNumber(1))
     text = ctx.getText()
     if ctx.DIGIT():
         return RealNumber(int(text))
     else:
         return Variable(self.state, text)
Пример #3
0
 def visitMult_sign(self, ctx: parse.Mult_signContext):
     """mult_sign
     sign=(PLUS | MINUS) mult_expr """
     if ctx.sign.type == parse.MINUS:
         return Expression(op.mul, RealNumber(-1),
                           self.visit(ctx.mult_expr()))
     else:
         return self.visit(ctx.mult_expr())
Пример #4
0
 def visitNnint(self, ctx: parse.NnintContext):
     """nnint
     DIGIT+ """
     return RealNumber(int(ctx.getText()))
Пример #5
0
 def visitNumber(self, ctx: parse.NumberContext):
     """number
     MINUS? DIGIT+ (POINT DIGIT*)? """
     return RealNumber(float(ctx.getText()))
Пример #6
0
 def visitUnit_i(self, ctx: parse.Unit_iContext):
     # i = 0 + 1i
     return ComplexNumber.create(RealNumber(0), RealNumber(1))
Пример #7
0
 def visitUnit_e(self, ctx: parse.Unit_eContext):
     return RealNumber(math.e)
Пример #8
0
 def visitUnit_pi(self, ctx: parse.Unit_piContext):
     return RealNumber(math.pi)