Ejemplo n.º 1
0
 def p_constant_def_2(p):
     """
     constant_def : structured_comment CONST INT8 ID '=' boolean_val
                  | structured_comment CONST INT16 ID '=' boolean_val
                  | structured_comment CONST INT32 ID '=' boolean_val
                  | structured_comment CONST INT64 ID '=' boolean_val
                  | structured_comment CONST UINT8 ID '=' boolean_val
                  | structured_comment CONST UINT16 ID '=' boolean_val
                  | structured_comment CONST UINT32 ID '=' boolean_val
                  | structured_comment CONST UINT64 ID '=' boolean_val
                  | structured_comment CONST INT8 ID '=' real_val
                  | structured_comment CONST INT16 ID '=' real_val
                  | structured_comment CONST INT32 ID '=' real_val
                  | structured_comment CONST INT64 ID '=' real_val
                  | structured_comment CONST UINT8 ID '=' real_val
                  | structured_comment CONST UINT16 ID '=' real_val
                  | structured_comment CONST UINT32 ID '=' real_val
                  | structured_comment CONST UINT64 ID '=' real_val
     """
     type_class = getattr(ast, p[3])
     value = ast.IntegerValue(int(p[6].value))
     p[0] = ast.Constant(name=p[4],
                         element_type=type_class(),
                         element_value=value,
                         comments=p[1])
Ejemplo n.º 2
0
 def p_constant_def_6(p):
     """
     constant_def : structured_comment CONST STRING ID '=' value
     """
     type_class = getattr(ast, p[3])
     value = ast.StringValue(str(p[6].value))
     p[0] = ast.Constant(name=p[4],
                         element_type=type_class(),
                         element_value=value,
                         comments=p[1])
Ejemplo n.º 3
0
 def p_constant_def_5(p):
     """
     constant_def : structured_comment CONST BOOLEAN ID '=' value
     """
     type_class = getattr(ast, p[3])
     value = ast.BooleanValue(bool(p[6].value))
     p[0] = ast.Constant(name=p[4],
                         element_type=type_class(),
                         element_value=value,
                         comments=p[1])
Ejemplo n.º 4
0
 def p_constant_def_4(p):
     """
     constant_def : structured_comment CONST DOUBLE ID '=' integer_val
                  | structured_comment CONST DOUBLE ID '=' boolean_val
                  | structured_comment CONST DOUBLE ID '=' real_val
     """
     type_class = getattr(ast, p[3])
     value = ast.DoubleValue(float(p[6].value))
     p[0] = ast.Constant(name=p[4],
                         element_type=type_class(),
                         element_value=value,
                         comments=p[1])