📄 xpathlexer.java
字号:
/* * Copyright 2001-2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *//* * $Id: xpath.lex,v 1.12 2005/08/02 02:59:03 mcnamara Exp $ *//* * @author Jacek Ambroziak * @author Santiago Pericas-Geertsen * @author Morten Jorgensen * */package com.sun.org.apache.xalan.internal.xsltc.compiler;import com.sun.java_cup.internal.runtime.Symbol;class XPathLexer implements com.sun.java_cup.internal.runtime.Scanner { private final int YY_BUFFER_SIZE = 512; private final int YY_F = -1; private final int YY_NO_STATE = -1; private final int YY_NOT_ACCEPT = 0; private final int YY_START = 1; private final int YY_END = 2; private final int YY_NO_ANCHOR = 4; private final int YY_BOL = 65536; private final int YY_EOF = 65537; public final int YYEOF = -1; int last; void initialize() { last = -1; } static boolean isWhitespace(int c) { return (c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f'); } /** * If symbol is not followed by '::' or '(', then treat it as a * name instead of an axis or function (Jira-1912). */ Symbol disambiguateAxisOrFunction(int ss) throws Exception { // Peek in the input buffer without changing the internal state int index = yy_buffer_index; // Skip whitespace while (index < yy_buffer_read && isWhitespace(yy_buffer[index])) { index++; } // If end of buffer, can't disambiguate :( if (index >= yy_buffer_read) { // Can't disambiguate, so return as symbol return new Symbol(ss); } // Return symbol if next token is '::' or '(' return (yy_buffer[index] == ':' && yy_buffer[index+1] == ':' || yy_buffer[index] == '(') ? newSymbol(ss) : newSymbol(sym.QNAME, yytext()); } /** * If symbol is first token or if it follows any of the operators * listed in http://www.w3.org/TR/xpath#exprlex then treat as a * name instead of a keyword (Jira-1912). */ Symbol disambiguateOperator(int ss) throws Exception { switch (last) { case -1: // first token case sym.ATSIGN: case sym.DCOLON: case sym.LPAREN: case sym.LBRACK: case sym.COMMA: case sym.AND: case sym.OR: case sym.MOD: case sym.DIV: case sym.STAR: case sym.SLASH: case sym.DSLASH: case sym.VBAR: case sym.PLUS: case sym.MINUS: case sym.EQ: case sym.NE: case sym.LT: case sym.LE: case sym.GT: case sym.GE: return newSymbol(sym.QNAME, yytext()); } return newSymbol(ss); } Symbol newSymbol(int ss) { last = ss; return new Symbol(ss); } Symbol newSymbol(int ss, String value) { last = ss; return new Symbol(ss, value); } Symbol newSymbol(int ss, Long value) { last = ss; return new Symbol(ss, value); } Symbol newSymbol(int ss, Double value) { last = ss; return new Symbol(ss, value); } private java.io.BufferedReader yy_reader; private int yy_buffer_index; private int yy_buffer_read; private int yy_buffer_start; private int yy_buffer_end; private char yy_buffer[]; private boolean yy_at_bol; private int yy_lexical_state; XPathLexer (java.io.Reader reader) { this (); if (null == reader) { throw (new Error("Error: Bad input stream initializer.")); } yy_reader = new java.io.BufferedReader(reader); } XPathLexer (java.io.InputStream instream) { this (); if (null == instream) { throw (new Error("Error: Bad input stream initializer.")); } yy_reader = new java.io.BufferedReader(new java.io.InputStreamReader(instream)); } private XPathLexer () { yy_buffer = new char[YY_BUFFER_SIZE]; yy_buffer_read = 0; yy_buffer_index = 0; yy_buffer_start = 0; yy_buffer_end = 0; yy_at_bol = true; yy_lexical_state = YYINITIAL; } private boolean yy_eof_done = false; private final int YYINITIAL = 0; private final int yy_state_dtrans[] = { 0 }; private void yybegin (int state) { yy_lexical_state = state; } private int yy_advance () throws java.io.IOException { int next_read; int i; int j; if (yy_buffer_index < yy_buffer_read) { return yy_buffer[yy_buffer_index++]; } if (0 != yy_buffer_start) { i = yy_buffer_start; j = 0; while (i < yy_buffer_read) { yy_buffer[j] = yy_buffer[i]; ++i; ++j; } yy_buffer_end = yy_buffer_end - yy_buffer_start; yy_buffer_start = 0; yy_buffer_read = j; yy_buffer_index = j; next_read = yy_reader.read(yy_buffer, yy_buffer_read, yy_buffer.length - yy_buffer_read); if (-1 == next_read) { return YY_EOF; } yy_buffer_read = yy_buffer_read + next_read; } while (yy_buffer_index >= yy_buffer_read) { if (yy_buffer_index >= yy_buffer.length) { yy_buffer = yy_double(yy_buffer); } next_read = yy_reader.read(yy_buffer, yy_buffer_read, yy_buffer.length - yy_buffer_read); if (-1 == next_read) { return YY_EOF; } yy_buffer_read = yy_buffer_read + next_read; } return yy_buffer[yy_buffer_index++]; } private void yy_move_end () { if (yy_buffer_end > yy_buffer_start && '\n' == yy_buffer[yy_buffer_end-1]) yy_buffer_end--; if (yy_buffer_end > yy_buffer_start && '\r' == yy_buffer[yy_buffer_end-1]) yy_buffer_end--; } private boolean yy_last_was_cr=false; private void yy_mark_start () { yy_buffer_start = yy_buffer_index; } private void yy_mark_end () { yy_buffer_end = yy_buffer_index; } private void yy_to_mark () { yy_buffer_index = yy_buffer_end; yy_at_bol = (yy_buffer_end > yy_buffer_start) && ('\r' == yy_buffer[yy_buffer_end-1] || '\n' == yy_buffer[yy_buffer_end-1] || 2028/*LS*/ == yy_buffer[yy_buffer_end-1] || 2029/*PS*/ == yy_buffer[yy_buffer_end-1]); } private java.lang.String yytext () { return (new java.lang.String(yy_buffer, yy_buffer_start, yy_buffer_end - yy_buffer_start)); } private int yylength () { return yy_buffer_end - yy_buffer_start; } private char[] yy_double (char buf[]) { int i; char newbuf[]; newbuf = new char[2*buf.length]; for (i = 0; i < buf.length; ++i) { newbuf[i] = buf[i]; } return newbuf; } private final int YY_E_INTERNAL = 0; private final int YY_E_MATCH = 1; private java.lang.String yy_error_string[] = { "Error: Internal error.\n", "Error: Unmatched input.\n" }; private void yy_error (int code,boolean fatal) { java.lang.System.out.print(yy_error_string[code]); java.lang.System.out.flush(); if (fatal) { throw new Error("Fatal Error.\n"); } } static private int[][] unpackFromString(int size1, int size2, String st) { int colonIndex = -1; String lengthString; int sequenceLength = 0; int sequenceInteger = 0; int commaIndex; String workString; int res[][] = new int[size1][size2]; for (int i= 0; i < size1; i++) { for (int j= 0; j < size2; j++) { if (sequenceLength != 0) { res[i][j] = sequenceInteger; sequenceLength--; continue; } commaIndex = st.indexOf(','); workString = (commaIndex==-1) ? st : st.substring(0, commaIndex); st = st.substring(commaIndex+1); colonIndex = workString.indexOf(':'); if (colonIndex == -1) { res[i][j]=Integer.parseInt(workString); continue; } lengthString = workString.substring(colonIndex+1); sequenceLength=Integer.parseInt(lengthString); workString=workString.substring(0,colonIndex); sequenceInteger=Integer.parseInt(workString); res[i][j] = sequenceInteger; sequenceLength--; } } return res; } private int yy_acpt[] = { /* 0 */ YY_NOT_ACCEPT, /* 1 */ YY_NO_ANCHOR, /* 2 */ YY_NO_ANCHOR, /* 3 */ YY_NO_ANCHOR, /* 4 */ YY_NO_ANCHOR, /* 5 */ YY_NO_ANCHOR, /* 6 */ YY_NO_ANCHOR, /* 7 */ YY_NO_ANCHOR, /* 8 */ YY_NO_ANCHOR, /* 9 */ YY_NO_ANCHOR, /* 10 */ YY_NO_ANCHOR, /* 11 */ YY_NO_ANCHOR, /* 12 */ YY_NO_ANCHOR, /* 13 */ YY_NO_ANCHOR, /* 14 */ YY_NO_ANCHOR, /* 15 */ YY_NO_ANCHOR, /* 16 */ YY_NO_ANCHOR, /* 17 */ YY_NO_ANCHOR, /* 18 */ YY_NO_ANCHOR, /* 19 */ YY_NO_ANCHOR, /* 20 */ YY_NO_ANCHOR, /* 21 */ YY_NO_ANCHOR, /* 22 */ YY_NO_ANCHOR, /* 23 */ YY_NO_ANCHOR, /* 24 */ YY_NO_ANCHOR, /* 25 */ YY_NO_ANCHOR, /* 26 */ YY_NO_ANCHOR, /* 27 */ YY_NO_ANCHOR, /* 28 */ YY_NO_ANCHOR, /* 29 */ YY_NO_ANCHOR, /* 30 */ YY_NO_ANCHOR, /* 31 */ YY_NO_ANCHOR, /* 32 */ YY_NO_ANCHOR, /* 33 */ YY_NO_ANCHOR, /* 34 */ YY_NO_ANCHOR, /* 35 */ YY_NO_ANCHOR, /* 36 */ YY_NO_ANCHOR, /* 37 */ YY_NO_ANCHOR, /* 38 */ YY_NO_ANCHOR, /* 39 */ YY_NO_ANCHOR, /* 40 */ YY_NO_ANCHOR, /* 41 */ YY_NO_ANCHOR, /* 42 */ YY_NO_ANCHOR, /* 43 */ YY_NO_ANCHOR, /* 44 */ YY_NO_ANCHOR, /* 45 */ YY_NO_ANCHOR, /* 46 */ YY_NO_ANCHOR, /* 47 */ YY_NO_ANCHOR, /* 48 */ YY_NO_ANCHOR, /* 49 */ YY_NO_ANCHOR, /* 50 */ YY_NO_ANCHOR, /* 51 */ YY_NO_ANCHOR, /* 52 */ YY_NO_ANCHOR, /* 53 */ YY_NO_ANCHOR, /* 54 */ YY_NO_ANCHOR, /* 55 */ YY_NO_ANCHOR, /* 56 */ YY_NO_ANCHOR, /* 57 */ YY_NO_ANCHOR, /* 58 */ YY_NO_ANCHOR, /* 59 */ YY_NO_ANCHOR, /* 60 */ YY_NO_ANCHOR, /* 61 */ YY_NO_ANCHOR, /* 62 */ YY_NO_ANCHOR, /* 63 */ YY_NO_ANCHOR, /* 64 */ YY_NOT_ACCEPT, /* 65 */ YY_NO_ANCHOR, /* 66 */ YY_NO_ANCHOR, /* 67 */ YY_NO_ANCHOR, /* 68 */ YY_NO_ANCHOR, /* 69 */ YY_NOT_ACCEPT, /* 70 */ YY_NO_ANCHOR, /* 71 */ YY_NO_ANCHOR, /* 72 */ YY_NOT_ACCEPT, /* 73 */ YY_NO_ANCHOR, /* 74 */ YY_NO_ANCHOR, /* 75 */ YY_NOT_ACCEPT, /* 76 */ YY_NO_ANCHOR, /* 77 */ YY_NO_ANCHOR, /* 78 */ YY_NOT_ACCEPT, /* 79 */ YY_NO_ANCHOR, /* 80 */ YY_NOT_ACCEPT, /* 81 */ YY_NO_ANCHOR, /* 82 */ YY_NOT_ACCEPT, /* 83 */ YY_NO_ANCHOR, /* 84 */ YY_NOT_ACCEPT, /* 85 */ YY_NO_ANCHOR, /* 86 */ YY_NOT_ACCEPT, /* 87 */ YY_NO_ANCHOR, /* 88 */ YY_NOT_ACCEPT, /* 89 */ YY_NO_ANCHOR, /* 90 */ YY_NOT_ACCEPT, /* 91 */ YY_NO_ANCHOR, /* 92 */ YY_NOT_ACCEPT, /* 93 */ YY_NO_ANCHOR, /* 94 */ YY_NOT_ACCEPT, /* 95 */ YY_NO_ANCHOR, /* 96 */ YY_NOT_ACCEPT, /* 97 */ YY_NO_ANCHOR, /* 98 */ YY_NOT_ACCEPT, /* 99 */ YY_NO_ANCHOR, /* 100 */ YY_NOT_ACCEPT, /* 101 */ YY_NO_ANCHOR, /* 102 */ YY_NOT_ACCEPT, /* 103 */ YY_NO_ANCHOR, /* 104 */ YY_NOT_ACCEPT, /* 105 */ YY_NO_ANCHOR, /* 106 */ YY_NOT_ACCEPT,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -