Package exception

Examples of exception.ParsingException


        this.lookahead++;
        positive = false;
      }
     
      if (this.lookahead >= tokens.size()) {
        throw new ParsingException("unexpected token at " + tk.getInitIndex());
      }
     
      tk = tokens.get(this.lookahead);
     
      BigDecimal value = null;
      // Parses the value, depending on terminal type
      if (tk.getType() == TypeEnum.NUMBER) {
        this.lookahead++;
        value = new BigDecimal(tk.getText());
       
        if (!positive) {
          value = value.negate();
        }
       
        return value;
      } else if (tk.getType() == TypeEnum.IDENTIFIER) {
        this.lookahead++;
        value = values.get(tk.getText());
       
        if (!positive) {
          value = value.negate();
        }
       
        return value;
      } else
      // Parses subexpressions
      if (tk.getType() == TypeEnum.OPEN_BRACK) {
        this.lookahead++;
       
        value = this.exp(tokens, values);
       
        tk = tokens.get(this.lookahead);
        if (tk.getType() == TypeEnum.CLOSE_BRACK) {
          this.lookahead++;
          return value;
        }
      }
    }
   
    // Throws an error when an unexpected token is found
    throw new ParsingException("unexpected token at " + tk.getInitIndex());
  }
View Full Code Here

TOP

Related Classes of exception.ParsingException

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.