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

📄 elparser.java

📁 业界著名的tomcat服务器的最新6.0的源代码。
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* Generated By:JJTree&JavaCC: Do not edit this line. ELParser.java */
package org.apache.el.parser;
import java.io.StringReader;
import javax.el.ELException;
public class ELParser/*@bgen(jjtree)*/implements ELParserTreeConstants, ELParserConstants {/*@bgen(jjtree)*/
  protected JJTELParserState jjtree = new JJTELParserState();public static Node parse(String ref) throws ELException
    {
        try {
                return (new ELParser(new StringReader(ref))).CompositeExpression();
        } catch (ParseException pe) {
                throw new ELException(pe.getMessage());
        }
    }
  
  public static void main(String[] argv) throws Exception {
	  String[] str = { "${foo()}", "${fn.fn:foo() ? a : b}", "${fn:foo() ? (fn_af.f:fd() ? a : b) : b}", "${a.b.c ? a : b}" };
		for (int i = 0; i < str.length; i++) {
			SimpleNode sn = (SimpleNode) ELParser.parse(str[i]);
			System.out.println("====\n" + str[i]);
			sn.dump("\t");
		}
  }

/*
 * CompositeExpression
 * Allow most flexible parsing, restrict by examining
 * type of returned node
 */
  final public AstCompositeExpression CompositeExpression() throws ParseException {
                                                                     /*@bgen(jjtree) CompositeExpression */
  AstCompositeExpression jjtn000 = new AstCompositeExpression(JJTCOMPOSITEEXPRESSION);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      label_1:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case LITERAL_EXPRESSION:
        case START_DYNAMIC_EXPRESSION:
        case START_DEFERRED_EXPRESSION:
          ;
          break;
        default:
          jj_la1[0] = jj_gen;
          break label_1;
        }
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case START_DEFERRED_EXPRESSION:
          DeferredExpression();
          break;
        case START_DYNAMIC_EXPRESSION:
          DynamicExpression();
          break;
        case LITERAL_EXPRESSION:
          LiteralExpression();
          break;
        default:
          jj_la1[1] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
      }
      jj_consume_token(0);
                                                                                    jjtree.closeNodeScope(jjtn000, true);
                                                                                    jjtc000 = false;
                                                                                    {if (true) return jjtn000;}
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
    throw new Error("Missing return statement in function");
  }

/*
 * LiteralExpression
 * Non-EL Expression blocks
 */
  final public void LiteralExpression() throws ParseException {
                                               /*@bgen(jjtree) LiteralExpression */
                                                AstLiteralExpression jjtn000 = new AstLiteralExpression(JJTLITERALEXPRESSION);
                                                boolean jjtc000 = true;
                                                jjtree.openNodeScope(jjtn000);Token t = null;
    try {
      t = jj_consume_token(LITERAL_EXPRESSION);
                                 jjtree.closeNodeScope(jjtn000, true);
                                 jjtc000 = false;
                                 jjtn000.setImage(t.image);
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

/*
 * DeferredExpression
 * #{..} Expressions
 */
  final public void DeferredExpression() throws ParseException {
                                                 /*@bgen(jjtree) DeferredExpression */
  AstDeferredExpression jjtn000 = new AstDeferredExpression(JJTDEFERREDEXPRESSION);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      jj_consume_token(START_DEFERRED_EXPRESSION);
      Expression();
      jj_consume_token(END_EXPRESSION);
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

/*
 * DynamicExpression
 * ${..} Expressions
 */
  final public void DynamicExpression() throws ParseException {
                                               /*@bgen(jjtree) DynamicExpression */
  AstDynamicExpression jjtn000 = new AstDynamicExpression(JJTDYNAMICEXPRESSION);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      jj_consume_token(START_DYNAMIC_EXPRESSION);
      Expression();
      jj_consume_token(END_EXPRESSION);
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

/*
 * Expression
 * EL Expression Language Root, goes to Choice
 */
  final public void Expression() throws ParseException {
    Choice();
  }

/*
 * Choice
 * For Choice markup a ? b : c, then Or
 */
  final public void Choice() throws ParseException {
    Or();
    label_2:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case QUESTIONMARK:
        ;
        break;
      default:
        jj_la1[2] = jj_gen;
        break label_2;
      }
      jj_consume_token(QUESTIONMARK);
      Or();
      jj_consume_token(COLON);
                                            AstChoice jjtn001 = new AstChoice(JJTCHOICE);
                                            boolean jjtc001 = true;
                                            jjtree.openNodeScope(jjtn001);
      try {
        Choice();
      } catch (Throwable jjte001) {
                                            if (jjtc001) {
                                              jjtree.clearNodeScope(jjtn001);
                                              jjtc001 = false;
                                            } else {
                                              jjtree.popNode();
                                            }
                                            if (jjte001 instanceof RuntimeException) {
                                              {if (true) throw (RuntimeException)jjte001;}
                                            }
                                            if (jjte001 instanceof ParseException) {
                                              {if (true) throw (ParseException)jjte001;}
                                            }
                                            {if (true) throw (Error)jjte001;}
      } finally {
                                            if (jjtc001) {
                                              jjtree.closeNodeScope(jjtn001,  3);
                                            }
      }
    }
  }

/*
 * Or
 * For 'or' '||', then And
 */
  final public void Or() throws ParseException {
    And();
    label_3:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case OR0:
      case OR1:
        ;
        break;
      default:
        jj_la1[3] = jj_gen;
        break label_3;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case OR0:
        jj_consume_token(OR0);
        break;
      case OR1:
        jj_consume_token(OR1);
        break;
      default:
        jj_la1[4] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
                               AstOr jjtn001 = new AstOr(JJTOR);
                               boolean jjtc001 = true;
                               jjtree.openNodeScope(jjtn001);
      try {
        And();
      } catch (Throwable jjte001) {
                               if (jjtc001) {
                                 jjtree.clearNodeScope(jjtn001);
                                 jjtc001 = false;
                               } else {
                                 jjtree.popNode();
                               }
                               if (jjte001 instanceof RuntimeException) {
                                 {if (true) throw (RuntimeException)jjte001;}
                               }
                               if (jjte001 instanceof ParseException) {
                                 {if (true) throw (ParseException)jjte001;}
                               }
                               {if (true) throw (Error)jjte001;}
      } finally {
                               if (jjtc001) {
                                 jjtree.closeNodeScope(jjtn001,  2);
                               }
      }
    }
  }

/*
 * And
 * For 'and' '&&', then Equality
 */
  final public void And() throws ParseException {
    Equality();
    label_4:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case AND0:
      case AND1:
        ;
        break;
      default:
        jj_la1[5] = jj_gen;
        break label_4;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case AND0:
        jj_consume_token(AND0);
        break;
      case AND1:
        jj_consume_token(AND1);
        break;
      default:
        jj_la1[6] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
                                      AstAnd jjtn001 = new AstAnd(JJTAND);
                                      boolean jjtc001 = true;
                                      jjtree.openNodeScope(jjtn001);
      try {
        Equality();
      } catch (Throwable jjte001) {
                                      if (jjtc001) {
                                        jjtree.clearNodeScope(jjtn001);
                                        jjtc001 = false;
                                      } else {
                                        jjtree.popNode();
                                      }
                                      if (jjte001 instanceof RuntimeException) {
                                        {if (true) throw (RuntimeException)jjte001;}
                                      }
                                      if (jjte001 instanceof ParseException) {
                                        {if (true) throw (ParseException)jjte001;}
                                      }
                                      {if (true) throw (Error)jjte001;}
      } finally {
                                      if (jjtc001) {
                                        jjtree.closeNodeScope(jjtn001,  2);
                                      }
      }
    }
  }

/*
 * Equality
 * For '==' 'eq' '!=' 'ne', then Compare
 */
  final public void Equality() throws ParseException {
    Compare();
    label_5:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case EQ0:
      case EQ1:
      case NE0:
      case NE1:
        ;
        break;
      default:
        jj_la1[7] = jj_gen;
        break label_5;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case EQ0:
      case EQ1:
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case EQ0:
          jj_consume_token(EQ0);
          break;
        case EQ1:
          jj_consume_token(EQ1);
          break;
        default:
          jj_la1[8] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
                                 AstEqual jjtn001 = new AstEqual(JJTEQUAL);
                                 boolean jjtc001 = true;
                                 jjtree.openNodeScope(jjtn001);
        try {
          Compare();
        } catch (Throwable jjte001) {
                                 if (jjtc001) {
                                   jjtree.clearNodeScope(jjtn001);
                                   jjtc001 = false;
                                 } else {
                                   jjtree.popNode();
                                 }
                                 if (jjte001 instanceof RuntimeException) {
                                   {if (true) throw (RuntimeException)jjte001;}
                                 }
                                 if (jjte001 instanceof ParseException) {
                                   {if (true) throw (ParseException)jjte001;}
                                 }
                                 {if (true) throw (Error)jjte001;}
        } finally {
                                 if (jjtc001) {
                                   jjtree.closeNodeScope(jjtn001,  2);
                                 }
        }
        break;
      case NE0:
      case NE1:
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case NE0:
          jj_consume_token(NE0);
          break;
        case NE1:
          jj_consume_token(NE1);
          break;
        default:
          jj_la1[9] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
                                 AstNotEqual jjtn002 = new AstNotEqual(JJTNOTEQUAL);
                                 boolean jjtc002 = true;
                                 jjtree.openNodeScope(jjtn002);
        try {
          Compare();
        } catch (Throwable jjte002) {
                                 if (jjtc002) {
                                   jjtree.clearNodeScope(jjtn002);
                                   jjtc002 = false;
                                 } else {
                                   jjtree.popNode();
                                 }
                                 if (jjte002 instanceof RuntimeException) {
                                   {if (true) throw (RuntimeException)jjte002;}
                                 }
                                 if (jjte002 instanceof ParseException) {
                                   {if (true) throw (ParseException)jjte002;}
                                 }
                                 {if (true) throw (Error)jjte002;}
        } finally {
                                 if (jjtc002) {
                                   jjtree.closeNodeScope(jjtn002,  2);
                                 }
        }
        break;
      default:
        jj_la1[10] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    }
  }

/*
 * Compare
 * For a bunch of them, then Math
 */
  final public void Compare() throws ParseException {
    Math();
    label_6:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case GT0:
      case GT1:
      case LT0:
      case LT1:
      case GE0:
      case GE1:
      case LE0:
      case LE1:
        ;
        break;
      default:
        jj_la1[11] = jj_gen;
        break label_6;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case LT0:
      case LT1:
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case LT0:
          jj_consume_token(LT0);
          break;
        case LT1:

⌨️ 快捷键说明

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