/** * {@inheritDoc} * * <p>The default implementation initializes the aggregate result to * {@link #defaultResult defaultResult()}. Before visiting each child, it * calls {@link #shouldVisitNextChild shouldVisitNextChild}; if the result * is {@code false} no more children are visited and the current aggregate * result is returned. After visiting a child, the aggregate result is * updated by calling {@link #aggregateResult aggregateResult} with the * previous aggregate result and the result of visiting the child.</p> * * <p>The default implementation is not safe for use in visitors that modify * the tree structure. Visitors that modify the tree should override this * method to behave properly in respect to the specific algorithm in use.</p> */ @Override public T visitChildren(RuleNode node) { T result = defaultResult(); int n = node.getChildCount(); for (int i=0; i<n; i++) { if (!shouldVisitNextChild(node, result)) { break; } ParseTree c = node.getChild(i); T childResult = c.accept(this); result = aggregateResult(result, childResult); } return result; }
/** * {@inheritDoc} * * <p>The default implementation returns the result of * {@link #defaultResult defaultResult}.</p> */ @Override public T visitTerminal(TerminalNode node) { return defaultResult(); }
public ArrayList<Symbol> parseVariable(VariableImpl variable) { ArrayList<Symbol> symbols = new ArrayList<>(); AbstractParseTreeVisitor parseTreeVisitor = new ObjectiveCParserBaseVisitor() { @Override public Object visitSpecifierQualifierList(ObjectiveCParser.SpecifierQualifierListContext ctx) { ClassImpl type = new ClassImpl(ctx.getText(), variable); variable.setType(type); return super.visitSpecifierQualifierList(ctx); } }; parseTreeVisitor.visit(variable.getRuleContext()); return symbols; }
/** * {@inheritDoc} * * <p>The default implementation returns the result of * {@link #defaultResult defaultResult}.</p> */ @Override public T visitErrorNode(ErrorNode node) { return defaultResult(); }
@Override public ArrayList<Symbol> parseVariable(VariableImpl variable) { ArrayList<Symbol> symbols = new ArrayList<>(); AbstractParseTreeVisitor parseTreeVisitor = new Java8BaseVisitor() { /** * variable name */ @Override public Object visitVariableDeclaratorId(Java8Parser.VariableDeclaratorIdContext ctx) { return super.visitVariableDeclaratorId(ctx); } }; parseTreeVisitor.visit(variable.getRuleContext()); return symbols; }
/** * {@inheritDoc} * * <p>The default implementation initializes the aggregate result to * {@link #defaultResult defaultResult()}. Before visiting each child, it * calls {@link #shouldVisitNextChild shouldVisitNextChild}; if the result * is {@code false} no more children are visited and the current aggregate * result is returned. After visiting a child, the aggregate result is * updated by calling {@link #aggregateResult aggregateResult} with the * previous aggregate result and the result of visiting the child.</p> * * <p>The default implementation is not safe for use in visitors that modify * the tree structure. Visitors that modify the tree should override this * method to behave properly in respect to the specific algorithm in use.</p> */ @Override public T visitChildren(RuleNode node) { T result = defaultResult(); int n = node.getChildCount(); for (int i=0; i<n; i++) { if (!shouldVisitNextChild(node, result)) { break; } ParseTree c = node.getChild(i); T childResult = c.accept(this); result = aggregateResult(result, childResult); } return result; }
/** * {@inheritDoc} * * <p>The default implementation returns the result of * {@link #defaultResult defaultResult}.</p> */ @Override public T visitErrorNode(ErrorNode node) { return defaultResult(); }
@Override public ArrayList<Symbol> parseEnumerator(EnumeratorImpl enumerator) { ArrayList<Symbol> symbols = new ArrayList<>(); AbstractParseTreeVisitor parseTreeVisitor = new Java8BaseVisitor() { /** * enums */ @Override public Object visitEnumConstant(Java8Parser.EnumConstantContext ctx) { return super.visitEnumConstant(ctx); } }; parseTreeVisitor.visit(enumerator.getRuleContext()); return symbols; }
/** * {@inheritDoc} * * <p>The default implementation initializes the aggregate result to * {@link #defaultResult defaultResult()}. Before visiting each child, it * calls {@link #shouldVisitNextChild shouldVisitNextChild}; if the result * is {@code false} no more children are visited and the current aggregate * result is returned. After visiting a child, the aggregate result is * updated by calling {@link #aggregateResult aggregateResult} with the * previous aggregate result and the result of visiting the child.</p> * * <p>The default implementation is not safe for use in visitors that modify * the tree structure. Visitors that modify the tree should override this * method to behave properly in respect to the specific algorithm in use.</p> */ @Override public T visitChildren(RuleNode node) { T result = defaultResult(); int n = node.getChildCount(); for (int i=0; i<n; i++) { if (!shouldVisitNextChild(node, result)) { break; } ParseTree c = node.getChild(i); T childResult = c.accept(this); result = aggregateResult(result, childResult); } return result; }
/** * {@inheritDoc} * * <p>The default implementation returns the result of * {@link #defaultResult defaultResult}.</p> */ @Override public T visitTerminal(TerminalNode node) { return defaultResult(); }
@Override public ArrayList<Symbol> parseEnumerator(EnumeratorImpl enumerator) { ArrayList<Symbol> symbols = new ArrayList<>(); AbstractParseTreeVisitor parseTreeVisitor = new ObjectiveCParserBaseVisitor() { @Override public Object visitEnumerator(ObjectiveCParser.EnumeratorContext ctx) { String itemName = ctx.enumeratorIdentifier().getText(); VariableImpl variable = new VariableImpl(itemName, enumerator); enumerator.getValues().add(variable); return super.visitEnumerator(ctx); } }; parseTreeVisitor.visit(enumerator.getRuleContext()); return symbols; }
/** * {@inheritDoc} * * <p>The default implementation initializes the aggregate result to * {@link #defaultResult defaultResult()}. Before visiting each child, it * calls {@link #shouldVisitNextChild shouldVisitNextChild}; if the result * is {@code false} no more children are visited and the current aggregate * result is returned. After visiting a child, the aggregate result is * updated by calling {@link #aggregateResult aggregateResult} with the * previous aggregate result and the result of visiting the child.</p> * * <p>The default implementation is not safe for use in visitors that modify * the tree structure. Visitors that modify the tree should override this * method to behave properly in respect to the specific algorithm in use.</p> */ @Override public T visitChildren(RuleNode node) { T result = defaultResult(); int n = node.getChildCount(); for (int i=0; i<n; i++) { if (!shouldVisitNextChild(node, result)) { break; } ParseTree c = node.getChild(i); T childResult = c.accept(this); result = aggregateResult(result, childResult); } return result; }
/** * {@inheritDoc} * * <p>The default implementation returns the result of * {@link #defaultResult defaultResult}.</p> */ @Override public T visitTerminal(TerminalNode node) { return defaultResult(); }
public ArrayList<Symbol> parseInterface(InterfaceImpl anInterface) { ArrayList<Symbol> symbols = new ArrayList<>(); AbstractParseTreeVisitor parseTreeVisitor = new ObjectiveCParserBaseVisitor() { /** * super class */ @Override public Object visitProtocolName(ObjectiveCParser.ProtocolNameContext ctx) { String protocol = ctx.getText(); InterfaceImpl i = new InterfaceImpl(protocol, anInterface); anInterface.getExtendInterfaces().add(i); return super.visitProtocolName(ctx); } /** * methods */ @Override public Object visitMethodDeclaration(ObjectiveCParser.MethodDeclarationContext ctx) { String methodName = ctx.methodSelector().getText(); FunctionImpl f = new FunctionImpl(methodName, anInterface); anInterface.getiFunctions().add(f); return super.visitMethodDeclaration(ctx); } }; parseTreeVisitor.visit(anInterface.getRuleContext()); return symbols; }
/** * {@inheritDoc} * * <p>The default implementation initializes the aggregate result to * {@link #defaultResult defaultResult()}. Before visiting each child, it * calls {@link #shouldVisitNextChild shouldVisitNextChild}; if the result * is {@code false} no more children are visited and the current aggregate * result is returned. After visiting a child, the aggregate result is * updated by calling {@link #aggregateResult aggregateResult} with the * previous aggregate result and the result of visiting the child.</p> * * <p>The default implementation is not safe for use in visitors that modify * the tree structure. Visitors that modify the tree should override this * method to behave properly in respect to the specific algorithm in use.</p> */ @Override public Result visitChildren(@NotNull RuleNode node) { Result result = defaultResult(); int n = node.getChildCount(); for (int i=0; i<n; i++) { if (!shouldVisitNextChild(node, result)) { break; } ParseTree c = node.getChild(i); Result childResult = c.accept(this); result = aggregateResult(result, childResult); } return result; }
/** * {@inheritDoc} * * <p>The default implementation returns the result of * {@link #defaultResult defaultResult}.</p> */ @Override public T visitTerminal(TerminalNode node) { return defaultResult(); }
parseTreeVisitor.visit(anInterface.getRuleContext());
/** * {@inheritDoc} * * <p>The default implementation returns the result of * {@link #defaultResult defaultResult}.</p> */ @Override public T visitErrorNode(ErrorNode node) { return defaultResult(); }
parseTreeVisitor.visit(clazz.getRuleContext()); symbols.addAll(functions); symbols.addAll(variables);
/** * {@inheritDoc} * * <p>The default implementation returns the result of * {@link #defaultResult defaultResult}.</p> */ @Override public T visitErrorNode(ErrorNode node) { return defaultResult(); }