Examples of GNode


Examples of org.antlr.works.visualization.graphics.shape.GNode

        getPathGroup().addPath(path);
    }

    public GNode findNodeForStateNumber(int stateNumber) {
        for (GGraph graph : getGraphs()) {
            GNode node = graph.findNodeForStateNumber(stateNumber);
            if (node != null) {
                return node;
            }
        }
        return null;
View Full Code Here

Examples of xtc.tree.GNode

    if(runtime.test("printAST")){
      runtime.console().pln().format(ast).pln().flush();
    }
   
    //It's a compilation run
    GNode result_ast  = null;
    GNode types_ast   = null;
    GNode support_ast = null;

    String output = (String)runtime.getValue("optionOutput");  
    if (null == output) {
      output = typicalName.substring(0, typicalName.length()- 5);
    }
View Full Code Here

Examples of xtc.tree.GNode

   *
   * @param n The typical tuple node.
   * @return The java representation.
   */
  private Node makeTuple(GNode n) {   
    GNode args = GNode.create("Arguments");
    List<String> upVars = getUpVariables(n);
    List<LetBinding> bl = null;
    for (int i = 0; i < n.size(); i++) {
      Node no = n.getGeneric(i);
      if (n.hasProperty(INANALYZE)) {
        no.setProperty(INANALYZE, Boolean.TRUE);
      }
      if (null != upVars) no.setProperty(UPVARS,upVars);
      Node expr = (Node)dispatch(no);
      args.add(expr);
      List<LetBinding> l = getBindings(expr);
      List<String> vars = extractVariables(l);
      upVars = groupList(upVars, vars);
      bl = groupList(bl,l);     
   
View Full Code Here

Examples of xtc.tree.GNode

        }
      }
      Node letclass = GNode.create("ClassBody");
      letclass = GNode.ensureVariable((GNode)letclass);
      GNode letbody = GNode.create("Block");
   
      for (int i = 0; i < size; i++) {
        Node binding = bindings.getGeneric(i);
        Node left = binding.getGeneric(0);
        Node right = binding.getGeneric(1);

        if (n.hasProperty(INANALYZE)) right.setProperty(INANALYZE, Boolean.TRUE);
    
        String bname;
        Object btype;
 
        right = (Node)dispatch(right);
 
        if (left.hasName("Variable")) {
          bname = left.getString(0);
          btype = left.getProperty(TYPE);
          letclass.add(makeVarDec2(bname, mapper.toTypeNode(btype, false) , null));
          // fix cast here
          if (mapper.hasTypeVariables(btype)) {
            letbody.add(factory.assign(toIdentifier(bname), right));
          } else {
            letbody.add(factory.assign(toIdentifier(bname), factory.cast(right)));
          }
       
        } else if ("TypedPattern".equals(left.getName()) &&
                   "Variable".equals(left.getGeneric(0).getName())) {
          bname = left.getGeneric(0).getString(0);       
          btype = left.getProperty(TYPE);
          letclass.add(makeVarDec2(bname, mapper.toTypeNode(btype, false), null));
          // fix cast here
          if (mapper.hasTypeVariables(btype)) {
            letbody.add(factory.assign(toIdentifier(bname),right));
          } else {
            letbody.add(factory.assign(toIdentifier(bname),factory.cast(right)));
          }
       
        } else {
          if (right.hasName("ConditionalExpression")) {
            letbody.add(factory.discard(right));
          } else {
            letbody.add(factory.expressionStmnt(right));
          }
        }
      }      

      if (letbody.size() > 0) {
        letclass.add(letbody);
      }
   
      letclass.add(GNode.create("MethodDeclaration",
        toModifiers("public"),null, mapper.toTypeNode(resultType, false),
View Full Code Here

Examples of xtc.tree.GNode

      }
    }
    Node letclass = GNode.create("ClassBody");
    letclass = GNode.ensureVariable((GNode)letclass);
    GNode letbody = GNode.create("Block");

    for (LetBinding bind : bl) {
      if (!bind.name.equals(spareVar)) {
        letclass.add(makeVarDec2(bind.name, bind.type , null));
      }
      if (mapper.hasTypeVariables(bind.typeObject)) {
        letbody.add(factory.assign(toIdentifier(bind.name), bind.value));
      } else {
        letbody.add(factory.assign(toIdentifier(bind.name),
                                   factory.cast(bind.value)));
      }
    }

    if (letbody.size() > 0) {
      letclass.add(letbody);
    }
   
    letclass.add(GNode.create("MethodDeclaration",
      toModifiers("public"),null, mapper.toTypeNode(retType, false),
View Full Code Here

Examples of xtc.tree.GNode

      }
    }
    Node letclass = GNode.create("ClassBody");
    letclass = GNode.ensureVariable((GNode)letclass);
    GNode letbody = GNode.create("Block");

    for (LetBinding bind : bl) {
      if (!bind.name.equals(spareVar)) {
        letclass.add(makeVarDec2(bind.name, bind.type , null));
      }
      if (mapper.hasTypeVariables(bind.typeObject)) {
        letbody.add(factory.assign(toIdentifier(bind.name), bind.value));
      } else {
        letbody.add(factory.assign(toIdentifier(bind.name),
                                   factory.cast(bind.value)));
      }
    }

    if (letbody.size() > 0) {
      letclass.add(letbody);
    }
   
    letclass.add(GNode.create("MethodDeclaration",
      toModifiers("public"),null, mapper.toTypeNode(retType, false),
View Full Code Here

Examples of xtc.tree.GNode

   * @param bn The node to get bindings from (if exists).
   * @return The augmented IfStatement.
   */
  public Node augmentIfStatement(Node n, String matchArg, GNode no, Node bn) {
    Node block = n.getGeneric(1);
    GNode pattern = no.getGeneric(0).getGeneric(0);
    List<Integer> indexList = getIndexList(pattern);

    int size = block.size();
    // Get the last return statement of the block
    Node retNode = block.getGeneric(size - 1);
View Full Code Here

Examples of xtc.tree.GNode

   * @return The corresponding package name.
   */
  protected String getPackage(GNode n) {
    assert n.hasName("ImportDeclaration");

    GNode qid  = n.getGeneric(1);
    int   size = qid.size();
    if (null == n.get(2)) size--;

    return 0 >= size ? "" : fold(qid, size);
  }
View Full Code Here

Examples of xtc.tree.GNode

    isOpenLine     = false;
    isNested       = false;
    isIfElse       = false;
    isDeclaration  = false;
    isStatement    = false;
    GNode previous = null;

    for (Object o : n) {
      final Node  node    = (Node)o;
      if (null == node) continue;
      final GNode current = GNode.cast(node);

      // If there was a previous node and the previous node was a
      // block or long declaration, the current node is a block or
      // long declaration, or the previous node was a statement and
      // the current node is a declaration, then print an extra
      // newline.
      if ((null != previous) &&
          (previous.hasName("Block") ||
           (isLongDeclaration(previous) &&
            current.getName().endsWith("Declaration")) ||
           current.hasName("Block") ||
           isLongDeclaration(current) ||
           (! previous.getName().endsWith("Declaration") &&
            current.getName().endsWith("Declaration")))) {
        printer.pln();
      }

      printer.p(node);
View Full Code Here

Examples of xtc.tree.GNode

    printDeclsAndStmts(n);
  }
   
  /** Visit the specified package declaration. */
  public void visitPackageDeclaration(GNode n) { 
    GNode qid   = n.getGeneric(1);
    packageName = fold(qid, qid.size());

    printer.indent().p(n.getNode(0)).p("package ").p(n.getNode(1)).pln(';');
    isOpenLine  = false;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.