xing-hu / EMSE-DeepCom

The dataset for EMSE-DeepCom
MIT License
118 stars 63 forks source link

Generate strange AST #24

Open TranSMS opened 3 years ago

TranSMS commented 3 years ago

@xing-hu Hi, I want to ask you a question. When generating an AST from get_AST.py file, the AST tree obtained is strange. An example is shown below: e.g. [{"id": 0, "type": "MethodDeclaration(annotations=[], body=[ReturnStatement(expression=MethodInvocation(arguments=[], member=size, postfix_operators=[], prefix_operators=[], qualifier=gralComponents, selectors=[], type_arguments=None), label=None)], documentation=None, modifiers={'public'}, name=numGeneratedSequences, parameters=[], return_type=BasicType(dimensions=[], name=int), throws=None, type_parameters=None)", "children": [1, 2], "value": "numGeneratedSequences"}, {"id": 1, "type": "BasicType(dimensions=[], name=int)", "value": "int"}, {"id": 2, "type": "ReturnStatement(expression=MethodInvocation(arguments=[], member=size, postfix_operators=[], prefix_operators=[], qualifier=gralComponents, selectors=[], type_arguments=None), label=None)", "children": [3], "value": "return"}, {"id": 3, "type": "MethodInvocation(arguments=[], member=size, postfix_operators=[], prefix_operators=[], qualifier=gralComponents, selectors=[], type_arguments=None)", "value": "gralComponents.size"}]

How to generate the AST described in the literature? e.g. [{"id": 0, "type": "MethodDeclaration", "children": [1, 2], "value": "doesNotHaveIds"}, {"id": 1, "type": "BasicType", "value": "boolean"}, {"id": 2, "type": "ReturnStatement", "children": [3], "value": "return"}, {"id": 3, "type": "BinaryOperation", "children": [4, 7]}, {"id": 4, "type": "BinaryOperation", "children": [5, 6]}, {"id": 5, "type": "MethodInvocation", "value": "getIds"}, {"id": 6, "type": "Literal", "value": "null"}, {"id": 7, "type": "MethodInvocation", "children": [8, 9], "value": "getIds"}, {"id": 8, "type": "MethodInvocation", "value": "."}, {"id": 9, "type": "MethodInvocation", "value": "."} ]