~maddevelopers/mg5amcnlo/3.0.2

« back to all changes in this revision

Viewing changes to aloha/aloha_parsers.py

  • Committer: Marco Zaro
  • Date: 2014-01-27 16:54:10 UTC
  • mfrom: (78.124.55 MG5_aMC_2.1)
  • Revision ID: marco.zaro@gmail.com-20140127165410-5lma8c2hzbzm426j
merged with lp:~maddevelopers/madgraph5/MG5_aMC_2.1 r 267

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
################################################################################
2
2
#
3
 
# Copyright (c) 2009 The MadGraph Development team and Contributors
 
3
# Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors
4
4
#
5
 
# This file is a part of the MadGraph 5 project, an application which 
 
5
# This file is a part of the MadGraph5_aMC@NLO project, an application which 
6
6
# automatically generates Feynman diagrams and matrix elements for arbitrary
7
7
# high-energy processes in the Standard Model and beyond.
8
8
#
9
 
# It is subject to the MadGraph license which should accompany this 
 
9
# It is subject to the MadGraph5_aMC@NLO license which should accompany this 
10
10
# distribution.
11
11
#
12
 
# For more information, please visit: http://madgraph.phys.ucl.ac.be
 
12
# For more information, visit madgraph.phys.ucl.ac.be and amcatnlo.web.cern.ch
13
13
#
14
14
################################################################################
15
15
 
187
187
 
188
188
    def p_error(self, p):
189
189
        if p:
 
190
            print p[:]
190
191
            raise Exception("Syntax error at '%s' in '%s'" % (p.value, self.f))
191
192
        else:
192
193
            logger.error("Syntax error at EOF")
202
203
 
203
204
    def p_expression_pi(self, p):
204
205
        '''expression : PI'''
205
 
        p[0] = 'M_PI'
 
206
        KERNEL.has_pi = True
 
207
        p[0] = 'Param(\'PI\')'
206
208
 
207
209
    def p_expression_power(self, p):
208
210
        'expression : expression POWER expression'
217
219
             new = aloha_lib.KERNEL.add_function_expression('pow', eval(p[1]), eval(p[3]))
218
220
             p[0] = str(new)
219
221
 
 
222
 
220
223
    def p_expression_variable(self, p):
221
224
        "expression : VARIABLE"
222
 
        p[0] = p[1]
 
225
        p[0] = 'Param(\'%s\')' % p[1]
223
226
        
224
227
    def p_expression_variable2(self, p):
225
228
        "expression : '\\'' VARIABLE '\\''"
281
284
        new = aloha_lib.KERNEL.add_function_expression(p1, eval(p[3]), eval(p[5]))
282
285
        p[0] = str(new)
283
286
    
 
287
    def p_expression_function3(self, p):
 
288
        "expression : FUNCTION '(' expression ',' expression ',' expression ')'"
 
289
        
 
290
        if p[1] in self.aloha_object:
 
291
            p[0] = p[1]+'('+p[3]+','+ p[5]+','+p[7]+')'
 
292
            return
 
293
        
 
294
        p1 = p[1]
 
295
        re_groups = self.re_cmath_function.match(p1)
 
296
        if re_groups:
 
297
            p1 = re_groups.group("name")
 
298
 
 
299
        new = aloha_lib.KERNEL.add_function_expression(p1, eval(p[3]), eval(p[5]),eval(p[7]))
 
300
        p[0] = str(new)
 
301
 
284
302
    
285
303
    def p_expression_binop(self, p):
286
304
        '''expression : expression '=' expression