|
3 | 3 | from __future__ import division |
4 | 4 | from __future__ import print_function |
5 | 5 |
|
6 | | -from ..identifiers import IDs |
7 | | -from ..parser import Operator, Function, Parser |
| 6 | +from ..identifiers import IDs, ConstantIDs |
| 7 | +from ..parser import POperator, PFunction, Parser, PConstant |
8 | 8 |
|
9 | 9 |
|
10 | 10 | __all__ = [ |
|
13 | 13 |
|
14 | 14 |
|
15 | 15 | config = [ |
16 | | - Operator(IDs.MINUS, '-', rhs_only=True), |
17 | | - Operator(IDs.PLUS, '+', rhs_only=True), |
18 | | - Operator(IDs.ADD, '+'), |
19 | | - Operator(IDs.SUB, '-'), |
20 | | - Operator(IDs.MUL, '*'), |
21 | | - Operator(IDs.DIV, '/'), |
22 | | - Operator(IDs.MOD, '%'), |
| 16 | + POperator(IDs.MINUS, '-', rhs_only=True), |
| 17 | + POperator(IDs.PLUS, '+', rhs_only=True), |
| 18 | + POperator(IDs.ADD, '+'), |
| 19 | + POperator(IDs.SUB, '-'), |
| 20 | + POperator(IDs.MUL, '*'), |
| 21 | + POperator(IDs.DIV, '/'), |
| 22 | + POperator(IDs.MOD, '%'), |
23 | 23 |
|
24 | | - Operator(IDs.EQ, '=='), |
25 | | - Operator(IDs.NEQ, '!='), |
26 | | - Operator(IDs.GT, '>'), |
27 | | - Operator(IDs.GTEQ, '>='), |
28 | | - Operator(IDs.LT, '<'), |
29 | | - Operator(IDs.LTEQ, '<='), |
| 24 | + POperator(IDs.EQ, '=='), |
| 25 | + POperator(IDs.NEQ, '!='), |
| 26 | + POperator(IDs.GT, '>'), |
| 27 | + POperator(IDs.GTEQ, '>='), |
| 28 | + POperator(IDs.LT, '<'), |
| 29 | + POperator(IDs.LTEQ, '<='), |
30 | 30 |
|
31 | | - Operator(IDs.AND, '&&'), |
32 | | - Operator(IDs.OR, '||'), |
33 | | - Operator(IDs.NOT, '!', rhs_only=True), |
| 31 | + POperator(IDs.AND, '&&'), |
| 32 | + POperator(IDs.OR, '||'), |
| 33 | + POperator(IDs.NOT, '!', rhs_only=True), |
34 | 34 |
|
35 | | - Function(IDs.SQRT, 'sqrt'), |
36 | | - Function(IDs.SQRT, 'TMath::Sqrt'), |
37 | | - Function(IDs.ABS, 'TMath::Abs'), |
| 35 | + PFunction(IDs.SQRT, 'sqrt'), |
| 36 | + PFunction(IDs.SQRT, 'TMath::Sqrt'), |
| 37 | + PFunction(IDs.ABS, 'TMath::Abs'), |
38 | 38 |
|
39 | | - Function(IDs.LOG, 'log'), |
40 | | - Function(IDs.LOG, 'TMath::Log'), |
41 | | - Function(IDs.LOG2, 'log2'), |
42 | | - Function(IDs.LOG2, 'TMath::Log2'), |
43 | | - Function(IDs.LOG10, 'log10'), |
44 | | - Function(IDs.LOG10, 'TMath::Log10'), |
| 39 | + PFunction(IDs.LOG, 'log'), |
| 40 | + PFunction(IDs.LOG, 'TMath::Log'), |
| 41 | + PFunction(IDs.LOG2, 'log2'), |
| 42 | + PFunction(IDs.LOG2, 'TMath::Log2'), |
| 43 | + PFunction(IDs.LOG10, 'log10'), |
| 44 | + PFunction(IDs.LOG10, 'TMath::Log10'), |
45 | 45 |
|
46 | | - Function(IDs.EXP, 'exp'), |
47 | | - Function(IDs.EXP, 'TMath::Exp'), |
| 46 | + PFunction(IDs.EXP, 'exp'), |
| 47 | + PFunction(IDs.EXP, 'TMath::Exp'), |
48 | 48 |
|
49 | | - Function(IDs.SIN, 'sin'), |
50 | | - Function(IDs.SIN, 'TMath::Sin'), |
51 | | - Function(IDs.ASIN, 'arcsin'), |
52 | | - Function(IDs.ASIN, 'TMath::ASin'), |
53 | | - Function(IDs.COS, 'cos'), |
54 | | - Function(IDs.COS, 'TMath::Cos'), |
55 | | - Function(IDs.ACOS, 'arccos'), |
56 | | - Function(IDs.ACOS, 'TMath::ACos'), |
57 | | - Function(IDs.TAN, 'tan'), |
58 | | - Function(IDs.TAN, 'TMath::Tan'), |
59 | | - Function(IDs.ATAN, 'arctan'), |
60 | | - Function(IDs.ATAN, 'TMath::ATan'), |
61 | | - Function(IDs.ATAN2, 'arctan2', 2), |
62 | | - Function(IDs.ATAN2, 'TMath::ATan2', 2), |
| 49 | + PFunction(IDs.SIN, 'sin'), |
| 50 | + PFunction(IDs.SIN, 'TMath::Sin'), |
| 51 | + PFunction(IDs.ASIN, 'arcsin'), |
| 52 | + PFunction(IDs.ASIN, 'TMath::ASin'), |
| 53 | + PFunction(IDs.COS, 'cos'), |
| 54 | + PFunction(IDs.COS, 'TMath::Cos'), |
| 55 | + PFunction(IDs.ACOS, 'arccos'), |
| 56 | + PFunction(IDs.ACOS, 'TMath::ACos'), |
| 57 | + PFunction(IDs.TAN, 'tan'), |
| 58 | + PFunction(IDs.TAN, 'TMath::Tan'), |
| 59 | + PFunction(IDs.ATAN, 'arctan'), |
| 60 | + PFunction(IDs.ATAN, 'TMath::ATan'), |
| 61 | + PFunction(IDs.ATAN2, 'arctan2', 2), |
| 62 | + PFunction(IDs.ATAN2, 'TMath::ATan2', 2), |
63 | 63 | ] |
64 | 64 |
|
| 65 | +constants = [ |
| 66 | + PConstant(ConstantIDs.TRUE, 'true'), |
| 67 | + PConstant(ConstantIDs.FALSE, 'false'), |
65 | 68 |
|
66 | | -root_parser = Parser('ROOT', config) |
| 69 | + PConstant(ConstantIDs.SQRT2, 'sqrt2'), |
| 70 | + PConstant(ConstantIDs.SQRT2, 'TMath::Sqrt2()'), |
| 71 | + PConstant(ConstantIDs.E, 'e'), |
| 72 | + PConstant(ConstantIDs.E, 'TMath::E()'), |
| 73 | + PConstant(ConstantIDs.PI, 'pi'), |
| 74 | + PConstant(ConstantIDs.PI, 'TMath::Pi()'), |
| 75 | + PConstant(ConstantIDs.INVPI, 'TMath::InvPi()'), |
| 76 | + PConstant(ConstantIDs.PIOVER2, 'TMath::PiOver2()'), |
| 77 | + PConstant(ConstantIDs.PIOVER4, 'TMath::PiOver4()'), |
| 78 | + PConstant(ConstantIDs.TAU, 'TMath::TwoPi()'), |
| 79 | + PConstant(ConstantIDs.LN10, 'ln10'), |
| 80 | + PConstant(ConstantIDs.LN10, 'TMath::Ln10()'), |
| 81 | + PConstant(ConstantIDs.LOG10E, 'TMath::LogE()'), |
| 82 | +] |
| 83 | + |
| 84 | +root_parser = Parser('ROOT', config, constants) |
0 commit comments