Package madgraph :: Package iolibs :: Module ufo_expression_parsers :: Class UFOExpressionParserPythonIF
[hide private]
[frames] | no frames]

Class UFOExpressionParserPythonIF

source code

         object --+    
                  |    
UFOExpressionParser --+
                      |
                     UFOExpressionParserPythonIF

An ad hoc parser for UFO algebraic expressions with if statement, outputting Python-style code, with the conditional 'if' expressions simplified using pre-defined set of variables specified when instanciating this parser.

Instance Methods [hide private]
 
__init__(self, *args, **kw)
Initialize the lex and yacc
source code
 
parse(self, *args, **kw)
Wrapper around the parse function so as to also return the number of if substitutions made.
source code
 
p_expression_number(self, p)
expression : NUMBER
source code
 
p_expression_variable(self, p)
expression : VARIABLE
source code
 
p_expression_power(self, p)
expression : expression POWER expression
source code
 
p_expression_if(self, p)
expression : expression IF boolexpression ELSE expression
source code
 
p_expression_ifimplicit(self, p)
expression : expression IF expression ELSE expression
source code
 
p_expression_cond(self, p)
expression : COND '(' expression ',' expression ',' expression ')'
source code
 
p_expression_complex(self, p)
expression : COMPLEX '(' expression ',' expression ')'
source code
 
p_expression_recms(self, p)
expression : RECMS '(' boolexpression ',' expression ')'
source code
 
p_expression_func(self, p)
expression : CSC group | SEC group | ACSC group | ASEC group | RE group | IM group | ARG group | SQRT group | TAN group | ATAN group | CONJ group | REGLOG group | REGLOGP group | REGLOGM group | BUILTIN group
source code
 
p_expression_real(self, p)
expression : expression RE2
source code
 
p_expression_pi(self, p)
expression : PI
source code

Inherited from UFOExpressionParser: build, clean, p_error, p_expression_binop, p_expression_function1, p_expression_function2, p_expression_function3, p_expression_function4, p_expression_group, p_expression_logical, p_expression_logicalcomb, p_expression_uminus, p_group_parentheses, p_group_parentheses_boolexpr, p_statement_expr, t_ACSC, t_ARG, t_ASEC, t_ATAN, t_BUILTIN, t_COMPLEX, t_COND, t_CONJ, t_CSC, t_ELSE, t_FUNCTION, t_IF, t_IM, t_LOGICAL, t_LOGICALCOMB, t_PI, t_RE, t_RE2, t_RECMS, t_REGLOG, t_REGLOGM, t_REGLOGP, t_SEC, t_SQRT, t_TAN, t_VARIABLE, t_error, t_newline

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  logical_equiv = {'!=': '!=', '<': '<', '<=': '<=', '==': '==',...
  builtin_equiv = {'abs': 'abs', 'bool': 'bool', 'float': 'float...

Inherited from UFOExpressionParser: literals, parsed_string, precedence, re_cmath_function, t_NUMBER, t_POWER, t_ignore, tokens

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args, **kw)
(Constructor)

source code 

Initialize the lex and yacc

Overrides: object.__init__

parse(self, *args, **kw)

source code 

Wrapper around the parse function so as to also return the number of if substitutions made.

Overrides: UFOExpressionParser.parse

Class Variable Details [hide private]

logical_equiv

Value:
{'!=': '!=',
 '<': '<',
 '<=': '<=',
 '==': '==',
 '>': '>',
 '>=': '>=',
 'and': ' and ',
 'or': ' or '}

builtin_equiv

Value:
{'abs': 'abs',
 'bool': 'bool',
 'float': 'float',
 'int': 'int',
 'max': 'max',
 'min': 'min'}