Exemple #1
0
  public static Definition setConfiguration(
      Definition node, org.kframework.kil.loader.Context context, final Configuration conf) {
    try {
      return (Definition)
          node.accept(
              new CopyOnWriteTransformer("Configuration setter", context) {
                @Override
                public ASTNode transform(Configuration node) {
                  return conf;
                }

                @Override
                public ASTNode transform(org.kframework.kil.Context node) {
                  return node;
                }

                @Override
                public ASTNode transform(Rule node) {
                  return node;
                }

                @Override
                public ASTNode transform(Syntax node) {
                  return node;
                }
              });
    } catch (TransformerException e) {
      e.printStackTrace();
    }
    return node;
  }
Exemple #2
0
  public static Configuration getConfiguration(
      Definition node, org.kframework.kil.loader.Context context) {
    final List<Configuration> result = new LinkedList<Configuration>();
    node.accept(
        new BasicVisitor(context) {
          @Override
          public void visit(Configuration node) {
            result.add(node);
          }

          @Override
          public void visit(org.kframework.kil.Context node) {
            return;
          }

          @Override
          public void visit(Rule node) {
            return;
          }

          @Override
          public void visit(Syntax node) {
            return;
          }
        });
    if (result.size() == 0) {
      GlobalSettings.kem.register(
          new KException(
              ExceptionType.ERROR,
              KExceptionGroup.INTERNAL,
              "Internal compiler error --- Cannot find configuration.",
              node.getFilename(),
              node.getLocation()));
    }
    return result.get(0);
  }