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

Class UFOExpressionParser

source code

object --+
         |
        UFOExpressionParser
Known Subclasses:

A base class for parsers for algebraic expressions coming from UFO.

Instance Methods [hide private]
 
__init__(self, **kw)
Initialize the lex and yacc
source code
 
parse(self, buf)
Parse the string buf
source code
 
t_CSC(self, t)
(?<!\w)csc(?=\()
source code
 
t_SEC(self, t)
(?<!\w)sec(?=\()
source code
 
t_ACSC(self, t)
(?<!\w)acsc(?=\()
source code
 
t_TAN(self, t)
(?<!\w)tan(?=\()|(?<!\w)cmath.tan(?=\()
source code
 
t_ATAN(self, t)
(?<!\w)atan(?=\()|(?<!\w)cmath.atan(?=\()
source code
 
t_ASEC(self, t)
(?<!\w)asec(?=\()
source code
 
t_REGLOG(self, t)
(?<!\w)reglog(?=\()
source code
 
t_REGLOGP(self, t)
(?<!\w)reglogp(?=\()
source code
 
t_REGLOGM(self, t)
(?<!\w)reglogm(?=\()
source code
 
t_RECMS(self, t)
(?<!\w)recms(?=\()
source code
 
t_COND(self, t)
(?<!\w)cond(?=\()
source code
 
t_ARG(self, t)
(?<!\w)arg(?=\()
source code
 
t_IF(self, t)
(?<!\w)if\s
source code
 
t_ELSE(self, t)
(?<!\w)else\s
source code
 
t_LOGICAL(self, t)
==|!=|<=|>=|<|>
source code
 
t_LOGICALCOMB(self, t)
(?<!\w)and(?=[\s\(])|(?<!\w)or(?=[\s\(])
source code
 
t_SQRT(self, t)
cmath\.sqrt
source code
 
t_PI(self, t)
cmath\.pi
source code
 
t_CONJ(self, t)
complexconjugate
source code
 
t_BUILTIN(self, t)
(?<!\w)abs|bool|float|int|min|max(?=\()
source code
 
t_IM(self, t)
(?<!\w)im(?=\()
source code
 
t_RE(self, t)
(?<!\w)re(?=\()
source code
 
t_RE2(self, t)
\.real|\.imag|\.conjugate\(\)
source code
 
t_COMPLEX(self, t)
(?<!\w)complex(?=\()
source code
 
t_FUNCTION(self, t)
(cmath\.){0,1}[a-zA-Z_][0-9a-zA-Z_]*(?=\()
source code
 
t_VARIABLE(self, t)
[a-zA-Z_][0-9a-zA-Z_]*
source code
 
t_newline(self, t)
\n+
source code
 
t_error(self, t) source code
 
clean(self)
remove variable related to the latest parsing
source code
 
build(self, **kwargs) source code
 
p_statement_expr(self, p)
statement : expression
source code
 
p_expression_binop(self, p)
expression : expression '=' expression | expression '+' expression | expression '-' expression | expression '*' expression | expression '/' expression
source code
 
p_expression_logical(self, p)
boolexpression : expression LOGICAL expression
source code
 
p_expression_logicalcomb(self, p)
boolexpression : boolexpression LOGICALCOMB boolexpression
source code
 
p_expression_uminus(self, p)
expression : '-' expression %prec UMINUS
source code
 
p_group_parentheses(self, p)
group : '(' expression ')'
source code
 
p_group_parentheses_boolexpr(self, p)
boolexpression : '(' boolexpression ')'
source code
 
p_expression_group(self, p)
expression : group
source code
 
p_expression_function1(self, p)
expression : FUNCTION '(' expression ')'
source code
 
p_expression_function2(self, p)
expression : FUNCTION '(' expression ',' expression ')'
source code
 
p_expression_function3(self, p)
expression : FUNCTION '(' expression ',' expression ',' expression ')'
source code
 
p_expression_function4(self, p)
expression : FUNCTION '(' expression ',' expression ',' expression ',' expression ')'
source code
 
p_error(self, p) source code

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

Class Variables [hide private]
  parsed_string = ''
  logical_equiv = {}
  tokens = ('LOGICAL', 'LOGICALCOMB', 'POWER', 'CSC', 'SEC', 'AC...
  literals = '=+-*/(),'
  t_NUMBER = '([0-9]+\\.[0-9]*|\\.[0-9]+|[0-9]+)([eE][+-]{0,1}[0...
  t_POWER = '\\*\\*'
  t_ignore = ' \t'
  re_cmath_function = re.compile(r'cmath\.(?P<name>[0-9a-zA-Z_]+)')
  precedence = (('right', 'LOGICALCOMB'), ('right', 'LOGICAL'), ...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, **kw)
(Constructor)

source code 

Initialize the lex and yacc

Overrides: object.__init__

Class Variable Details [hide private]

tokens

Value:
('LOGICAL',
 'LOGICALCOMB',
 'POWER',
 'CSC',
 'SEC',
 'ACSC',
 'ASEC',
 'TAN',
...

t_NUMBER

Value:
'([0-9]+\\.[0-9]*|\\.[0-9]+|[0-9]+)([eE][+-]{0,1}[0-9]+){0,1}j{0,1}'

precedence

Value:
(('right', 'LOGICALCOMB'),
 ('right', 'LOGICAL'),
 ('right', 'IF'),
 ('right', 'ELSE'),
 ('left', '='),
 ('left', '+', '-'),
 ('left', '*', '/'),
 ('left', 'RE2'),
...