Package xtc.tree

Examples of xtc.tree.Node


   *
   * @return The node of the class body
   */
  private Node makeClassBody() {
    // Make the constructor
    Node constructor;
    if ("Typical".equals(output)) {
      constructor = factory.makeConstructor(output + "Analyzer");
      Node fieldDecl = factory.nodeTypeDecl();
      // return the class body node
      return GNode.create("ClassBody", fieldDecl, constructor);
    } else {
      constructor = factory.makeConstructor2(output + "Analyzer");
      // return the class body node
View Full Code Here


   * Create the typechecker skeleton.
   *
   * @return The root of the type checker ast.
   */
  private Node makeSkeleton() {   
    Node classDec = GNode.create("ClassDeclaration",
      toModifiers("public"),
      output + "Analyzer",
      null,
      GNode.create("Extension", GNode.create("Type",
        GNode.create("QualifiedIdentifier", "Analyzer"),null)),null,
      cbody);

    Node compUnit = GNode.create("CompilationUnit", 8);
    compUnit.add(packageNode);
    addImports(compUnit, cbody, "Analyzer");     
    compUnit.add(comment(classDec,
                         "Type checker for " + output + "."));
    return compUnit;
 
View Full Code Here

   * Create the skeleton for the xxxTypes.java file.
   *
   * @return The root of the XXXTypes.java ast.
   */
  private Node makeTypesSkeleton() {
    Node compUnit = GNode.create("CompilationUnit", 8);
    compUnit.add(packageNode);
    addImports(compUnit, tbody, "Types");
  
    Node classDecl = factory.classDecl2(output + "Types");
    classDecl.set(5, tbody);

    compUnit.add(comment(classDecl,
                         "Types for " + output + "."));
    return compUnit;   
  }
View Full Code Here

   * Create the skeleton for the xxxSupport.java file.
   *
   * @return The root of the XXXSupport.java ast.
   */
  private Node makeSupportSkeleton() {
    Node compUnit = GNode.create("CompilationUnit", 8);
    compUnit.add(packageNode);
    addImports(compUnit, sbody, "Support");
   
    Node classDecl = factory.classDecl2(output + "Support");
    classDecl.set(5, sbody);

    compUnit.add(comment(classDecl,
                         "Helper functionality for " + output + "."));
    return compUnit;   
  }
View Full Code Here

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

    // Alternative 1.

    yyResult = pAccessModifier$$Choice1(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      String v$g$1 = yyResult.semanticValue();

      yyOption1  = yyResult.index;
      yyOpValue1 = null;

      yyResult = pAccessQualifier(yyOption1);
      yyError  = yyResult.select(yyError, yyOption1);
      if (yyResult.hasValue()) {
        Node v$el$3 = yyResult.semanticValue();

        yyOption1  = yyResult.index;
        yyOpValue1 = v$el$3;
      }
      { // Start scope for v$g$2.
        Node v$g$2 = yyOpValue1;

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

        return new SemanticValue(yyValue, yyOption1, yyError);
View Full Code Here

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

    // Alternative 1.

    yyResult = psep(yyStart);
    if (yyResult.hasValue("{")) {

      final int yyChoice1 = yyResult.index;

      // Nested alternative 1.

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

        yyBase   = yyResult.index;
        yyResult = psep(yyBase);
        if (yyResult.hasValue("}")) {

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

          return yyResult.createValue(yyValue, yyError);
        } else {
          yyError = yyError.select("'}' expected", yyBase);
        }
      }

      // Nested alternative 2.

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

        yyBase   = yyResult.index;
        yyResult = psep(yyBase);
        if (yyResult.hasValue("}")) {

View Full Code Here

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

    // Alternative 1.

    yyResult = pENTER_NL_ENABLE(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {

      yyResult = pBlock$$Star1(yyResult.index);
      yyError  = yyResult.select(yyError);
      if (yyResult.hasValue()) {
        Pair<Node> v$g$1 = yyResult.semanticValue();

        yyOption1  = yyResult.index;
        yyOpValue1 = null;

        yyResult = pResultExpr(yyOption1);
        yyError  = yyResult.select(yyError, yyOption1);
        if (yyResult.hasValue()) {
          Node v$el$3 = yyResult.semanticValue();

          yyOption1  = yyResult.index;
          yyOpValue1 = v$el$3;
        }
        { // Start scope for v$g$2.
          Node v$g$2 = yyOpValue1;

          yyResult = pEXIT_NL_ENABLE(yyOption1);
          yyError  = yyResult.select(yyError);
          if (yyResult.hasValue()) {

View Full Code Here

   */
  private Node checkToLet(Node n, Object retType) {
    List<LetBinding> bl = getBindings(n);
    if (null == bl || bl.isEmpty()) return n;

    Node block = null;
    if ("Block".equals(n.getName())) {
      block = GNode.create("Block", n);
    } else {
      // fix cast here
      if (mapper.hasTypeVariables(retType)) {
        block = GNode.create("Block", factory.ret(n));
      } else {
        block = GNode.create("Block", factory.ret(factory.cast(n)));
      }
    }
    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),
      "apply", GNode.create("FormalParameters"), null, null, block));
   
    Node let = factory.letExpression(mapper.toTypeNode(retType, false));
    let.getGeneric(0).set(4, letclass);
    return let;   
  }
View Full Code Here

    // Alternative 1.

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

      yyResult = pSEMI(yyResult.index);
      yyError  = yyResult.select(yyError);
      if (yyResult.hasValue()) {
View Full Code Here

    Result       yyResult;
    Result       yyPredResult;
    boolean      yyPredMatched;
    int          yyRepetition1;
    Pair<Object> yyRepValue1;
    Node         yyValue;
    ParseError   yyError = ParseError.DUMMY;

    // Alternative 1.

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

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

      return yyResult.createValue(yyValue, yyError);
    }

    // Alternative 2.

    yyRepetition1 = yyStart;
    yyRepValue1   = Pair.empty();
    while (true) {

      yyResult = pBlockStat$$Choice1(yyRepetition1);
      yyError  = yyResult.select(yyError, yyRepetition1);
      if (yyResult.hasValue()) {
        String v$el$1 = yyResult.semanticValue();

        yyRepetition1 = yyResult.index;
        yyRepValue1   = new Pair<Object>(v$el$1, yyRepValue1);
        continue;
      }
      break;
    }
    { // Start scope for v$g$2.
      Pair<String> v$g$2 = cast(yyRepValue1.reverse());

      yyResult = pDef(yyRepetition1);
      yyError  = yyResult.select(yyError);
      if (yyResult.hasValue()) {
        Node v$g$3 = yyResult.semanticValue();

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

        return yyResult.createValue(yyValue, yyError);
      }
    } // End scope for v$g$2.

    // Alternative 3.

    yyRepetition1 = yyStart;
    yyRepValue1   = Pair.empty();
    while (true) {

      yyResult = pLocalModifier(yyRepetition1);
      yyError  = yyResult.select(yyError, yyRepetition1);
      if (yyResult.hasValue()) {
        Node v$el$4 = yyResult.semanticValue();

        yyRepetition1 = yyResult.index;
        yyRepValue1   = new Pair<Object>(v$el$4, yyRepValue1);
        continue;
      }
      break;
    }
    { // Start scope for v$g$4.
      Pair<Node> v$g$4 = cast(yyRepValue1.reverse());

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

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

        return yyResult.createValue(yyValue, yyError);
      }
    } // End scope for v$g$4.

    // Alternative 4.

    yyPredMatched = false;

    yyPredResult = pResultFunExpr(yyStart);
    if (yyPredResult.hasValue()) {

      yyPredMatched = true;
    }

    if (! yyPredMatched) {

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

        yyValue = GNode.create("BlockStat", v$g$6);
        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.