Package xtc.type

Examples of xtc.type.VariantT


      pln(". */");

    // Ensure that all tuples are concrete and then print the result.
    if (! runtime.test("optionVariant")) {
      // Flat AST definition.
      final VariantT node = ast.toVariant("Node", false);

      ast.concretizeTuples(node, UnitT.TYPE);
      printer.indent().p("module ").p(m.name.name).p("Tree").pln(';');
      printer.pln();
      ast.print(node, printer, true, false, null);
      printer.pln();

    } else {
      // Hierarchical AST definition.
      final VariantT     root      =
        analyzer.lookup((NonTerminal)m.getProperty(Properties.ROOT)).
        type.resolve().toVariant();
      final AST.MetaData meta      = ast.getMetaData(root);
      final Set<String>  processed = new HashSet<String>();

      // Concretize variants.
      for (Production p : m.productions) {
        if (AST.isStaticNode(p.type)) {
          final VariantT variant = p.type.resolve().toVariant();
          final String   name    = variant.getName();

          if (meta.reachable.contains(name) && ! processed.contains(name)) {
            processed.add(name);
            ast.concretizeTuples(variant, UnitT.TYPE);
          }
        }
      }
      processed.clear();

      // Print variants...
      if (! meta.modularize) {
        // ... in a single module.
        printer.indent().p("module ").p(m.name.name).p("Tree").pln(';');
        printer.pln();

        for (Production p : m.productions) {
          if (AST.isStaticNode(p.type)) {
            final VariantT variant = p.type.resolve().toVariant();
            final String   name    = variant.getName();
           
            if (meta.reachable.contains(name) && ! processed.contains(name)) {
              processed.add(name);
              ast.print(variant, printer, true, false, null);
              printer.pln();
            }
          }
        }

      } else {
        // ... across several modules.
        boolean first = true;
        String  module;

        do {
          module = null;

          for (Production p : m.productions) {
            if (AST.isStaticNode(p.type)) {
              final VariantT variant = p.type.resolve().toVariant();
              final String   name    = variant.getName();

              if (meta.reachable.contains(name) && ! processed.contains(name)) {
                final String qualifier = variant.getQualifier();
               
                if (null == module) {
                  module = qualifier;
                 
                  if (first) {
View Full Code Here


      // Print all variant types.
      Set<String> printed = new HashSet<String>();

      for (Production p : m.productions) {
        if (AST.isStaticNode(p.type)) {
          VariantT variant = p.type.resolve().toVariant();

          if (! printed.contains(variant.getName())) {
            printed.add(variant.getName());
            ast.print(variant, runtime.console(), true, true, null);
            runtime.console().pln();
          }
        }
      }
View Full Code Here

                pln(": error: but has alternatives without static type").flush();
              result = ErrorT.TYPE;
              break loop;

            } else {
              VariantT v = result.toVariant();
              result     = merge(ast.toVariant(p.qName.name, true), v, p);
              if (result.isError()) break loop;
              result     = merge(result.toVariant(), t.toVariant(), p);
              if (result.isError()) break loop;
              seenPoly   = true;
View Full Code Here

      // signal an error.
      if (names.isEmpty()) return ErrorT.TYPE;

      // (2) If the production creates generic nodes that already have
      // tuples belonging to the same variant, we return that variant.
      VariantT variant = null;
      boolean  isValid = false;

      for (String name : names) {
        if (ast.hasTuple(name)) {
          final List<VariantT> variants = ast.toVariants(ast.toTuple(name));
View Full Code Here

TOP

Related Classes of xtc.type.VariantT

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.