diff --git a/designer-base/src/main/java/com/fr/design/formula/FRFormulaLexer.java b/designer-base/src/main/java/com/fr/design/formula/FRFormulaLexer.java new file mode 100644 index 0000000000..23c15d98ac --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/formula/FRFormulaLexer.java @@ -0,0 +1,1689 @@ +package com.fr.design.formula; + +import com.fr.parser.FRParserTokenTypes; +import com.fr.third.antlr.ByteBuffer; +import com.fr.third.antlr.CharBuffer; +import com.fr.third.antlr.CharStreamException; +import com.fr.third.antlr.CharStreamIOException; +import com.fr.third.antlr.InputBuffer; +import com.fr.third.antlr.LexerSharedInputState; +import com.fr.third.antlr.NoViableAltForCharException; +import com.fr.third.antlr.RecognitionException; +import com.fr.third.antlr.Token; +import com.fr.third.antlr.TokenStream; +import com.fr.third.antlr.TokenStreamException; +import com.fr.third.antlr.TokenStreamIOException; +import com.fr.third.antlr.TokenStreamRecognitionException; +import com.fr.third.antlr.collections.impl.BitSet; + +import java.io.InputStream; +import java.io.Reader; +import java.util.Hashtable; + +/** + * @author Hoky + * @date 2021/11/22 + */ + +public class FRFormulaLexer extends com.fr.third.antlr.CharScanner implements FRParserTokenTypes, TokenStream { + public FRFormulaLexer(InputStream in) { + this(new ByteBuffer(in)); + } + + public FRFormulaLexer(Reader in) { + this(new CharBuffer(in)); + } + + public FRFormulaLexer(InputBuffer ib) { + this(new LexerSharedInputState(ib)); + } + + public FRFormulaLexer(LexerSharedInputState state) { + super(state); + caseSensitiveLiterals = true; + setCaseSensitive(true); + literals = new Hashtable(); + } + + public Token nextToken() throws TokenStreamException { + Token theRetToken = null; + tryAgain: + for (; ; ) { + Token _token = null; + int _ttype = Token.INVALID_TYPE; + resetText(); + try { // for char stream error handling + try { // for lexical error handling + switch (LA(1)) { + case '?': { + mQUESTION(true); + theRetToken = _returnToken; + break; + } + case '(': { + mLPAREN(true); + theRetToken = _returnToken; + break; + } + case ')': { + mRPAREN(true); + theRetToken = _returnToken; + break; + } + case '[': { + mLBRACK(true); + theRetToken = _returnToken; + break; + } + case ']': { + mRBRACK(true); + theRetToken = _returnToken; + break; + } + case '{': { + mLCURLY(true); + theRetToken = _returnToken; + break; + } + case '}': { + mRCURLY(true); + theRetToken = _returnToken; + break; + } + case ',': { + mCOMMA(true); + theRetToken = _returnToken; + break; + } + case '/': { + mDIV(true); + theRetToken = _returnToken; + break; + } + case '+': { + mPLUS(true); + theRetToken = _returnToken; + break; + } + case '-': { + mMINUS(true); + theRetToken = _returnToken; + break; + } + case '*': { + mSTAR(true); + theRetToken = _returnToken; + break; + } + case '%': { + mMOD(true); + theRetToken = _returnToken; + break; + } + case '^': { + mPOWER(true); + theRetToken = _returnToken; + break; + } + case ';': { + mSEMI(true); + theRetToken = _returnToken; + break; + } + case '#': { + mSHARP(true); + theRetToken = _returnToken; + break; + } + case '@': { + mAT(true); + theRetToken = _returnToken; + break; + } + case '~': { + mWAVE(true); + theRetToken = _returnToken; + break; + } + case '`': { + mALLL2(true); + theRetToken = _returnToken; + break; + } + case '.': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': { + mINT_NUM(true); + theRetToken = _returnToken; + break; + } + case '"': { + mSTRING_LITERAL_DSQ(true); + theRetToken = _returnToken; + break; + } + case '\'': { + mSTRING_LITERAL_SSQ(true); + theRetToken = _returnToken; + break; + } + case '\t': + case '\n': + case '\u000c': + case '\r': + case ' ': { + mWS(true); + theRetToken = _returnToken; + break; + } + default: + if ((LA(1) == ':') && (LA(2) == ':')) { + mDCOLON(true); + theRetToken = _returnToken; + } else if ((LA(1) == '=') && (LA(2) == '=')) { + mEQUAL(true); + theRetToken = _returnToken; + } else if ((LA(1) == '!') && (LA(2) == '=')) { + mNOT_EQUAL(true); + theRetToken = _returnToken; + } else if ((LA(1) == '<') && (LA(2) == '>')) { + mNOT_EQUAL2(true); + theRetToken = _returnToken; + } else if ((LA(1) == '>') && (LA(2) == '=')) { + mGE(true); + theRetToken = _returnToken; + } else if ((LA(1) == '<') && (LA(2) == '=')) { + mLE(true); + theRetToken = _returnToken; + } else if ((LA(1) == '|') && (LA(2) == '|')) { + mLOR(true); + theRetToken = _returnToken; + } else if ((LA(1) == '&') && (LA(2) == '&')) { + mLAND(true); + theRetToken = _returnToken; + } else if ((LA(1) == '!') && (LA(2) == '0')) { + mALLL(true); + theRetToken = _returnToken; + } else if ((LA(1) == '&') && (_tokenSet_0.member(LA(2)))) { + mCR_ADRESS(true); + theRetToken = _returnToken; + } else if ((LA(1) == ':') && (true)) { + mCOLON(true); + theRetToken = _returnToken; + } else if ((LA(1) == '=') && (true)) { + mEQUAL2(true); + theRetToken = _returnToken; + } else if ((LA(1) == '!') && (true)) { + mLNOT(true); + theRetToken = _returnToken; + } else if ((LA(1) == '>') && (true)) { + mGT(true); + theRetToken = _returnToken; + } else if ((LA(1) == '<') && (true)) { + mLT(true); + theRetToken = _returnToken; + } else if ((LA(1) == '|') && (true)) { + mBOR(true); + theRetToken = _returnToken; + } else if ((LA(1) == '&') && (true)) { + mBAND(true); + theRetToken = _returnToken; + } else if ((_tokenSet_1.member(LA(1)))) { + mIDENT(true); + theRetToken = _returnToken; + } else { + if (LA(1) == EOF_CHAR) { + uponEOF(); + _returnToken = makeToken(Token.EOF_TYPE); + } else { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + } + } + if (_returnToken == null) continue tryAgain; // found SKIP token + _ttype = _returnToken.getType(); + _ttype = testLiteralsTable(_ttype); + _returnToken.setType(_ttype); + return _returnToken; + } catch (RecognitionException e) { + throw new TokenStreamRecognitionException(e); + } + } catch (CharStreamException cse) { + if (cse instanceof CharStreamIOException) { + throw new TokenStreamIOException(((CharStreamIOException) cse).io); + } else { + throw new TokenStreamException(cse.getMessage()); + } + } + } + } + + public final void mQUESTION(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = QUESTION; + int _saveIndex; + + match('?'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mLPAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = LPAREN; + int _saveIndex; + + match('('); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mRPAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = RPAREN; + int _saveIndex; + + match(')'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mLBRACK(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = LBRACK; + int _saveIndex; + + match('['); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mRBRACK(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = RBRACK; + int _saveIndex; + + match(']'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mLCURLY(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = LCURLY; + int _saveIndex; + + match('{'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mRCURLY(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = RCURLY; + int _saveIndex; + + match('}'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mCOLON(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = COLON; + int _saveIndex; + + match(':'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mDCOLON(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = DCOLON; + int _saveIndex; + + match("::"); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mCOMMA(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = COMMA; + int _saveIndex; + + match(','); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mEQUAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = EQUAL; + int _saveIndex; + + match("=="); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mEQUAL2(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = EQUAL2; + int _saveIndex; + + match('='); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mLNOT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = LNOT; + int _saveIndex; + + match('!'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mNOT_EQUAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = NOT_EQUAL; + int _saveIndex; + + match("!="); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mNOT_EQUAL2(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = NOT_EQUAL2; + int _saveIndex; + + match("<>"); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mDIV(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = DIV; + int _saveIndex; + + match('/'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mPLUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = PLUS; + int _saveIndex; + + match('+'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mMINUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = MINUS; + int _saveIndex; + + match('-'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mSTAR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = STAR; + int _saveIndex; + + match('*'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mMOD(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = MOD; + int _saveIndex; + + match('%'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mPOWER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = POWER; + int _saveIndex; + + match('^'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mGE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = GE; + int _saveIndex; + + match(">="); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mGT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = GT; + int _saveIndex; + + match('>'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mLE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = LE; + int _saveIndex; + + match("<="); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mLT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = LT; + int _saveIndex; + + match('<'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mBOR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = BOR; + int _saveIndex; + + match('|'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mBAND(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = BAND; + int _saveIndex; + + match('&'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mLOR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = LOR; + int _saveIndex; + + match("||"); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mLAND(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = LAND; + int _saveIndex; + + match("&&"); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mSEMI(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = SEMI; + int _saveIndex; + + match(';'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mSHARP(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = SHARP; + int _saveIndex; + + match('#'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mAT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = AT; + int _saveIndex; + + match('@'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mWAVE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = WAVE; + int _saveIndex; + + match('~'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mALLL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = ALLL; + int _saveIndex; + + match('!'); + match('0'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mALLL2(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = ALLL2; + int _saveIndex; + + match('`'); + match('0'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mIDENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = IDENT; + int _saveIndex; + + mChar(false); + { + _loop109: + do { + if ((_tokenSet_1.member(LA(1)))) { + mChar(false); + } else if (((LA(1) >= '0' && LA(1) <= '9'))) { + { + mDIGIT(false); + } + } else { + break _loop109; + } + + } while (true); + } + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + /** + * 'a'..'z', '_', 'A'..'Z' and others without number + */ + protected final void mChar(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = Char; + int _saveIndex; + + switch (LA(1)) { + case '$': { + match('\u0024'); + break; + } + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': { + matchRange('\u0041', '\u005a'); + break; + } + case '_': { + match('\u005f'); + break; + } + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': { + matchRange('\u0061', '\u007a'); + break; + } + case '\u00c0': + case '\u00c1': + case '\u00c2': + case '\u00c3': + case '\u00c4': + case '\u00c5': + case '\u00c6': + case '\u00c7': + case '\u00c8': + case '\u00c9': + case '\u00ca': + case '\u00cb': + case '\u00cc': + case '\u00cd': + case '\u00ce': + case '\u00cf': + case '\u00d0': + case '\u00d1': + case '\u00d2': + case '\u00d3': + case '\u00d4': + case '\u00d5': + case '\u00d6': { + matchRange('\u00c0', '\u00d6'); + break; + } + case '\u00d8': + case '\u00d9': + case '\u00da': + case '\u00db': + case '\u00dc': + case '\u00dd': + case '\u00de': + case '\u00df': + case '\u00e0': + case '\u00e1': + case '\u00e2': + case '\u00e3': + case '\u00e4': + case '\u00e5': + case '\u00e6': + case '\u00e7': + case '\u00e8': + case '\u00e9': + case '\u00ea': + case '\u00eb': + case '\u00ec': + case '\u00ed': + case '\u00ee': + case '\u00ef': + case '\u00f0': + case '\u00f1': + case '\u00f2': + case '\u00f3': + case '\u00f4': + case '\u00f5': + case '\u00f6': { + matchRange('\u00d8', '\u00f6'); + break; + } + case '\u00f8': + case '\u00f9': + case '\u00fa': + case '\u00fb': + case '\u00fc': + case '\u00fd': + case '\u00fe': + case '\u00ff': { + matchRange('\u00f8', '\u00ff'); + break; + } + default: + if (((LA(1) >= '\u0100' && LA(1) <= '\u1fff'))) { + matchRange('\u0100', '\u1fff'); + } else if (((LA(1) >= '\u3040' && LA(1) <= '\u318f'))) { + matchRange('\u3040', '\u318f'); + } else if (((LA(1) >= '\u3300' && LA(1) <= '\u337f'))) { + matchRange('\u3300', '\u337f'); + } else if (((LA(1) >= '\u3400' && LA(1) <= '\u3d2d'))) { + matchRange('\u3400', '\u3d2d'); + } else if (((LA(1) >= '\u4e00' && LA(1) <= '\u9fff'))) { + matchRange('\u4e00', '\u9fff'); + } else if (((LA(1) >= '\uf900' && LA(1) <= '\ufaff'))) { + matchRange('\uf900', '\ufaff'); + } else if (((LA(1) >= '\uac00' && LA(1) <= '\ud7af'))) { + matchRange('\uac00', '\ud7af'); + } else { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + } + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + protected final void mDIGIT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = DIGIT; + int _saveIndex; + + matchRange('0', '9'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mCR_ADRESS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = CR_ADRESS; + int _saveIndex; + + mBAND(false); + { + int _cnt112 = 0; + _loop112: + do { + if ((_tokenSet_0.member(LA(1)))) { + mLETTER(false); + } else { + if (_cnt112 >= 1) { + break _loop112; + } else { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + } + + _cnt112++; + } while (true); + } + { + int _cnt114 = 0; + _loop114: + do { + if (((LA(1) >= '0' && LA(1) <= '9'))) { + mDIGIT(false); + } else { + if (_cnt114 >= 1) { + break _loop114; + } else { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + } + + _cnt114++; + } while (true); + } + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + protected final void mLETTER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = LETTER; + int _saveIndex; + + switch (LA(1)) { + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': { + matchRange('A', 'Z'); + break; + } + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': { + matchRange('a', 'z'); + break; + } + default: { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + } + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mINT_NUM(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = INT_NUM; + int _saveIndex; + + switch (LA(1)) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': { + { + int _cnt117 = 0; + _loop117: + do { + if (((LA(1) >= '0' && LA(1) <= '9'))) { + mDIGIT(false); + } else { + if (_cnt117 >= 1) { + break _loop117; + } else { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + } + + _cnt117++; + } while (true); + } + { + if ((LA(1) == '.')) { + match('.'); + { + _loop120: + do { + if (((LA(1) >= '0' && LA(1) <= '9'))) { + mDIGIT(false); + } else { + break _loop120; + } + + } while (true); + } + _ttype = FLOT_NUM; + } else { + } + + } + { + if ((LA(1) == 'E' || LA(1) == 'e')) { + mExponent(false); + _ttype = FLOT_NUM; + } else { + } + + } + + //System.out.println("number like 1.2e+12"); + + break; + } + case '.': { + match('.'); + _ttype = DOT; + { + if (((LA(1) >= '0' && LA(1) <= '9'))) { + { + int _cnt124 = 0; + _loop124: + do { + if (((LA(1) >= '0' && LA(1) <= '9'))) { + mDIGIT(false); + } else { + if (_cnt124 >= 1) { + break _loop124; + } else { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + } + + _cnt124++; + } while (true); + } + { + if ((LA(1) == 'E' || LA(1) == 'e')) { + mExponent(false); + } else { + } + + } + _ttype = FLOT_NUM; + } else { + } + + } + + //System.out.println("number like .3e-2"); + + break; + } + default: { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + } + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + protected final void mExponent(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = Exponent; + int _saveIndex; + + { + switch (LA(1)) { + case 'e': { + match('e'); + break; + } + case 'E': { + match('E'); + break; + } + default: { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + } + } + { + switch (LA(1)) { + case '+': { + match('+'); + break; + } + case '-': { + match('-'); + break; + } + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': { + break; + } + default: { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + } + } + { + int _cnt144 = 0; + _loop144: + do { + if (((LA(1) >= '0' && LA(1) <= '9'))) { + mDIGIT(false); + } else { + if (_cnt144 >= 1) { + break _loop144; + } else { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + } + + _cnt144++; + } while (true); + } + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mSTRING_LITERAL_DSQ(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = STRING_LITERAL_DSQ; + int _saveIndex; + + match('"'); + { + _loop128: + do { + if ((LA(1) == '\\')) { + mESC(false); + } else if ((_tokenSet_2.member(LA(1)))) { + matchNot('"'); + } else { + break _loop128; + } + + } while (true); + } + match('"'); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + protected final void mESC(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = ESC; + int _saveIndex; + + match('\\'); + { + switch (LA(1)) { + case 'n': { + match('n'); + break; + } + case 'r': { + match('r'); + break; + } + case 't': { + match('t'); + break; + } + case 'b': { + match('b'); + break; + } + case 'f': { + match('f'); + break; + } + case '"': { + match('"'); + break; + } + case '\'': { + match('\''); + break; + } + case '\\': { + match('\\'); + break; + } + case 'u': { + { + int _cnt136 = 0; + _loop136: + do { + if ((LA(1) == 'u')) { + match('u'); + } else { + if (_cnt136 >= 1) { + break _loop136; + } else { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + } + + _cnt136++; + } while (true); + } + mXDIGIT(false); + mXDIGIT(false); + mXDIGIT(false); + mXDIGIT(false); + break; + } + case '0': + case '1': + case '2': + case '3': { + matchRange('0', '3'); + { + if (((LA(1) >= '0' && LA(1) <= '7')) && ((LA(2) >= '\u0003' && LA(2) <= '\ufffe'))) { + matchRange('0', '7'); + { + if (((LA(1) >= '0' && LA(1) <= '7')) && ((LA(2) >= '\u0003' && LA(2) <= '\ufffe'))) { + matchRange('0', '7'); + } else if (((LA(1) >= '\u0003' && LA(1) <= '\ufffe')) && (true)) { + } else { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + + } + } else if (((LA(1) >= '\u0003' && LA(1) <= '\ufffe')) && (true)) { + } else { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + + } + break; + } + case '4': + case '5': + case '6': + case '7': { + matchRange('4', '7'); + { + if (((LA(1) >= '0' && LA(1) <= '7')) && ((LA(2) >= '\u0003' && LA(2) <= '\ufffe'))) { + matchRange('0', '7'); + } else if (((LA(1) >= '\u0003' && LA(1) <= '\ufffe')) && (true)) { + } else { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + + } + break; + } + default: { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + } + } + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mSTRING_LITERAL_SSQ(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = STRING_LITERAL_SSQ; + int _saveIndex; + + match('\''); + { + _loop131: + do { + if ((LA(1) == '\\')) { + mESC(false); + } else if ((_tokenSet_3.member(LA(1)))) { + matchNot('\''); + } else { + break _loop131; + } + + } while (true); + } + match('\''); + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + protected final void mXDIGIT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = XDIGIT; + int _saveIndex; + + switch (LA(1)) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': { + matchRange('0', '9'); + break; + } + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': { + matchRange('a', 'f'); + break; + } + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': { + matchRange('A', 'F'); + break; + } + default: { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + } + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + public final void mWS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { + int _ttype; + Token _token = null; + int _begin = text.length(); + _ttype = WS; + int _saveIndex; + + { + int _cnt151 = 0; + _loop151: + do { + switch (LA(1)) { + case ' ': { + match(' '); + break; + } + case '\t': { + match('\t'); + break; + } + case '\u000c': { + match('\f'); + break; + } + case '\n': + case '\r': { + { + if ((LA(1) == '\r') && (LA(2) == '\n')) { + match("\r\n"); + } else if ((LA(1) == '\r') && (true)) { + match('\r'); + } else if ((LA(1) == '\n')) { + match('\n'); + } else { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + + } + //new line 不生效情况居多,此line对于公式语法的检测没有什么作用,还不如直接用column定位,表示第xx个字符 + //newline(); + break; + } + default: { + if (_cnt151 >= 1) { + break _loop151; + } else { + throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn()); + } + } + } + _cnt151++; + } while (true); + } + _ttype = Token.SKIP; + if (_createToken && _token == null && _ttype != Token.SKIP) { + _token = makeToken(_ttype); + _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin)); + } + _returnToken = _token; + } + + + private static final long[] mk_tokenSet_0() { + long[] data = new long[1025]; + data[1] = 576460743847706622L; + return data; + } + + public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0()); + + private static final long[] mk_tokenSet_1() { + long[] data = new long[3988]; + data[0] = 68719476736L; + data[1] = 576460745995190270L; + data[3] = -36028797027352577L; + for (int i = 4; i <= 127; i++) { + data[i] = -1L; + } + for (int i = 193; i <= 197; i++) { + data[i] = -1L; + } + data[198] = 65535L; + for (int i = 204; i <= 205; i++) { + data[i] = -1L; + } + for (int i = 208; i <= 243; i++) { + data[i] = -1L; + } + data[244] = 70368744177663L; + for (int i = 312; i <= 639; i++) { + data[i] = -1L; + } + for (int i = 688; i <= 861; i++) { + data[i] = -1L; + } + data[862] = 281474976710655L; + for (int i = 996; i <= 1003; i++) { + data[i] = -1L; + } + return data; + } + + public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1()); + + private static final long[] mk_tokenSet_2() { + long[] data = new long[2048]; + data[0] = -17179869192L; + data[1] = -268435457L; + for (int i = 2; i <= 1022; i++) { + data[i] = -1L; + } + data[1023] = 9223372036854775807L; + return data; + } + + public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2()); + + private static final long[] mk_tokenSet_3() { + long[] data = new long[2048]; + data[0] = -549755813896L; + data[1] = -268435457L; + for (int i = 2; i <= 1022; i++) { + data[i] = -1L; + } + data[1023] = 9223372036854775807L; + return data; + } + + public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3()); + +} + diff --git a/designer-base/src/main/java/com/fr/design/formula/FormulaChecker.java b/designer-base/src/main/java/com/fr/design/formula/FormulaChecker.java index f91322f689..302be0b08d 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FormulaChecker.java +++ b/designer-base/src/main/java/com/fr/design/formula/FormulaChecker.java @@ -2,7 +2,6 @@ package com.fr.design.formula; import com.fr.design.formula.exception.FormulaExceptionTipsProcessor; import com.fr.design.i18n.Toolkit; -import com.fr.parser.FRLexer; import com.fr.parser.FRParser; import com.fr.script.checker.FunctionCheckerDispatcher; import com.fr.script.checker.result.FormulaCheckResult; @@ -29,7 +28,8 @@ public class FormulaChecker { } //过滤一些空格等符号 StringReader in = new StringReader(formulaText); - FRLexer lexer = new FRLexer(in); + //此lexer为公式校验定制 + FRFormulaLexer lexer = new FRFormulaLexer(in); FRParser parser = new FRParser(lexer); try {