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

📄 jsgfparser.java

📁 It is the Speech recognition software. It is platform independent. To execute the source code,
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        t.specialToken != null) {      if (t.specialToken.image != null && t.specialToken.image.startsWith("/**")) {        BaseRuleGrammar JG = (BaseRuleGrammar) G;        JG.addGrammarDocComment(t.specialToken.image);      }    }    {if (true) return G;}    throw new Error("Missing return statement in function");  }  final public void IdentHeader() throws ParseException {    jj_consume_token(IDENTIFIER);    jj_consume_token(27);    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case IDENTIFIER:      jj_consume_token(IDENTIFIER);      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case IDENTIFIER:        jj_consume_token(IDENTIFIER);        break;      default:        jj_la1[3] = jj_gen;        ;      }      break;    default:      jj_la1[4] = jj_gen;      ;    }    jj_consume_token(26);  }  final public void ImportDeclaration(RuleGrammar G) throws ParseException { boolean all = false; String name; Token t = null;    t = jj_consume_token(IMPORT);    jj_consume_token(28);    name = Name();    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case 29:      jj_consume_token(29);      jj_consume_token(30);                                         all=true;      break;    default:      jj_la1[5] = jj_gen;      ;    }    jj_consume_token(31);    jj_consume_token(26);   // import all rules if .*    if (all)      name = name + ".*";    RuleName r = new RuleName(name);    if (G != null) {      G.addImport(r);      if (G instanceof BaseRuleGrammar && t != null && t.specialToken != null) {        if (t.specialToken.image != null && t.specialToken.image.startsWith("/**")) {          BaseRuleGrammar JG = (BaseRuleGrammar) G;          JG.addImportDocComment(r, t.specialToken.image);        }      }    }  }  final public String Name() throws ParseException { Token t1, t2; StringBuffer sb = new StringBuffer();    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case IDENTIFIER:      t1 = jj_consume_token(IDENTIFIER);      break;    case PUBLIC:      t1 = jj_consume_token(PUBLIC);      break;    case IMPORT:      t1 = jj_consume_token(IMPORT);      break;    case GRAMMAR:      t1 = jj_consume_token(GRAMMAR);      break;    default:      jj_la1[6] = jj_gen;      jj_consume_token(-1);      throw new ParseException();    }                                                                  sb.append(t1.image);    label_3:    while (true) {      if (jj_2_1(2)) {        ;      } else {        break label_3;      }      jj_consume_token(29);      t2 = jj_consume_token(IDENTIFIER);                                       sb.append('.'); sb.append(t2.image);    }   {if (true) return sb.toString();}    throw new Error("Missing return statement in function");  }  final public void RuleDeclaration(RuleGrammar G) throws ParseException { boolean pub = false; String s; Rule r; Token t = null; Token t1 = null;    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case PUBLIC:      t = jj_consume_token(PUBLIC);                pub=true;      break;    default:      jj_la1[7] = jj_gen;      ;    }    t1 = jj_consume_token(28);    s = ruleDef();    jj_consume_token(31);    jj_consume_token(32);    r = alternatives();    jj_consume_token(26);    try {     if (G != null) {        G.setRule(s,r,pub);        if (G instanceof BaseRuleGrammar) {          BaseRuleGrammar JG = (BaseRuleGrammar) G;          String docComment = null;          if ((t != null) && (t.specialToken != null) && (t.specialToken.image != null))            docComment = t.specialToken.image;          else if ((t1 != null) && (t1.specialToken != null) && (t1.specialToken.image != null))            docComment = t1.specialToken.image;          if (docComment != null && docComment.startsWith("/**"))          {            extractKeywords(JG,s,docComment);            JG.addRuleDocComment(s,docComment);          }          JG.setSourceLine(s,t1.beginLine);       }     }    } catch (IllegalArgumentException e) {     System.out.println("ERROR SETTING RULE " + s);    }  }  final public RuleAlternatives alternatives() throws ParseException { Vector rv = new Vector(); Rule r; float w; float wa[] = new float[25]; int cnt=0;    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case GRAMMAR:    case IMPORT:    case PUBLIC:    case INTEGER_LITERAL:    case STRING_LITERAL:    case IDENTIFIER:    case 28:    case 36:    case 38:      r = sequence();                   rv.addElement(r);      label_4:      while (true) {        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {        case 33:          ;          break;        default:          jj_la1[8] = jj_gen;          break label_4;        }        jj_consume_token(33);        r = sequence();                                                           rv.addElement(r);      }      break;    case 34:      w = weight();      r = sequence();                              rv.addElement(r); wa[cnt++]=w;      label_5:      while (true) {        jj_consume_token(33);        w = weight();        r = sequence();                        rv.addElement(r);                        // make array bigger if needed                        if (cnt > (wa.length-1)) {                         float watmp[] = new float[wa.length+25];                         System.arraycopy(wa,0,watmp,0,wa.length);                         wa = watmp;                        }                        wa[cnt++]=w;        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {        case 33:          ;          break;        default:          jj_la1[9] = jj_gen;          break label_5;        }      }      break;    default:      jj_la1[10] = jj_gen;      jj_consume_token(-1);      throw new ParseException();    }     Rule rarry[] = new Rule[rv.size()];     rv.copyInto(rarry);     RuleAlternatives ra = new RuleAlternatives(rarry);     if (cnt != 0) {      float wa1[] = new float[cnt];      System.arraycopy(wa,0,wa1,0,cnt);      try {       ra.setWeights(wa1);      } catch (IllegalArgumentException e) {        System.out.println("ERROR " + e);      }     }     {if (true) return ra;}    throw new Error("Missing return statement in function");  }  final public String ruleDef() throws ParseException { Token t;    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case IDENTIFIER:      t = jj_consume_token(IDENTIFIER);      break;    case INTEGER_LITERAL:      t = jj_consume_token(INTEGER_LITERAL);      break;    case PUBLIC:      t = jj_consume_token(PUBLIC);      break;    case IMPORT:      t = jj_consume_token(IMPORT);      break;    case GRAMMAR:      t = jj_consume_token(GRAMMAR);      break;    default:      jj_la1[11] = jj_gen;      jj_consume_token(-1);      throw new ParseException();    }    {if (true) return t.image;}    throw new Error("Missing return statement in function");  }  final public RuleSequence sequence() throws ParseException { Rule r; Vector v = new Vector();    label_6:    while (true) {      r = item();              v.addElement(r);      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case GRAMMAR:      case IMPORT:      case PUBLIC:      case INTEGER_LITERAL:      case STRING_LITERAL:      case IDENTIFIER:      case 28:      case 36:      case 38:        ;        break;      default:        jj_la1[12] = jj_gen;        break label_6;      }    }    Rule ra[] = new Rule[v.size()];    v.copyInto(ra);    {if (true) return new RuleSequence(ra);}    throw new Error("Missing return statement in function");  }  final public float weight() throws ParseException { Token t; float f;    jj_consume_token(34);    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case FLOATING_POINT_LITERAL:      t = jj_consume_token(FLOATING_POINT_LITERAL);      break;    case INTEGER_LITERAL:      t = jj_consume_token(INTEGER_LITERAL);      break;    default:      jj_la1[13] = jj_gen;      jj_consume_token(-1);      throw new ParseException();    }    jj_consume_token(34);    {if (true) return Float.valueOf(t.image).floatValue();}    throw new Error("Missing return statement in function");  }  final public Rule item() throws ParseException { Rule r; Vector t = null; int count=-1;    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case GRAMMAR:    case IMPORT:    case PUBLIC:    case INTEGER_LITERAL:    case STRING_LITERAL:    case IDENTIFIER:    case 28:      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case GRAMMAR:      case IMPORT:      case PUBLIC:      case INTEGER_LITERAL:      case STRING_LITERAL:      case IDENTIFIER:        r = terminal();        break;      case 28:        r = ruleRef();        break;      default:        jj_la1[14] = jj_gen;        jj_consume_token(-1);        throw new ParseException();      }      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case 30:      case 35:        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {        case 30:          jj_consume_token(30);                    count=RuleCount.ZERO_OR_MORE;          break;        case 35:          jj_consume_token(35);                                                            count=RuleCount.ONCE_OR_MORE;          break;        default:          jj_la1[15] = jj_gen;          jj_consume_token(-1);          throw new ParseException();        }        break;      default:        jj_la1[16] = jj_gen;        ;      }      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case TAG:        t = tag();        break;      default:        jj_la1[17] = jj_gen;        ;      }      break;    case 36:      jj_consume_token(36);      r = alternatives();      jj_consume_token(37);      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case 30:      case 35:        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {        case 30:          jj_consume_token(30);                    count=RuleCount.ZERO_OR_MORE;          break;        case 35:          jj_consume_token(35);                                                            count=RuleCount.ONCE_OR_MORE;          break;        default:          jj_la1[18] = jj_gen;          jj_consume_token(-1);          throw new ParseException();        }        break;      default:        jj_la1[19] = jj_gen;        ;      }      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case TAG:        t = tag();        break;      default:        jj_la1[20] = jj_gen;        ;

⌨️ 快捷键说明

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