⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 slparser.java

📁 人工智能中Agent开发包。多 Agent 系统是处理自治 Agent 之间知识层的协作问题
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
      while (true) {
        Parameter(val);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case PARAMETERNAME:
          ;
          break;
        default:
          jj_la1[11] = jj_gen;
          break label_3;
        }
      }
      break;
    default:
      jj_la1[12] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  final public void Parameter(AbsConcept val) throws ParseException {
  Token t; AbsTerm term;
    t = jj_consume_token(PARAMETERNAME);
    term = Term();
                                val.set(t.image.substring(1),term);
  }

  final public AbsAgentAction ActionExpression_NoBrace() throws ParseException {
  AbsAgentAction val=null; AbsTerm term1, term2; Token t;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case ACTION:
      t = jj_consume_token(ACTION);
      term1 = Term();
      term2 = Term();
       val = new AbsAgentAction(t.image);
       try {
           String slotNames[] = curOntology.getSchema(t.image).getNames();
           val.set(slotNames[0], term1);
           val.set(slotNames[1], toAbsAgentAction(term2));
        } catch (Exception e) {
           val.set(Codec.UNNAMEDPREFIX+"0", term1);
           val.set(Codec.UNNAMEDPREFIX+"1", toAbsAgentAction(term2));
        }
      break;
    case ACTIONOPLL:
      t = jj_consume_token(ACTIONOPLL);
                    if (slType<2) {if (true) throw new ParseException("NotFullSL_ActionOperatorExpression_NotParsable");}
      term1 = ActionExpression();
      term2 = ActionExpression();
       val = new AbsAgentAction(t.image);
       try {
           String slotNames[] = curOntology.getSchema(t.image).getNames();
           val.set(slotNames[0], term1);
           val.set(slotNames[1], toAbsAgentAction(term2));
        } catch (Exception e) {
           val.set(Codec.UNNAMEDPREFIX+"0", term1);
           val.set(Codec.UNNAMEDPREFIX+"1", toAbsAgentAction(term2));
        }
      break;
    default:
      jj_la1[13] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
   {if (true) return val;}
    throw new Error("Missing return statement in function");
  }

  final public AbsAgentAction ActionExpression() throws ParseException {
  AbsAgentAction val=null;
    LBrace();
    val = ActionExpression_NoBrace();
    RBrace();
   {if (true) return val;}
    throw new Error("Missing return statement in function");
  }

  final public AbsPredicate Wff() throws ParseException {
  AbsPredicate val=null; String s;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case WORD:
    case STRING_LITERAL:
    case WORD2:
    case STRING_LITERAL2:
      s = String();
                 val = new AbsPredicate(s);
      break;
    case LBRACE:
    case LBRACE2:
      LBrace();
      val = Wff_NoBrace();
      RBrace();
      break;
    default:
      jj_la1[14] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  {if (true) return val;}
    throw new Error("Missing return statement in function");
  }

  final public AbsPredicate Wff_NoBrace() throws ParseException {
  AbsPredicate arg1, arg2, val=null; Token t; AbsTerm term; String s;
  AbsAgentAction act; String slotNames[]=null;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case UNARYLOGICALOP:
      t = jj_consume_token(UNARYLOGICALOP);
                        if (slType<1) {if (true) throw new ParseException("NotFullSL_NotExpression_NotParsable_UseAtLeastSL1");}
      arg1 = Wff();
    val = new AbsPredicate(t.image);
    try {
           slotNames = curOntology.getSchema(t.image).getNames();
           val.set(slotNames[0], arg1);
        } catch (Exception e) {
           val.set(Codec.UNNAMEDPREFIX+"0", arg1);
        }
      break;
    case BINARYLOGICALOP:
      t = jj_consume_token(BINARYLOGICALOP);
                         if (slType<1) {if (true) throw new ParseException("NotFullSL_BinaryLogicalExpression_NotParsable_UseAtLeastSL1");}
      arg1 = Wff();
      arg2 = Wff();
    val = new AbsPredicate(t.image);
    try {
           slotNames = curOntology.getSchema(t.image).getNames();
           val.set(slotNames[0], arg1);
           val.set(slotNames[1], arg2);
        } catch (Exception e) {
           val.set(Codec.UNNAMEDPREFIX+"0", arg1);
           val.set(Codec.UNNAMEDPREFIX+"1", arg2);
        }
      break;
    case QUANTIFIER:
      t = jj_consume_token(QUANTIFIER);
                    if (slType<2) {if (true) throw new ParseException("NotFullSL_QuantifierExpression_NotParsable_UseAtLeastSL2");} AbsVariable var;
      var = Variable();
      arg1 = Wff();
    val = new AbsPredicate(t.image);
    try {
           slotNames = curOntology.getSchema(t.image).getNames();
           val.set(slotNames[0], var);
           val.set(slotNames[1], arg1);
        } catch (Exception e) {
           val.set(Codec.UNNAMEDPREFIX+"0", var);
           val.set(Codec.UNNAMEDPREFIX+"1", arg1);
        }
      break;
    case MODALOP:
      t = jj_consume_token(MODALOP);
                 if (slType<2) {if (true) throw new ParseException("NotFullSL_ModalOperatorExpression_NotParsable_UseAtLeastSL2");}
      term = Term();
      arg1 = Wff();
    val = new AbsPredicate(t.image);
    try {
           slotNames = curOntology.getSchema(t.image).getNames();
           val.set(slotNames[0], term);
           val.set(slotNames[1], arg1);
        } catch (Exception e) {
           val.set(Codec.UNNAMEDPREFIX+"0", term);
           val.set(Codec.UNNAMEDPREFIX+"1", arg1);
        }
      break;
    case ACTIONOP:
      t = jj_consume_token(ACTIONOP);
      act = ActionExpression();
    val = new AbsPredicate(t.image);
    try {
           slotNames = curOntology.getSchema(t.image).getNames();
           val.set(slotNames[0], act);
        } catch (Exception e) {
           val.set(Codec.UNNAMEDPREFIX+"0", act);
        }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case LBRACE:
      case WORD:
      case STRING_LITERAL:
      case LBRACE2:
      case WORD2:
      case STRING_LITERAL2:
        arg1 = Wff();
    try {
           val.set(slotNames[1], arg1);
        } catch (Exception e) {
           val.set(Codec.UNNAMEDPREFIX+"1", arg1);
        }
        break;
      default:
        jj_la1[15] = jj_gen;
        ;
      }
      break;
    case WORD:
    case STRING_LITERAL:
    case WORD2:
    case STRING_LITERAL2:
      s = String();
                val = new AbsPredicate(s); int slotNumber=0;
                try {
                   slotNames = curOntology.getSchema(s).getNames();
                } catch (Exception e) {
                }
      label_4:
      while (true) {
        term = Term();
                try {
                  val.set(slotNames[slotNumber], term);
              } catch (Exception e) {
                  val.set(Codec.UNNAMEDPREFIX+slotNumber, term);
              }
              slotNumber++;
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case LBRACE:
        case VARIABLE:
        case INTEGER:
        case HEXINTEGER:
        case FLOATONE:
        case FLOATTWO:
        case WORD:
        case STRING_LITERAL:
        case DATETIME:
        case LBRACE2:
        case WORD2:
        case STRING_LITERAL2:
          ;
          break;
        default:
          jj_la1[16] = jj_gen;
          break label_4;
        }
      }
      break;
    default:
      jj_la1[17] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  {if (true) return val;}
    throw new Error("Missing return statement in function");
  }

  final public AbsPrimitive Number() throws ParseException {
   Token t; AbsPrimitive val = null;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case INTEGER:
      t = jj_consume_token(INTEGER);
                    long value;
                  try {
                   val = AbsPrimitive.wrap(Long.parseLong(t.image));
                  } catch (NumberFormatException e) { //should never happen
                   e.printStackTrace();
                   val=AbsPrimitive.wrap(t.image);
                  }
      break;
    case HEXINTEGER:
      t = jj_consume_token(HEXINTEGER);
                      val=AbsPrimitive.wrap(t.image);
      break;
    case FLOATONE:
      t = jj_consume_token(FLOATONE);
                    double d1;
                   try {
                    // J2ME incompatible d1=Double.parseDouble(t.image); 
                    d1=(new Double(t.image)).doubleValue();
                    val=AbsPrimitive.wrap(d1);
                  } catch (NumberFormatException e) { //should never happen
                    e.printStackTrace();
                    val=AbsPrimitive.wrap(t.image);
                  }
      break;
    case FLOATTWO:
      t = jj_consume_token(FLOATTWO);
                    double d2;
                   try {
                    // J2ME incompatible d2=Double.parseDouble(t.image); 
                    d2=(new Double(t.image)).doubleValue();
                    val=AbsPrimitive.wrap(d2);
                  } catch (NumberFormatException e) { //should never happen
                    e.printStackTrace();
                    val=AbsPrimitive.wrap(t.image);
                  }
      break;
    default:
      jj_la1[18] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
 {if (true) return val;}
    throw new Error("Missing return statement in function");
  }

