示例#1
0
 def exprCheck(expr, output=None):
     class Config:
         c_id_attributes = ["id_attr"]
         c_paren_attributes = ["paren_attr"]
     parser = DefinitionParser(expr, location=None, config=Config())
     parser.allowFallbackExpressionParsing = False
     ast = parser.parse_expression()
     parser.assert_end()
     # first a simple check of the AST
     if output is None:
         output = expr
     res = str(ast)
     if res != output:
         print("")
         print("Input:    ", input)
         print("Result:   ", res)
         print("Expected: ", output)
         raise DefinitionError("")
     displayString = ast.get_display_string()
     if res != displayString:
         # note: if the expression contains an anon name then this will trigger a falsely
         print("")
         print("Input:    ", expr)
         print("Result:   ", res)
         print("Display:  ", displayString)
         raise DefinitionError("")
示例#2
0
def parse(name, string):
    class Config:
        c_id_attributes = ["id_attr", 'LIGHTGBM_C_EXPORT']
        c_paren_attributes = ["paren_attr"]
    parser = DefinitionParser(string, location=None, config=Config())
    parser.allowFallbackExpressionParsing = False
    ast = parser.parse_declaration(name, name)
    parser.assert_end()
    return ast
示例#3
0
 def exprCheck(expr, output=None):
     parser = DefinitionParser(expr, location=None)
     parser.allowFallbackExpressionParsing = False
     ast = parser.parse_expression()
     parser.assert_end()
     # first a simple check of the AST
     if output is None:
         output = expr
     res = str(ast)
     if res != output:
         print("")
         print("Input:    ", input)
         print("Result:   ", res)
         print("Expected: ", output)
         raise DefinitionError("")
示例#4
0
 def exprCheck(expr, output=None):
     class Config:
         c_id_attributes = ["id_attr"]
         c_paren_attributes = ["paren_attr"]
     parser = DefinitionParser(expr, location=None, config=Config())
     parser.allowFallbackExpressionParsing = False
     ast = parser.parse_expression()
     parser.assert_end()
     # first a simple check of the AST
     if output is None:
         output = expr
     res = str(ast)
     if res != output:
         print("")
         print("Input:    ", input)
         print("Result:   ", res)
         print("Expected: ", output)
         raise DefinitionError("")
示例#5
0
def parse(name, string):
    parser = DefinitionParser(string, location=None, config=Config())
    parser.allowFallbackExpressionParsing = False
    ast = parser.parse_declaration(name, name)
    parser.assert_end()
    return ast