Package sizzle.types

Examples of sizzle.types.SizzleArray


  }

  /** {@inheritDoc} */
  @Override
  public SizzleType visit(final ArrayType n, final SymbolTable argu) {
    return new SizzleArray(n.f2.accept(this, argu));
  }
View Full Code Here


    for (int i = 1; i < types.size(); i++)
      if (!t.assigns(types.get(i)))
        return new SizzleTuple(types);

    return new SizzleArray(t);
  }
View Full Code Here

  @Override
  public SizzleType visit(final Call n, final SymbolTable argu) {
    if (n.f1.present())
      return n.f1.node.accept(this, argu);

    return new SizzleArray();
  }
View Full Code Here

      default:
        throw new RuntimeException("unexpected choice " + nodeChoice.which + " is " + nodeChoice.choice.getClass());
      }
    }

    return new SizzleArray();
  }
View Full Code Here

    final SymbolTable st = new SymbolTable();

    // fake functions for this unit test
    st.setFunction("day_of_query", new SizzleFunction(new SizzleInt(), new SizzleType[] {}, "Nonexistant.day_of_query()"));
    st.setFunction("month_of_query", new SizzleFunction(new SizzleInt(), new SizzleType[] {}, "Nonexistant.month_of_query()"));
    st.setFunction("words_from_query", new SizzleFunction(new SizzleArray(new SizzleString()), new SizzleType[] {}, "Nonexistant.words_from_query()"));

    SizzleParser.ReInit(new StringReader(source));
    TestTypeCheckingVisitor.typeChecker.visit(SizzleParser.Start(), st);

    Assert.assertEquals("out is not an unweighted table of ints indexed by various",
        new SizzleTable(new SizzleInt(), Arrays.asList(new SizzleString(), new SizzleInt(), new SizzleInt()), null), st.get("out"));

    Assert.assertEquals("keywords is not an array of strings", new SizzleArray(new SizzleString()), st.get("keywords"));
    Assert.assertEquals("querywords is not an array of strings", new SizzleArray(new SizzleString()), st.get("querywords"));

    Assert.assertEquals("month is not an int", new SizzleInt(), st.get("month"));
    Assert.assertEquals("day is not an int", new SizzleInt(), st.get("day"));
  }
View Full Code Here

    final SymbolTable st = new SymbolTable();

    // fake functions for this unit test
    st.setFunction("day_of_query", new SizzleFunction(new SizzleInt(), new SizzleType[] {}, "Nonexistant.day_of_query()"));
    st.setFunction("month_of_query", new SizzleFunction(new SizzleInt(), new SizzleType[] {}, "Nonexistant.month_of_query()"));
    st.setFunction("words_from_query", new SizzleFunction(new SizzleArray(new SizzleString()), new SizzleType[] {}, "Nonexistant.words_from_query()"));

    SizzleParser.ReInit(new StringReader(source));
    TestTypeCheckingVisitor.typeChecker.visit(SizzleParser.Start(), st);
  }
View Full Code Here

    final List<SizzleType> members = new ArrayList<SizzleType>(Arrays.asList(new SizzleInt(), new SizzleFloat()));

    Assert.assertEquals("out is not a unindexed, unweighted table of tuple of int and float", new SizzleTable(new SizzleTuple(members)), st.get("out"));

    Assert.assertEquals("line is not a string", new SizzleString(), st.get("line"));
    Assert.assertEquals("tuple is not an array of strings", new SizzleArray(new SizzleString()), st.get("tuple"));
  }
View Full Code Here

    final List<SizzleType> members = new ArrayList<SizzleType>(Arrays.asList(new SizzleInt(), new SizzleFloat()));

    Assert.assertEquals("out is not an unindexed, unweighted table of int and float", new SizzleTable(new SizzleTuple(members)), st.get("out"));

    Assert.assertEquals("line is not a string", new SizzleString(), st.get("line"));
    Assert.assertEquals("tuple is not an array of strings", new SizzleArray(new SizzleString()), st.get("tuple"));
  }
View Full Code Here

    // these generic functions require more finagling than can currently be
    // (easily) done with a static method, so they are handled with macros

    this.setFunction("def", new SizzleFunction(new SizzleBool(), new SizzleType[] { new SizzleAny() }, "${0} != null"));
    this.setFunction("len", new SizzleFunction(new SizzleInt(), new SizzleType[] { new SizzleArray(new SizzleScalar()) }, "${0}.length"));
    this.setFunction("len", new SizzleFunction(new SizzleInt(), new SizzleType[] { new SizzleString() }, "${0}.length()"));
    this.setFunction("len", new SizzleFunction(new SizzleInt(), new SizzleType[] { new SizzleBytes() }, "${0}.length"));
    this.setFunction("len", new SizzleFunction(new SizzleInt(), new SizzleType[] { new SizzleMap(new SizzleScalar(), new SizzleScalar()) },
        "${0}.keySet().size()"));
    this.setFunction("haskey", new SizzleFunction(new SizzleBool(), new SizzleType[] { new SizzleMap(new SizzleScalar(), new SizzleScalar()),
        new SizzleScalar() }, "${0}.containsKey(${1})"));
    this.setFunction("keys", new SizzleFunction(new SizzleArray(new SizzleScalar()), new SizzleType[] { new SizzleMap(new SizzleScalar(),
        new SizzleScalar()) }, "${0}.keySet().toArray()"));
    this.setFunction("lookup", new SizzleFunction(new SizzleScalar(), new SizzleType[] { new SizzleMap(new SizzleScalar(), new SizzleScalar()),
        new SizzleScalar(), new SizzleScalar() }, "(${0}.containsKey(${1}) ? ${0}.get(${1}) : ${2})"));

    this.setFunction("regex", new SizzleFunction(new SizzleString(), new SizzleType[] { new SizzleName(new SizzleScalar()), new SizzleInt() },
View Full Code Here

  public SizzleType getType(final String id) {
    if (this.idmap.containsKey(id))
      return this.idmap.get(id);

    if (id.startsWith("array of "))
      return new SizzleArray(this.getType(id.substring("array of ".length())));

    throw new TypeException("no such type " + id);
  }
View Full Code Here

TOP

Related Classes of sizzle.types.SizzleArray

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.