/**
* <p> <code> String = WORD | STRING_LITERAL  </code>
*/
  final public String String() throws ParseException {
  Token t;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case WORD2:
      t = jj_consume_token(WORD2);
                         {if (true) return t.image;}
      break;
    case STRING_LITERAL2:
      t = jj_consume_token(STRING_LITERAL2);
                         {if (true) return unescape(t.image);}
      break;
    case WORD:
      t = jj_consume_token(WORD);
                         {if (true) return t.image;}
      break;
    case STRING_LITERAL:
      t = jj_consume_token(STRING_LITERAL);
                         {if (true) return unescape(t.image);}
      break;
    default:
      jj_la1[19] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    throw new Error("Missing return statement in function");
  }

  public SLParserTokenManager token_source;
  ASCII_CharStream jj_input_stream;
  public Token token, jj_nt;
  private int jj_ntk;
  private int jj_gen;
  final private int[] jj_la1 = new int[20];
  final private int[] jj_la1_0 = {0x80103020,0x100020,0x200040,0x80103020,0xfdc03000,0x8ac03000,0x8010bfa0,0x8000bf00,0x8010ffa0,0x82003000,0x8010bfa0,0x4000,0x8010ffa0,0x8400000,0x80103020,0x80103020,0x8010bfa0,0xf5003000,0xf00,0x80003000,};
  final private int[] jj_la1_1 = {0x1,0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x1,0x0,0x1,0x1,0x1,0x1,0x0,0x1,};

  public SLParser(java.io.InputStream stream) {
    jj_input_stream = new ASCII_CharStream(stream, 1, 1);
    token_source = new SLParserTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 20; i++) jj_la1[i] = -1;
  }

  public void ReInit(java.io.InputStream stream) {
    jj_input_stream.ReInit(stream, 1, 1);
    token_source.ReInit(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 20; i++) jj_la1[i] = -1;
  }

  public SLParser(java.io.Reader stream) {
    jj_input_stream = new ASCII_CharStream(stream, 1, 1);
    token_source = new SLParserTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 20; i++) jj_la1[i] = -1;
  }

  public void ReInit(java.io.Reader stream) {
    jj_input_stream.ReInit(stream, 1, 1);
    token_source.ReInit(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 20; i++) jj_la1[i] = -1;
  }

  public SLParser(SLParserTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 20; i++) jj_la1[i] = -1;
  }

  public void ReInit(SLParserTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 20; i++) jj_la1[i] = -1;
  }

  final private Token jj_consume_token(int kind) throws ParseException {
    Token oldToken;
    if ((oldToken = token).next != null) token = token.next;
    else token = token.next = token_source.getNextToken();
    jj_ntk = -1;
    if (token.kind == kind) {
      jj_gen++;
      return token;
    }
    token = oldToken;
    jj_kind = kind;
    throw generateParseException();
  }

  final public Token getNextToken() {
    if (token.next != null) token = token.next;
    else token = token.next = token_source.getNextToken();
    jj_ntk = -1;
    jj_gen++;
    return token;
  }

  final public Token getToken(int index) {
    Token t = token;
    for (int i = 0; i < index; i++) {
      if (t.next != null) t = t.next;
      else t = t.next = token_source.getNextToken();
    }
    return t;
  }

  final private int jj_ntk() {
    if ((jj_nt=token.next) == null)
      return (jj_ntk = (token.next=token_source.getNextToken()).kind);
    else
      return (jj_ntk = jj_nt.kind);
  }

  private java.util.Vector jj_expentries = new java.util.Vector();
  private int[] jj_expentry;
  private int jj_kind = -1;

  final public ParseException generateParseException() {
    jj_expentries.removeAllElements();
    boolean[] la1tokens = new boolean[33];
    for (int i = 0; i < 33; i++) {
      la1tokens[i] = false;
    }
    if (jj_kind >= 0) {
      la1tokens[jj_kind] = true;
      jj_kind = -1;
    }
    for (int i = 0; i < 20; i++) {
      if (jj_la1[i] == jj_gen) {
        for (int j = 0; j < 32; j++) {
          if ((jj_la1_0[i] & (1<<j)) != 0) {
            la1tokens[j] = true;
          }
          if ((jj_la1_1[i] & (1<<j)) != 0) {
            la1tokens[32+j] = true;
          }
        }
      }
    }
    for (int i = 0; i < 33; i++) {
      if (la1tokens[i]) {
        jj_expentry = new int[1];
        jj_expentry[0] = i;
        jj_expentries.addElement(jj_expentry);
      }
    }
    int[][] exptokseq = new int[jj_expentries.size()][];
    for (int i = 0; i < jj_expentries.size(); i++) {
      exptokseq[i] = (int[])jj_expentries.elementAt(i);
    }
    return new ParseException(token, exptokseq, tokenImage);
  }

  final public void enable_tracing() {
  }

  final public void disable_tracing() {
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -