Package fjord.compiler

Examples of fjord.compiler.Compiler


      out.flush();
    }
  }

  public static String eval(final Environment env, String input) throws Exception {
    final Compiler compiler = new Compiler(String.format("ScriptFragment$%d", counter++));

    Node node = compiler.parse(input);
    if (node == null)
      return "";

    final StringBuilder output = new StringBuilder();

    node.accept(new DefaultNodeVisitor() {
      @Override public void visit(CompilerDirectiveDecl decl) {
        if (decl.getIdent().equals("help"))
          output.append(help());
        else if (decl.getIdent().equals("quit"))
          env.halt();
        else
          output.append(String.format("Invalid directive '%s'\n", decl));
      }
    });

    node.accept(new DefaultNodeVisitor() {
      @Override public void visitAfter(ValueDefn defn) {
        Value val = compiler.codegen(defn);

        output.append(String.format("val %s = %s\n", defn.pattern(), val.eval()));
      }
    });
View Full Code Here

TOP

Related Classes of fjord.compiler.Compiler

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.