Package org.openntf.formula

Examples of org.openntf.formula.FormulaParser


  private ASTNode parse(final String line) throws FormulaParseException {
    ASTNode ast = null;
    if (cacheAST)
      ast = astCache.get(line);

    FormulaParser parser = Formulas.getParser();
    if (ast == null) {
      ast = parser.parse(line);
      if (cacheAST)
        astCache.put(line, ast);
    }
    return ast;
  }
View Full Code Here


  private ASTNode parse(final String line) throws FormulaParseException {
    ASTNode ast = null;
    if (cacheAST)
      ast = astCache.get(line);

    FormulaParser parser = Formulas.getParser();
    if (ast == null) {
      ast = parser.parse(line);
      if (cacheAST)
        astCache.put(line, ast);
    }
    return ast;
  }
View Full Code Here

      }
    }

    // benchmark the AtFormulaParser
    ASTNode ast = null;
    FormulaParser parser = Formulas.getParser();
    try {
      ast = parser.parse(line);
    } catch (FormulaParseException e) {
      errors.append(NTF("\tParser failed: ") + ERROR(e) + "\n");
      e.printStackTrace();
      parserFailed = true;
    } catch (Throwable t) {
View Full Code Here

    fillDemoDoc(ntfMap, rnd);

    // benchmark the AtFormulaParser
    ASTNode ast = null;
    FormulaParser parser = Formulas.getParser();
    try {
      ast = parser.parse(line);
    } catch (FormulaParseException e) {
      errors.append(NTF("\tParser failed: ") + ERROR(e) + "\n");
      e.printStackTrace();
      parserFailed = true;
    } catch (Throwable t) {
View Full Code Here

public class TestServiceLoader {

  public static void main(final String[] args) throws FormulaParseException, EvaluateException {

    final FormulaParser p = Formulas.getParser();

    p.setIncludeProvider(new FormulaProvider<ASTNode>() {

      public ASTNode get(final String key) {
        try {
          if ("demofunc".equals(key)) {
            return p.parse("@listSupportedFunctions");
          }

          if ("ackermann".equals(key)) {
            return p.parse("@Function(@Ack(n;m)) := @if( n = 0; m+1; m=0; @Ack(n-1;1); @Ack(n-1;@Ack(n;m-1))); @Ack(1;1)");
          }
        } catch (FormulaParseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        // TODO Auto-generated method stub
        return null;
      }

    });
    ASTNode x = p.parse(System.in, true);
    FormulaContext ctx = Formulas.createContext(null, p);

    ctx.setParameterProvider(new FormulaProvider<String>() {

      public String get(final String key) {
View Full Code Here

      });
      for (Function func : funcs) {
        System.out.println(func);
      }

      FormulaParser parser = Formulas.getParser();

      for (int i = 1; i < 10000; i++) {
        java.io.StringReader sr = new java.io.StringReader(str);
        //java.io.Reader r = new java.io.BufferedReader(sr);
        n = parser.parse(sr, false);
      }
      time = System.currentTimeMillis() - time;
      System.err.println("[FormulaEngine] 10000x building AST tree\ttook " + time + "ms.");
      //n.dump("");
View Full Code Here

      System.out.println("Please type a Lotus domino @formula. Quit with CTRL+Z:");
      ASTNode n = null;
      List<Object> v = null;

      FormulaParser parser = Formulas.getParser();
      n = parser.parse(System.in, false);
      n.dump("");
      FormulaContext ctx = Formulas.createContext(null, parser);
      v = n.solve(ctx);

      System.out.println("NTF:\t" + v);
View Full Code Here

        map = ((AsDocMap) o).asDocMap();
      if (map != null)
        numParams--;
    }
    try {
      FormulaParser parser = Formulas.getParser();
      ASTNode ast = parser.parse(msgString, true);
      Formatter formatter = Formulas.getFormatter(loc);
      FormulaContext ctx = Formulas.createContext(map, formatter, parser);
      // ctx.useBooleans(false);
      for (int i = 0; i < numParams; i++)
        ctx.setParam(Integer.toString(i + 1), args[i]);
View Full Code Here

TOP

Related Classes of org.openntf.formula.FormulaParser

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.