Package Parser

Examples of Parser.Parser


  public void testMinus() throws LexicalException, Exception {
    ValueMap values = new ValueMap();
    values.put("val1", new BigDecimal(5));
    values.put("val2", new BigDecimal(10));
   
    Parser p = new Parser("val1-val2");
    BigDecimal value;
    value = p.eval(p.lexicalVerifier(), values);
    assertEquals(value.compareTo(new BigDecimal("-5")), 0);
  }
View Full Code Here


  public void testMult() throws LexicalException, Exception {
    ValueMap values = new ValueMap();
    values.put("val1", new BigDecimal(3));
    values.put("val2", new BigDecimal(10));
   
    Parser p = new Parser("val1*val2");
    BigDecimal value;
    value = p.eval(p.lexicalVerifier(), values);
    assertEquals(value.compareTo(new BigDecimal("30")), 0);
  }
View Full Code Here

  public void testDiv() throws LexicalException, Exception {
    ValueMap values = new ValueMap();
    values.put("val1", new BigDecimal(10));
    values.put("val2", new BigDecimal(2));
   
    Parser p = new Parser("val1/val2");
    BigDecimal value;
    value = p.eval(p.lexicalVerifier(), values);
    assertEquals(value.compareTo(new BigDecimal("5")), 0);
  }
View Full Code Here

    ValueMap values = new ValueMap();
    values.put("val1", new BigDecimal(5));
    values.put("val2", new BigDecimal(8));
    values.put("val3", new BigDecimal(3));
   
    Parser p = new Parser("val1+(val2+val3)");
    BigDecimal value;
    value = p.eval(p.lexicalVerifier(), values);
    assertEquals(value.compareTo(new BigDecimal("16")), 0);
  }
View Full Code Here

    ValueMap values = new ValueMap();
    values.put("val1", new BigDecimal(5));
    values.put("val2", new BigDecimal(8));
    values.put("val3", new BigDecimal(3));
   
    Parser p = new Parser("val1-(val2-val3)");
    BigDecimal value;
    value = p.eval(p.lexicalVerifier(), values);
    assertEquals(value.compareTo(new BigDecimal("0")), 0);
  }
View Full Code Here

    ValueMap values = new ValueMap();
    values.put("val1", new BigDecimal(5));
    values.put("val2", new BigDecimal(8));
    values.put("val3", new BigDecimal(3));
   
    Parser p = new Parser("val1*(val2*val3)");
    BigDecimal value;
    value = p.eval(p.lexicalVerifier(), values);
    assertEquals(value.compareTo(new BigDecimal("120")), 0);
  }
View Full Code Here

    ValueMap values = new ValueMap();
    values.put("val1", new BigDecimal(12));
    values.put("val2", new BigDecimal(9));
    values.put("val3", new BigDecimal(3));
   
    Parser p = new Parser("val1/(val2/val3)");
    BigDecimal value;
    value = p.eval(p.lexicalVerifier(), values);
    assertEquals(value.compareTo(new BigDecimal("4")), 0);
  }
View Full Code Here

    values.put("val2", new BigDecimal(7));
    values.put("val3", new BigDecimal(8));
    values.put("val4", new BigDecimal(20));
    values.put("val5", new BigDecimal(80));
   
    Parser p = new Parser("val1+val2-(val3*val4/val5)+val1^2.0^3.0");
    BigDecimal value = p.eval(p.lexicalVerifier(), values);
   
    assertEquals(value.compareTo(new BigDecimal("390635")), 0);
  }
View Full Code Here

    values.put("val2", new BigDecimal(7));
    values.put("val3", new BigDecimal(8));
    values.put("val4", new BigDecimal(20));
    values.put("val5", new BigDecimal(20));
   
    Parser p = new Parser("val1+val2-(val3*val4/val5^2.0)+val1^2.0^3.0");
    BigDecimal value = p.eval(p.lexicalVerifier(), values);
   
    assertEquals(value.compareTo(new BigDecimal("390636.6")), 0);
  }
View Full Code Here

    values.put("val2", new BigDecimal(7));
    values.put("val3", new BigDecimal(8));
    values.put("val4", new BigDecimal(20));
    values.put("val5", new BigDecimal(20));
   
    Parser p = new Parser("val1+val2-((val3*val4/val5)^2.0)+val1^2.0^3.0");
    BigDecimal value = p.eval(p.lexicalVerifier(), values);
   
    assertEquals(value.compareTo(new BigDecimal("390573")), 0);
  }
View Full Code Here

TOP

Related Classes of Parser.Parser

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.