Package xtc.tree

Examples of xtc.tree.Node


   * @throws IOException Signals an I/O error.
   */
  private Result pAtPattern(final int yyStart) throws IOException {
    Result     yyResult;
    int        yyBase;
    Node       yyValue;
    ParseError yyError = ParseError.DUMMY;

    // Alternative 1.

    yyResult = pVarId(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      Node v$g$1 = yyResult.semanticValue();

      yyBase   = yyResult.index;
      yyResult = pkey(yyBase);
      if (yyResult.hasValue("@")) {

        yyResult = pPattern3(yyResult.index);
        yyError  = yyResult.select(yyError);
        if (yyResult.hasValue()) {
          Node v$g$2 = yyResult.semanticValue();

          yyValue = GNode.create("AtPattern", v$g$1, v$g$2);
          yyValue.setLocation(location(yyStart));

          return yyResult.createValue(yyValue, yyError);
View Full Code Here


   *
   * @param n The name space definition node.
   */ 
  public void visitNameSpaceDefinition(GNode n) {  
    seenNameSpace = true;      
    Node pat = GNode.create("PatternMatching");
    pat.setProperty(TYPE, n.getProperty(TYPE));
    pat.setProperty(MATCHARG, "n");

    // Create the pattern matching node
    for(int i = 0; i < n.size(); i++) {
      Node child = n.getGeneric(i);
    
      for(int j = 0; j < child.getGeneric(2).size(); j++) {       
        Node grand = child.getGeneric(2).getGeneric(j);
        Node pattern = GNode.create("PatternMatch");
       
        pattern.add(grand.getGeneric(0));
        // Create Typical tuple
        Node tup = GNode.create("TupleLiteral", grand.getGeneric(1),
          GNode.create("StringLiteral", "\"" + child.getString(0) + "\""),
          GNode.create("StringLiteral", "\"" + child.getString(1) + "\""));
        tup.setProperty(TYPE, TypeMapper.nameTupleT);
        pattern.add(tup);
     
        pattern.setProperty("enterScope",grand.getProperty("enterScope"));
       
        Node thepatterns = pattern.getGeneric(0);
       
        for (int k = 0; k < thepatterns.size(); k++) {
        thepatterns.getGeneric(k).setProperty("enterScope",
          pattern.getProperty("enterScope"));
        }
        pat.add(pattern);
      }     
    }

    pat.setProperty(MATCHARG, "n");
    Node match =
      GNode.create("MatchExpression", GNode.create("LowerID","n"),pat);
   
    // create the value definition node
    Node top = GNode.create("ValueDefinition",
      "getNameSpace", GNode.create("Parameters", GNode.create("Parameter", "n",
       GNode.create("UserDefinedType", "node"))), match);
    top.setProperty("__isfunction", null);
    match.setProperty("__arg_type", table.current().lookup("type(node)"));
    match.setProperty(TYPE, TypeMapper.nameTupleT);
    top.setProperty("__arg_type", n.getProperty("__arg_type"));
  
    top.setProperty(TYPE, table.current().lookup("value(getNameSpace)"));
    functionDefinitions.add((Node)dispatch(top));
  }
View Full Code Here

  }

  /** Actually parse org.netbeans.modules.scala.core.rats.ParserScala.Pattern3. */
  private Result pPattern3$1(final int yyStart) throws IOException {
    Result     yyResult;
    Node       yyValue;
    ParseError yyError = ParseError.DUMMY;

    // Alternative 1.

    yyResult = pSimplePattern(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      Node v$g$1 = yyResult.semanticValue();

      final int yyChoice1 = yyResult.index;

      // Nested alternative 1.

      yyResult = pInfixPatternTail(yyChoice1);
      yyError  = yyResult.select(yyError);
      if (yyResult.hasValue()) {
        Node v$g$2 = yyResult.semanticValue();

        yyResult = pPattern3$$Star1(yyResult.index);
        yyError  = yyResult.select(yyError);
        if (yyResult.hasValue()) {
          Pair<Node> v$g$3 = yyResult.semanticValue();
View Full Code Here

    // Alternative 1.

    yyResult = pInfixPatternTail(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      Node v$el$1 = yyResult.semanticValue();

      yyResult = pPattern3$$Star1(yyResult.index);
      yyError  = yyResult.select(yyError);
      if (yyResult.hasValue()) {
        Pair<Node> v$2 = yyResult.semanticValue();
View Full Code Here

   * @param tag The message class.
   * @param msg The message.
   * @param o The node generating the message.
   */
  protected void showMessage(String tag, String msg, Object o){
    Node n = (Node)o;
    if (null == n) {
      if ("error".equals(tag)) {
        if (matching_nodes.size() - 1 < 0) {
          runtime.error(msg);         
        } else {
          Node nod = matching_nodes.get(matching_nodes.size() - 1);
          runtime.error(msg,nod);         
        }       
      } else {
        if (matching_nodes.size() -1 < 0) {
          runtime.warning(msg);         
        } else {
          Node nod = matching_nodes.get(matching_nodes.size() - 1);
          runtime.warning(msg,nod);         
        }
      }
    } else {
      if ("error".equals(tag)) {
View Full Code Here

    ArrayList<Node> nodeList = (ArrayList<Node>)nodes.list();
    int index;
    int prob = -1;
    // check and remove set scope property in those nodes
    for (index = 0; index < nodeList.size(); index++) {
      Node node = nodeList.get(index);
      if ( node == null) {
        continue;
      }
      if (!node.hasProperty(ENTERSCOPE)) {
        node.setProperty(ENTERSCOPE,str);
        node.setProperty(EXITSCOPE,true);
        prob = index;
      }
    }
    if ((prob!=-1) && (scopename.isTemporary())) {
      Node node = nodeList.get(prob);
      node.setProperty("deleteScope",str);
    }
  }
View Full Code Here

        // Work around
        Object ob = rt;
        @SuppressWarnings("unchecked")
        TypicalTypes.ConstructedT ct = (TypicalTypes.ConstructedT)ob;
        String str = (String)ct.getTuple().get2();
        Node baseNode = toTypeNode(getBase(rt), objectToWild);
        if ("list".equals(str)) {
          return GNode.create("Type",
                   GNode.create("InstantiatedType",
                     GNode.create("TypeInstantiation",
                       "Pair",
                       GNode.create("TypeArguments", baseNode))),
                   null);
        } else if ("var".equals(str)) {
          return baseNode;
        } else {
          return makeTypeNode(str, objectToWild);
        }
      }

      // Type name
      if (rt.isTypeName()) {
        return makeTypeNode((String)rt.getTuple().get1(), objectToWild);
      }

      // Record type
      if (rt.isRecordT()) {
        Pair<Object> p = rt.getTuple().get1();
        Object head = p.head();
        @SuppressWarnings("unchecked")
        TypicalTypes.raw_type field = unwrapRawType(head);
        if(field.isFieldT()){ 
          final String recName = (String)field.getTuple().get1();
          return makeTypeNode(recName, objectToWild);
        } else {
          return toTypeNode(field, objectToWild);
        }
      }

      // Tuple type
      if (rt.isTupleT()) {
      
        //Workaround to fix incompatible type bug on Mac OS
        Object o1 = rt;
        @SuppressWarnings("unchecked")
        TypicalTypes.TupleT tt = (TypicalTypes.TupleT)o1;
        //End workaround

        List<Object> members = new ArrayList<Object>();
        @SuppressWarnings("unchecked")
        Pair<?> tl  = tt.getTuple().get1();
        for (Iterator<?> iter = tl.iterator(); iter.hasNext(); ) {
          members.add(iter.next());
        }
        // Make type arguments       
        Node typeArgs = GNode.create("TypeArguments");               

        for (Object ob : members) typeArgs.add(toTypeNode(ob, objectToWild));
       
        // Return the tuple type
        return GNode.create("Type",
                 GNode.create("InstantiatedType",
                   GNode.create("TypeInstantiation", "Tuple", null),
                   GNode.create("TypeInstantiation", "T" + members.size(),
                                typeArgs)),
                 null);
      }

      if (rt.isPairOfType()) {
        return toTypeNode(rt.getTuple().get1(), objectToWild);
      }

      // Function type
      if (rt.isFunctionT()) {
        inFunctionType = true;
        List<Object> paramTypes = new ArrayList<Object>();

        Pair<?> params = cast(rt.getTuple().get1());
        for (Iterator<?> iter = params.iterator(); iter.hasNext();) {
          paramTypes.add(iter.next());
        }

        Node retTypeNode;
        Object retType = rt.getTuple().get2();
        if (retType instanceof TypicalTypes.type) {
          TypicalTypes.type retT = (TypicalTypes.type)retType;
          if (null == retT.type) {
            retTypeNode = makeTypeNode("Void", false) ;
          } else {
            retTypeNode = toTypeNode(retT, objectToWild);
          }
        } else {
          if (null == retType) {
            retTypeNode = makeTypeNode("Void", false) ;
          } else {
            retTypeNode = toTypeNode(retType, objectToWild);
          }
        }
       
        // Make type arguments
        Node typeArgs = GNode.create("TypeArguments");
        typeArgs.add(retTypeNode);
                
        for (Object ob : paramTypes) typeArgs.add(toTypeNode(ob, objectToWild));
        inFunctionType = false;
        // Return the function type
        return GNode.create("Type",
                 GNode.create("InstantiatedType",
                   GNode.create("TypeInstantiation", "Function", null),
View Full Code Here

      Object ob = rt.getTuple().get2();
      if (null == ob) return makeTypeNode("Void", false);

      TypicalTypes.raw_type<?> retType = unwrapRawType(ob);
      if (null == retType) return makeTypeNode("Void", false);
      Node res = toTypeNode(retType, false);
      inFunctionType = false;
      return res;
    } else {
      return toTypeNode(rt, false);
    }      
View Full Code Here

    if (null == o) throw new AssertionError("Null type");
   
    List<Node> members = new ArrayList<Node>();

    if (o instanceof Node) {
      Node n = (Node)o;
      Node no = n.getGeneric(0).getGeneric(1).getGeneric(1);
      for (int i = 0; i < no.size(); i++) {
        members.add(no.getGeneric(i));
      }
      return members;
    }

    if (!isTGType(o)) throw new AssertionError("Not a type " + o);
View Full Code Here

   * @return The result.
   * @throws IOException Signals an I/O error.
   */
  private Result pXmlContentP(final int yyStart) throws IOException {
    Result     yyResult;
    Node       yyValue;
    ParseError yyError = ParseError.DUMMY;

    // Alternative <ScalaPatterns>.

    yyResult = pScalaPatterns(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      Node v$g$1 = yyResult.semanticValue();

      yyValue = GNode.create("XmlContentP", v$g$1);
      yyValue.setLocation(location(yyStart));

      return yyResult.createValue(yyValue, yyError);
    }

    // Alternative <XmlCDSect>.

    yyResult = pParserScala$XmlCDSect(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      Node v$g$2 = yyResult.semanticValue();

      yyValue = GNode.create("XmlContentP", v$g$2);
      yyValue.setLocation(location(yyStart));

      return yyResult.createValue(yyValue, yyError);
    }

    // Alternative <XmlPI>.

    yyResult = pParserScala$XmlPI(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      String v$g$3 = yyResult.semanticValue();

      yyValue = GNode.create("XmlContentP", v$g$3);
      yyValue.setLocation(location(yyStart));

      return yyResult.createValue(yyValue, yyError);
    }

    // Alternative <XmlCharData>.

    yyResult = pParserScala$XmlCharData(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      Node v$g$4 = yyResult.semanticValue();

      yyValue = GNode.create("XmlContentP", v$g$4);
      yyValue.setLocation(location(yyStart));

      return yyResult.createValue(yyValue, yyError);
    }

    // Alternative <XmlElement>.

    yyResult = pXmlElementP(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      Node v$g$5 = yyResult.semanticValue();

      yyValue = GNode.create("XmlContentP", v$g$5);
      yyValue.setLocation(location(yyStart));

      return yyResult.createValue(yyValue, yyError);
    }

    // Alternative <XmlReference>.

    yyResult = pParserScala$XmlReference(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      String v$g$6 = yyResult.semanticValue();

      yyValue = GNode.create("XmlContentP", v$g$6);
      yyValue.setLocation(location(yyStart));

      return yyResult.createValue(yyValue, yyError);
    }

    // Alternative <XmlComment>.

    yyResult = pParserScala$XmlComment(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      Node v$g$7 = yyResult.semanticValue();

      yyValue = GNode.create("XmlContentP", v$g$7);
      yyValue.setLocation(location(yyStart));

      return yyResult.createValue(yyValue, yyError);
View Full Code Here

TOP

Related Classes of xtc.tree.Node

Copyright © 2018 www.massapicom. 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.