flamapy / fm_metamodel

This repo host the feature model concrete classes
3 stars 5 forks source link

Adapt fm reader to ASTOperation enum #39

Closed jmhorcas closed 2 years ago

jmhorcas commented 3 years ago

@pabpazjim could you check and adapt these couple of line in the afm_reader, so that it uses the ASTOperation enumeration instead of "str" for the OR, AND, IMPLIES/REQUIRES,.... operations? In case of relational and arithmetic you can leave them as is for now.

Take a look to line 194 for an example of NOT operation.

binary_operation_types = []
binary_operation_types.append(AFMParser.LogicalExpContext)
binary_operation_types.append(AFMParser.OrExpContext)
binary_operation_types.append(AFMParser.AndExpContext)
binary_operation_types.append(AFMParser.RelationalExpContext)
binary_operation_types.append(AFMParser.ArithmeticExpContext)

if expression.__class__ in binary_operation_types:
    # TODO: change str binary operation types for enumerations in ASTOperation 
    result = result = Node(expression.getChild(1).getText())
    result.left = self.build_ast_node(
        expression.expression()[0], prefix)
    result.right = self.build_ast_node(
        expression.expression()[1], prefix)
jagalindo commented 2 years ago

This has been integrated