示例#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])
示例#2
0
 def p_integer_val_3(p):
     """
     integer_val : BINARY_VAL
     """
     p[0] = ast.IntegerValue(p[1], ast.IntegerValue.BINARY)
示例#3
0
 def p_integer_val_2(p):
     """
     integer_val : HEXADECIMAL_VAL
     """
     p[0] = ast.IntegerValue(p[1], ast.IntegerValue.HEXADECIMAL)
示例#4
0
 def p_integer_val(p):
     """
     integer_val : INTEGER_VAL
     """
     p[0] = ast.IntegerValue(p[1])