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

📄 pythongrammar.java

📁 无线通信的主要编程软件,是无线通信工作人员的必备工具,关天相关教程我会在后续传上.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* Generated By:JJTree&JavaCC: Do not edit this line. PythonGrammar.java */package org.python.parser;import org.python.parser.ast.modType;public class PythonGrammar/*@bgen(jjtree)*/implements PythonGrammarTreeConstants, PythonGrammarConstants {/*@bgen(jjtree)*/  protected JJTPythonGrammarState jjtree = new JJTPythonGrammarState();public IParserHost hostLiteralMkr;    void jjtreeOpenNodeScope(Node n) {        Token t = getToken(1);        jjtree.pushNodePos(t.beginLine, t.beginColumn);    }    void jjtreeCloseNodeScope(Node n) {        jjtree.setNodePos();    }    Object makeInt(String s, int radix) {        if (s.endsWith("L") || s.endsWith("l")) {            s = s.substring(0, s.length()-1);            return hostLiteralMkr.newLong(new java.math.BigInteger(s, radix));        }        int ndigits = s.length();        int i=0;        while (i < ndigits && s.charAt(i) == '0')            i++;        if ((ndigits - i) > 11) {            return hostLiteralMkr.newLong(new java.math.BigInteger(s, radix));        }        long l = Long.valueOf(s, radix).longValue();        if (l > 0xffffffffl || (radix == 10 && l > Integer.MAX_VALUE)) {            return hostLiteralMkr.newLong(new java.math.BigInteger(s, radix));        }        return hostLiteralMkr.newInteger((int) l);    }    Object makeFloat(String s) {        return hostLiteralMkr.newFloat(Double.valueOf(s).doubleValue());    }    Object makeLong(String s) {        return hostLiteralMkr.newLong(s);    }    Object makeComplex(String s) {        s = s.substring(0, s.length() - 1);        return hostLiteralMkr.newImaginary(Double.valueOf(s).doubleValue());    }    String makeString(String s, int quotes) {        //System.out.println("string: "+s);        char quoteChar = s.charAt(0);        int start=0;        boolean ustring = false;        if (quoteChar == 'u' || quoteChar == 'U') {            ustring = true;            start++;        }        quoteChar = s.charAt(start);        if (quoteChar == 'r' || quoteChar == 'R') {            return s.substring(quotes+start+1, s.length()-quotes);        } else {            StringBuffer sb = new StringBuffer(s.length());            char[] ca = s.toCharArray();            int n = ca.length-quotes;            int i=quotes+start;            int last_i=i;            return hostLiteralMkr.decode_UnicodeEscape(s, i, n, "strict", ustring);        }    }    // ! maximal currently used LOOKAHEAD is 3        private static final int MAX_LOOKAHEAD = 3;    public boolean partial_valid_sentence(Throwable t) {        if (t instanceof TokenMgrError) {           // check whether EOF condition inside multi-line string,           // or just after newline continuation inside a string (*NLC states)           TokenMgrError e = (TokenMgrError)t;           switch(e.lexState) {           case IN_STRING1NLC:           case IN_STRING2NLC:           case IN_STRING13:           case IN_STRING23:               return e.EOFSeen;           default:               return false;           }        }        if (!(t instanceof ParseException))            return false;        try {            ParseException e = (ParseException)t;            int tok = getNextToken().kind;            if (tok == EOF) return true; // all tokens eaten            // or check whether remaing tokens partially fullfill lookahead            // expectations            int[][] expected = e.expectedTokenSequences;            if (expected == null) return false;            int[] ahead = new int[MAX_LOOKAHEAD-1];            int i = 0;            for(;;) {                ahead[i] = tok;                i++;                tok = getNextToken().kind;                if (tok == EOF) break;                if (i >= MAX_LOOKAHEAD-1) return false;            }            int nahead = i;        next_expected:            for(int j = 0; j<expected.length; j++) {                int[] cand = expected[j];                if (cand.length <= nahead ) continue next_expected;                for(int k = 0; k < nahead; k++)                    if (ahead[k] != cand[k])                        continue next_expected;                return true;            }            return false;        } catch (TokenMgrError e1) {            return false;        }    }        // constructors taking a IParserHost impl        public PythonGrammar(CharStream stream,IParserHost host) {            this(stream);            hostLiteralMkr = host;        }        public PythonGrammar(PythonGrammarTokenManager tm,                             IParserHost host)    {        this(tm);        hostLiteralMkr = host;        }//single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE // apparently CPython coalesces newlines, we don't  final public modType single_input() throws ParseException {                         /*@bgen(jjtree) single_input */    SimpleNode jjtn000 = (SimpleNode)SimpleNode.jjtCreate(this, JJTSINGLE_INPUT);    boolean jjtc000 = true;    jjtree.openNodeScope(jjtn000);    jjtreeOpenNodeScope(jjtn000);token_source.single_input=true;    try {      label_1:      while (true) {        if (jj_2_1(2)) {          ;        } else {          break label_1;        }        jj_consume_token(NEWLINE);      }      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case LPAREN:      case LBRACE:      case LBRACKET:      case PLUS:      case MINUS:      case NOT:      case NOT_BOOL:      case LAMBDA:      case IF:      case WHILE:      case FOR:      case TRY:      case DEF:      case CLASS:      case PRINT:      case PASS:      case BREAK:      case CONTINUE:      case RETURN:      case YIELD:      case IMPORT:      case FROM:      case DEL:      case RAISE:      case GLOBAL:      case EXEC:      case ASSERT:      case AS:      case NAME:      case DECNUMBER:      case HEXNUMBER:      case OCTNUMBER:      case FLOAT:      case COMPLEX:      case SINGLE_STRING:      case SINGLE_STRING2:      case TRIPLE_STRING:      case TRIPLE_STRING2:      case 121:        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {        case LPAREN:        case LBRACE:        case LBRACKET:        case PLUS:        case MINUS:        case NOT:        case NOT_BOOL:        case LAMBDA:        case PRINT:        case PASS:        case BREAK:        case CONTINUE:        case RETURN:        case YIELD:        case IMPORT:        case FROM:        case DEL:        case RAISE:        case GLOBAL:        case EXEC:        case ASSERT:        case AS:        case NAME:        case DECNUMBER:        case HEXNUMBER:        case OCTNUMBER:        case FLOAT:        case COMPLEX:        case SINGLE_STRING:        case SINGLE_STRING2:        case TRIPLE_STRING:        case TRIPLE_STRING2:        case 121:          simple_stmt();          break;        case IF:        case WHILE:        case FOR:        case TRY:        case DEF:        case CLASS:          compound_stmt();          jj_consume_token(NEWLINE);          break;        default:          jj_la1[0] = jj_gen;          jj_consume_token(-1);          throw new ParseException();        }        break;      default:        jj_la1[1] = jj_gen;        ;      }      label_2:      while (true) {        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {        case NEWLINE:          ;          break;        default:          jj_la1[2] = jj_gen;          break label_2;        }        jj_consume_token(NEWLINE);      }      jj_consume_token(0);      jjtree.closeNodeScope(jjtn000, true);      jjtc000 = false;      jjtreeCloseNodeScope(jjtn000);      {if (true) return (modType) jjtree.popNode();}    } 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);        jjtreeCloseNodeScope(jjtn000);      }    }    throw new Error("Missing return statement in function");  }//file_input: (NEWLINE | stmt)* ENDMARKER  final public modType file_input() throws ParseException {                       /*@bgen(jjtree) file_input */                       SimpleNode jjtn000 = (SimpleNode)SimpleNode.jjtCreate(this, JJTFILE_INPUT);                       boolean jjtc000 = true;                       jjtree.openNodeScope(jjtn000);                       jjtreeOpenNodeScope(jjtn000);token_source.single_input=false;    try {      label_3:      while (true) {        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {        case NEWLINE:        case LPAREN:        case LBRACE:        case LBRACKET:        case PLUS:        case MINUS:        case NOT:        case NOT_BOOL:        case LAMBDA:        case IF:        case WHILE:        case FOR:        case TRY:        case DEF:        case CLASS:        case PRINT:        case PASS:        case BREAK:        case CONTINUE:        case RETURN:        case YIELD:        case IMPORT:        case FROM:        case DEL:        case RAISE:        case GLOBAL:        case EXEC:        case ASSERT:        case AS:        case NAME:        case DECNUMBER:        case HEXNUMBER:        case OCTNUMBER:        case FLOAT:        case COMPLEX:        case SINGLE_STRING:        case SINGLE_STRING2:        case TRIPLE_STRING:        case TRIPLE_STRING2:        case 121:          ;          break;        default:          jj_la1[3] = jj_gen;          break label_3;        }        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {        case NEWLINE:          jj_consume_token(NEWLINE);          break;        case LPAREN:        case LBRACE:        case LBRACKET:        case PLUS:        case MINUS:        case NOT:        case NOT_BOOL:        case LAMBDA:        case IF:        case WHILE:        case FOR:        case TRY:        case DEF:        case CLASS:        case PRINT:        case PASS:        case BREAK:        case CONTINUE:        case RETURN:        case YIELD:        case IMPORT:        case FROM:        case DEL:        case RAISE:        case GLOBAL:        case EXEC:        case ASSERT:        case AS:        case NAME:        case DECNUMBER:        case HEXNUMBER:        case OCTNUMBER:        case FLOAT:        case COMPLEX:        case SINGLE_STRING:        case SINGLE_STRING2:        case TRIPLE_STRING:        case TRIPLE_STRING2:        case 121:          stmt();          break;        default:          jj_la1[4] = jj_gen;          jj_consume_token(-1);          throw new ParseException();        }      }      jj_consume_token(0);      jjtree.closeNodeScope(jjtn000, true);      jjtc000 = false;      jjtreeCloseNodeScope(jjtn000);      {if (true) return (modType) jjtree.popNode();}    } 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);        jjtreeCloseNodeScope(jjtn000);      }    }    throw new Error("Missing return statement in function");  }//eval_input: NEWLINE* testlist NEWLINE* ENDMARKER  final public modType eval_input() throws ParseException {                       /*@bgen(jjtree) eval_input */                       SimpleNode jjtn000 = (SimpleNode)SimpleNode.jjtCreate(this, JJTEVAL_INPUT);                       boolean jjtc000 = true;                       jjtree.openNodeScope(jjtn000);                       jjtreeOpenNodeScope(jjtn000);token_source.single_input=false;    try {      label_4:      while (true) {        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {        case NEWLINE:          ;          break;        default:          jj_la1[5] = jj_gen;          break label_4;        }        jj_consume_token(NEWLINE);      }      SmartTestList();      label_5:      while (true) {        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {        case NEWLINE:          ;

⌨️ 快捷键说明

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