Package sizzle.types

Examples of sizzle.types.SizzleTable


    final SymbolTable st = new SymbolTable();

    SizzleParser.ReInit(new StringReader(source));
    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


    if (n.f2.present())
      if (annotation.formalParameters().length == 0)
        throw new TypeException("no arguments for table " + n.f1.f0.tokenImage);

    return new SizzleTable(type, indexTypes, tweight);
  }
View Full Code Here

  /** {@inheritDoc} */
  @Override
  public SizzleType visit(final EmitStatement n, final SymbolTable argu) {
    final String id = n.f1.f0.tokenImage;

    final SizzleTable t = (SizzleTable) argu.get(id);

    if (t == null)
      throw new TypeException("emitting to undeclared table " + id);

    if (n.f2.present()) {
      final List<SizzleType> indices = new ArrayList<SizzleType>();
      for (final Node node : n.f2.nodes)
        indices.add(((NodeSequence) node).nodes.get(1).accept(this, argu));

      if (indices.size() != t.countIndices())
        throw new TypeException("incorrect number of indices for " + id);

      for (int i = 0; i < t.countIndices(); i++)
        if (!t.getIndex(i).assigns(indices.get(i)))
          throw new TypeException("incorrect type " + indices.get(i) + " for index " + i);
    } else if (t.countIndices() > 0)
      throw new TypeException("indices missing from emit");

    final SizzleType expression = n.f4.accept(this, argu);
    if (!t.accepts(expression))
      throw new TypeException("incorrect type " + expression + " for " + id + ":" + t);

    if (n.f5.present()) {
      if (t.getWeightType() == null)
        throw new TypeException("unexpected weight specified by emit");

      final SizzleType wtype = ((NodeSequence) n.f5.node).nodes.get(1).accept(this, argu);

      if (!t.acceptsWeight(wtype))
        throw new TypeException("incorrect type " + wtype + " for weight of " + id + ":" + t.getWeightType());
    } else if (t.getWeightType() != null)
      throw new TypeException("no weight specified by emit");

    return null;
  }
View Full Code Here

  public String visit(final OutputType n, final SymbolTable argu) {
    final String id = argu.getId();

    final String aggregator = n.f1.f0.tokenImage;

    final SizzleTable t = (SizzleTable) argu.get(id);

    if (n.f2.present()) {
      final String parameter = ((NodeSequence) n.f2.node).nodes.get(1).accept(this, argu);
      this.tables.put(id, new TableDescription(aggregator, t.getType(), Arrays.asList(parameter)));
    } else {
      this.tables.put(id, new TableDescription(aggregator, t.getType()));
    }

    return null;
  }
View Full Code Here

TOP

Related Classes of sizzle.types.SizzleTable

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.