Package xtc.tree

Examples of xtc.tree.Attribute


    String   stateName  = null;
    boolean  stateError = false;
    for (Module m2 : g.modules) {
      // Process stateful attribute.
      if (m2.hasAttribute(Constants.ATT_STATEFUL.getName())) {
        Attribute state =
          Attribute.get(Constants.ATT_STATEFUL.getName(), m2.attributes);
        Object    value = state.getValue();
        if ((null != value) &&
            (value instanceof String) &&
            (! ((String)value).startsWith("\""))) {
          if (null == stateName) {
            attributes.add(state);
            stateName = (String)state.getValue();
          }
          if (! stateName.equals(state.getValue())) {
            stateError = true;
          }
        }
      }
       
      // Process set and flag attributes.
      if (m2.hasAttribute(Constants.NAME_STRING_SET) ||
          m2.hasAttribute(Constants.NAME_FLAG)) {
        for (Attribute att : m2.attributes) {
          String name = att.getName();
          if ((Constants.NAME_STRING_SET.equals(name) ||
               Constants.NAME_FLAG.equals(name)) &&
              (! attributes.contains(att))) {
            attributes.add(att);
          }
        }
      }
    }
    
    // Now, do the actual well-formedness checking.
    Set<ModuleName> visited     = new HashSet<ModuleName>();
    boolean         hasTopLevel = false;
    for (Module m2 : g.modules) {
      analyzer.process(m2);
      hasState    = false;
      isMofunctor = (null != m2.modification);

      if (null != m2.attributes) {
        final int length = m2.attributes.size();
        for (int i=0; i<length; i++) {
          Attribute att   = m2.attributes.get(i);
          String    name  = att.getName();
          Object    value = att.getValue();

          if ((! Constants.ATT_WITH_LOCATION.equals(att)) &&
              (! Constants.ATT_CONSTANT.equals(att)) &&
              (! Constants.ATT_RAW_TYPES.equals(att)) &&
              (! Constants.ATT_VERBOSE.equals(att)) &&
              (! Constants.ATT_NO_WARNINGS.equals(att)) &&
              (! Constants.ATT_IGNORING_CASE.equals(att)) &&
              (! Constants.ATT_STATEFUL.getName().equals(name)) &&
              (! Constants.NAME_PARSER.equals(name)) &&
              (! Constants.NAME_MAIN.equals(name)) &&
              (! Constants.NAME_PRINTER.equals(name)) &&
              (! Constants.NAME_VISIBILITY.equals(name)) &&
              (! Constants.NAME_STRING_SET.equals(name)) &&
              (! Constants.NAME_FLAG.equals(name)) &&
              (! Constants.NAME_FACTORY.equals(name)) &&
              (! Constants.ATT_FLATTEN.equals(att)) &&
              (! Constants.ATT_GENERIC_AS_VOID.equals(att)) &&
              (! Constants.ATT_PARSE_TREE.equals(att)) &&
              (! Constants.ATT_PROFILE.equals(att)) &&
              (! Constants.ATT_DUMP.equals(att))) {
            runtime.error("unrecognized grammar-wide attribute '"+att+"'", att);
           
          } else {
            for (int j=0; j<i; j++) {
              Attribute att2 = m2.attributes.get(j);
              if (name.equals(Constants.NAME_STRING_SET) ||
                  name.equals(Constants.NAME_FLAG)) {
                if (att.equals(att2)) {
                  runtime.error("duplicate attribute '"+att+"'", att);
                  break;
                } else if ((null != value) && value.equals(att2.getValue())) {
                  runtime.error("duplicate field name '" + att + "'", att);
                }

              } else if (name.equals(att2.getName())) {
                runtime.error("duplicate attribute '" + name + "'", att);
                break;
              }
            }
          }
View Full Code Here


      }
     
      if (null != p.attributes) {
        final int length = p.attributes.size();
        for (int i=0; i<length; i++) {
          Attribute att = p.attributes.get(i);
         
          if ((! Constants.ATT_PUBLIC.equals(att)) &&
              (! Constants.ATT_PROTECTED.equals(att)) &&
              (! Constants.ATT_PRIVATE.equals(att)) &&
              (! Constants.ATT_TRANSIENT.equals(att)) &&
              (! Constants.ATT_INLINE.equals(att)) &&
              (! Constants.ATT_NO_INLINE.equals(att)) &&
              (! Constants.ATT_MEMOIZED.equals(att)) &&
              (! Constants.ATT_WITH_LOCATION.equals(att)) &&
              (! Constants.ATT_CONSTANT.equals(att)) &&
              (! Constants.ATT_VARIANT.equals(att)) &&
              (! Constants.ATT_EXPLICIT.equals(att)) &&
              (! Constants.ATT_VERBOSE.equals(att)) &&
              (! Constants.ATT_NO_WARNINGS.equals(att)) &&
              (! Constants.ATT_IGNORING_CASE.equals(att)) &&
              (! Constants.ATT_STATEFUL.equals(att)) &&
              (! Constants.ATT_RESETTING.equals(att))) {
            runtime.error("unrecognized per-production attribute '" + att +
                          "'", att);

          } else if ((! hasState) && Constants.ATT_STATEFUL.equals(att)) {
            runtime.error("stateful attribute without grammar-wide stateful " +
                          "attribute", att);
           
          } else if ((! hasState) && Constants.ATT_RESETTING.equals(att)) {
            runtime.error("resetting attribute without grammar-wide stateful " +
                          "attribute", att);
           
          } else {
            for (int j=0; j<i; j++) {
              if (att.equals(p.attributes.get(j))) {
                runtime.error("duplicate attribute '" + att.getName() + "'",
                              att);
                break;
              }
            }
          }
View Full Code Here

      printer.pln().indent().p("option ");

      boolean             isFirst = true;
      Iterator<Attribute> iter    = m.attributes.iterator();
      while (iter.hasNext()) {
        Attribute att       = iter.next();
        String    name      = att.getName();
        String    attText   = att.toString();
        boolean   highlight = (analyzer.isTopLevel(m) ||
                               Constants.ATT_STATEFUL.getName().equals(name) ||
                               Constants.NAME_STRING_SET.equals(name) ||
                               Constants.NAME_FLAG.equals(name));
View Full Code Here

    return (null != attributes) && attributes.contains(att) ? true :
      forward ? type.hasAttribute(att, true) : false;
  }

  public Attribute getAttribute(String name, boolean forward) {
    Attribute att = Attribute.get(name, attributes);
    return null != att ? att : forward ? type.getAttribute(name, true) : null;
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  public List<Attribute> getAttributeList(String name) {
    List<?> l = getList(name);
    // Make sure the list actually contains attributes.
    if (0 < l.size()) {
      @SuppressWarnings("unused")
      Attribute a = (Attribute)l.get(0);
    }
    return (List<Attribute>)l;
  }
View Full Code Here

   * module name.
   *
   * @return The class name.
   */
  public String getClassName() {
    Attribute att = Attribute.get(Constants.NAME_PARSER, attributes);
    return null == att ? name.name : (String)att.getValue();
  }
View Full Code Here

    if (yyResult.hasValue("option")) {

      yyResult = pAttribute(yyResult.index);
      yyError  = yyResult.select(yyError);
      if (yyResult.hasValue()) {
        final Attribute att = yyResult.semanticValue();

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

          yyBase   = yyRepetition1;
          yyResult = pSymbol(yyBase);
          if (yyResult.hasValue(",")) {

            yyResult = pAttribute(yyResult.index);
            yyError  = yyResult.select(yyError, yyRepetition1);
            if (yyResult.hasValue()) {
              final Attribute v$el$1 = yyResult.semanticValue();

              yyRepetition1 = yyResult.index;
              yyRepValue1   = new Pair<Attribute>(v$el$1, yyRepValue1);
              continue;
            }
View Full Code Here

    // Alternative 2.

    yyResult = pAttribute(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      final Attribute att = yyResult.semanticValue();

      yyResult = pProductionAttributes(yyResult.index);
      yyError  = yyResult.select(yyError);
      if (yyResult.hasValue()) {
        final Pair<Attribute> atts = yyResult.semanticValue();
View Full Code Here

  private Result pAttribute$1(final int yyStart) throws IOException {
    Result     yyResult;
    int        yyBase;
    int        yyOption1;
    Object     yyOpValue1;
    Attribute  yyValue;
    ParseError yyError = ParseError.DUMMY;

    // Alternative 1.

    yyResult = pWord(yyStart);
    if (yyResult.hasValue("public")) {

      yyValue = new Attribute(Constants.NAME_VISIBILITY,
      Constants.VALUE_PUBLIC);

      setLocation(yyValue, yyStart);
      return yyResult.createValue(yyValue, yyError);
    }

    // Alternative 2.

    yyResult = pWord(yyStart);
    if (yyResult.hasValue("protected")) {

      yyValue = new Attribute(Constants.NAME_VISIBILITY,
      Constants.VALUE_PROTECTED);

      setLocation(yyValue, yyStart);
      return yyResult.createValue(yyValue, yyError);
    }

    // Alternative 3.

    yyResult = pWord(yyStart);
    if (yyResult.hasValue("private")) {

      yyValue = new Attribute(Constants.NAME_VISIBILITY,
      Constants.VALUE_PRIVATE);

      setLocation(yyValue, yyStart);
      return yyResult.createValue(yyValue, yyError);
    }

    // Alternative 4.

    yyResult = pWord(yyStart);
    yyError  = yyResult.select(yyError);
    if (yyResult.hasValue()) {
      final String name = yyResult.semanticValue();

      yyOption1  = yyResult.index;
      yyOpValue1 = null;

      yyBase   = yyOption1;
      yyResult = pSymbol(yyBase);
      if (yyResult.hasValue("(")) {

        yyResult = pAttributeValue(yyResult.index);
        yyError  = yyResult.select(yyError, yyOption1);
        if (yyResult.hasValue()) {
          final Object v$el$1 = yyResult.semanticValue();

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

            yyOption1  = yyResult.index;
            yyOpValue1 = v$el$1;
          } else {
            yyError = yyError.select("')' expected", yyBase);
          }
        }
      } else {
        yyError = yyError.select("'(' expected", yyBase);
      }
      { // Start scope for value.
        final Object value = yyOpValue1;

        yyValue = new Attribute(name, value);

        setLocation(yyValue, yyStart);
        return new SemanticValue(yyValue, yyOption1, yyError);
      } // End scope for value.
    }
View Full Code Here

TOP

Related Classes of xtc.tree.Attribute

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.