Package fasp.parser.tokenizer

Examples of fasp.parser.tokenizer.Token


   * @throws fasp.parser.ParseException
   */
  @Override
  public FaspVariable parse(TokenState st) throws ParseException {
    if (getResult() == null) {
      Token lookahead = st.lookahead();
      if(lookahead.getType().equals(Token.Type.SYMBOL)) {
        SymbolToken sym = (SymbolToken)lookahead;
        if(Character.isUpperCase(sym.getSymbol().charAt(0))) {
          st.eat();
          return new FaspVariable(sym.getSymbol());
        } else {
View Full Code Here


    NonGroundLiteral litHead = null;
    LattVal constHead = null;
    LiteralParser headParser = new LiteralParser();
    LattValParser constParser = new LattValParser();
    // Following is needed for proper error line output:
    Token headToken = st.lookahead();
    if(headParser.tryParse(st)) {
      litHead = headParser.getResult();
      if(litHead.isNaf())
        throw new ParseException(headToken.getLocation(),"non-naf-literal","naf-literal: "+litHead.toString());
      constraint = false;
    } else if(constParser.tryParse(st)) {
      constHead = constParser.getResult();
      constraint = true;
    } else {
      throw new ParseException(st,"literal or lattice constant",st.lookahead().toString());
    }

    // Next: get the rule type token
    Token ruleType = st.getNext();
    if(!(ruleType.getType().equals(Token.Type.FUZZYRULE)
        || ruleType.getType().equals(Token.Type.REGRULE)
        || ruleType.getType().equals(Token.Type.CHOICERULE)))
      throw new ParseException(st,"rule symbol (:-, :/, or :~)",ruleType.toString());

    // Now parse the rule operator
    Token bodyOpTok = st.getNext();
    if(!bodyOpTok.getType().equals(Token.Type.SYMBOL))
      throw new ParseException(bodyOpTok.getLocation(),"body operator",bodyOpTok.toString());

    SymbolToken bodyOpSym = (SymbolToken)bodyOpTok;

    if(!BODYOPERATORS.containsKey(bodyOpSym.getSymbol()))
      throw new ParseException(st,unsupportedBodyOp(),bodyOpSym.getSymbol());
View Full Code Here

*/
public class BodyExpParser extends AbstractParser<BodyExpression> {
  public BodyExpression parse(TokenState st) throws ParseException {
    FaspVariable leftOp = new VariableParser().parse(st);
    FaspBodyOp op;
    Token opTok = st.getNext();
    if(opTok.getType().equals(Token.Type.NEQOP))
      op = new FaspBodyOpIneq();
    else if(opTok.getType().equals(Token.Type.EQOP))
      op = new FaspBodyOpEq();
    else
      throw new ParseException(opTok.getLocation(),"body expression operator (== or /=)",opTok.toString());

    ConstantParser constP = new ConstantParser();
    VariableParser varP = new VariableParser();
    if(constP.tryParse(st))
      return new BodyExpression(op,leftOp,constP.getResult());
View Full Code Here

    boolean naf = false;
    boolean neg = false;
    UnaryOperator negOp = null;
    if(nafSym.tryParse(st)) {
      naf = true;
      Token negOpTok = st.getNext();
      if(!negOpTok.getType().equals(Token.Type.SYMBOL))
        throw new ParseException(negOpTok.getLocation(),"naf operator",negOpTok.toString());

      SymbolToken negOpSym = (SymbolToken)negOpTok;

      if(!NEGATIONOPERATORS.containsKey(negOpSym.getSymbol()))
        throw new ParseException(st,unsupportedNegationOp(),negOpSym.getSymbol());
View Full Code Here

   * @throws fasp.parser.ParseException
   */
  @Override
  public FaspConstant parse(TokenState st) throws ParseException {
    if (getResult() == null) {
      Token lookahead = st.lookahead();
      if(lookahead.getType().equals(Token.Type.SYMBOL)) {
        SymbolToken sym = (SymbolToken)lookahead;
        if(Character.isLowerCase(sym.getSymbol().charAt(0))) {
          st.eat();
          return new FaspConstant(sym.getSymbol());
        } else {
View Full Code Here

TOP

Related Classes of fasp.parser.tokenizer.Token

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.