Package com.lastcalc.parsers.Parser

Examples of com.lastcalc.parsers.Parser.ParseResult


  @Test
  public void successfulParseTest(){
   
    final FactorialParser fp = new FactorialParser();
    ParseResult pr=fp.parse(TokenList.createD("blah","factorial",LargeInteger.valueOf(3),"blah"),1);
    Assert.assertTrue("Ensure parse was succcesful", pr.isSuccess());
    Assert.assertEquals("Ensure parse result is what it's supposed to be",TokenList.createD("blah",LargeInteger.valueOf(6),"blah"), pr.output);
  }
View Full Code Here


 
  @Test
  public void tooBigOrSmallTest(){
   
    final FactorialParser fp = new FactorialParser();
    ParseResult pr=fp.parse(TokenList.createD("blah","factorial",LargeInteger.valueOf(-1),"blah"),1);
    Assert.assertFalse("Ensure parse failed b/c it's a negative num", pr.isSuccess());

    ParseResult pr2=fp.parse(TokenList.createD("blah","factorial",LargeInteger.valueOf(20),"blah"),1);
    Assert.assertFalse("Ensure parse failed b/c it's a too big", pr2.isSuccess());
   
  }
View Full Code Here

          }
        }
        templateScan: while (true) {
          sPos = candidate.matchTemplate(input, sPos + 1);
          if (sPos != -1) {
            final ParseResult parseResult = candidate.parse(input, sPos, context);
            prevAttemptPos.put(attempt, sPos);
            if (parseResult.isSuccess())
              return new ParseStep(input, candidate, parseResult, previous,
                  parseResult.scoreBias);
          } else {
            prevAttemptPos.put(attempt, -2);
            break templateScan;
View Full Code Here

TOP

Related Classes of com.lastcalc.parsers.Parser.ParseResult

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.