Package sizzle.types

Examples of sizzle.types.SizzleMap


    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() },
        "sizzle.functions.SizzleSpecialIntrinsics.regex(\"${0}\", ${1})"));
    this.setFunction("regex", new SizzleFunction(new SizzleString(), new SizzleType[] { new SizzleName(new SizzleScalar()) },
View Full Code Here


    TestTypeCheckingVisitor.typeChecker.visit(SizzleParser.Start(), st);

    Assert.assertEquals("xlated is not an unindexed, unweighted table of string", new SizzleTable(new SizzleString(), null), st.get("xlated"));

    Assert.assertEquals("abbr is not a string", new SizzleString(), st.get("abbr"));
    Assert.assertEquals("CJK is not a mapping from string to string", new SizzleMap(new SizzleString(), new SizzleString()), st.get("CJK"));
  }
View Full Code Here

    Assert.assertEquals("my_bool is not an alias for bool", new SizzleName(new SizzleBool()), st.getType("my_bool"));
    final ArrayList<SizzleType> members = new ArrayList<SizzleType>(Arrays.asList(new SizzleFloat(), new SizzleFloat()));
    Assert.assertEquals("Coordinates is not is not an alias for a tuple of x: float, y: float", new SizzleName(new SizzleTuple(members)),
        st.getType("Coordinates"));
    Assert.assertEquals("CityMap is not an alias for a mapping from string to tuple of x: float, y: float", new SizzleName(new SizzleMap(
        new SizzleString(), new SizzleName(new SizzleTuple(members)))), st.getType("CityMap"));

  }
View Full Code Here

  }

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

      switch (nodeChoice.which) {
      case 0: // pair list
      case 1: // expression list
        return nodeChoice.choice.accept(this, argu);
      case 2: // empty map
        return new SizzleMap();
      default:
        throw new RuntimeException("unexpected choice " + nodeChoice.which + " is " + nodeChoice.choice.getClass());
      }
    }
View Full Code Here

  }

  /** {@inheritDoc} */
  @Override
  public SizzleType visit(final PairList n, final SymbolTable argu) {
    final SizzleMap sizzleMap = (SizzleMap) n.f0.accept(this, argu);

    if (n.f1.present())
      for (final Node node : n.f1.nodes)
        if (!sizzleMap.assigns(((NodeSequence) node).elementAt(1).accept(this, argu)))
          throw new TypeException("incorrect type " + node + " for " + sizzleMap);

    return sizzleMap;
  }
View Full Code Here

  }

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

TOP

Related Classes of sizzle.types.SizzleMap

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.