Author: abelevich
Date: 2008-10-30 06:04:25 -0400 (Thu, 30 Oct 2008)
New Revision: 10975
Added:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/HtmlSeamTextLexer.java
trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/HtmlSeamTextParser.java
trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/HtmlSeamTextParserTokenTypes.java
Log:
Html to SeamText parser
Added: trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/HtmlSeamTextLexer.java
===================================================================
--- trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/HtmlSeamTextLexer.java
(rev 0)
+++
trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/HtmlSeamTextLexer.java 2008-10-30
10:04:25 UTC (rev 10975)
@@ -0,0 +1,808 @@
+// $ANTLR : "html-seamtext.g" -> "HtmlSeamTextLexer.java"$
+
+ package org.richfaces.antlr;
+
+import java.io.InputStream;
+import antlr.TokenStreamException;
+import antlr.TokenStreamIOException;
+import antlr.TokenStreamRecognitionException;
+import antlr.CharStreamException;
+import antlr.CharStreamIOException;
+import antlr.ANTLRException;
+import java.io.Reader;
+import java.util.Hashtable;
+import antlr.CharScanner;
+import antlr.InputBuffer;
+import antlr.ByteBuffer;
+import antlr.CharBuffer;
+import antlr.Token;
+import antlr.CommonToken;
+import antlr.RecognitionException;
+import antlr.NoViableAltForCharException;
+import antlr.MismatchedCharException;
+import antlr.TokenStream;
+import antlr.ANTLRHashString;
+import antlr.LexerSharedInputState;
+import antlr.collections.impl.BitSet;
+import antlr.SemanticException;
+
+public class HtmlSeamTextLexer extends antlr.CharScanner implements
HtmlSeamTextParserTokenTypes, TokenStream
+ {
+public HtmlSeamTextLexer(InputStream in) {
+ this(new ByteBuffer(in));
+}
+public HtmlSeamTextLexer(Reader in) {
+ this(new CharBuffer(in));
+}
+public HtmlSeamTextLexer(InputBuffer ib) {
+ this(new LexerSharedInputState(ib));
+}
+public HtmlSeamTextLexer(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 '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ case '8': case '9': 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':
+ 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':
+ {
+ mALPHANUMERICWORD(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '!': case '$': case '%': case '(':
+ case ')': case ',': case '-': case '.':
+ case ':': case ';': case '?': case '@':
+ case '{': case '}':
+ {
+ mPUNCTUATION(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '=':
+ {
+ mEQ(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '+':
+ {
+ mPLUS(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '_':
+ {
+ mUNDERSCORE(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '*':
+ {
+ mSTAR(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '/':
+ {
+ mSLASH(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '\\':
+ {
+ mESCAPE(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '|':
+ {
+ mBAR(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '`':
+ {
+ mBACKTICK(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '~':
+ {
+ mTWIDDLE(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '"':
+ {
+ mDOUBLEQUOTE(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '\'':
+ {
+ mSINGLEQUOTE(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '[':
+ {
+ mOPEN(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case ']':
+ {
+ mCLOSE(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '#':
+ {
+ mHASH(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '^':
+ {
+ mHAT(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '>':
+ {
+ mGT(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '<':
+ {
+ mLT(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '\t': case ' ':
+ {
+ mSPACE(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '\n': case '\r':
+ {
+ mNEWLINE(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '\uffff':
+ {
+ mEOF(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ default:
+ if ((LA(1)=='&') && (LA(2)=='l')) {
+ mESCAPED_LT(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='&') && (LA(2)=='g')) {
+ mESCAPED_GT(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='&') && (LA(2)=='a')) {
+ mESCAPED_AMP(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='&') && (LA(2)=='q')) {
+ mESCAPED_QOUT(true);
+ theRetToken=_returnToken;
+ }
+ else if ((_tokenSet_0.member(LA(1)))) {
+ mUNICODEWORD(true);
+ theRetToken=_returnToken;
+ }
+ else if ((LA(1)=='&') && (true)) {
+ mAMPERSAND(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 mALPHANUMERICWORD(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = ALPHANUMERICWORD;
+ int _saveIndex;
+
+ {
+ int _cnt430=0;
+ _loop430:
+ do {
+ 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;
+ }
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ case '8': case '9':
+ {
+ matchRange('0','9');
+ break;
+ }
+ default:
+ {
+ if ( _cnt430>=1 ) { break _loop430; } else {throw new
NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
+ }
+ }
+ _cnt430++;
+ } 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 mUNICODEWORD(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = UNICODEWORD;
+ int _saveIndex;
+
+ {
+ int _cnt433=0;
+ _loop433:
+ do {
+ if (((LA(1) >= '\u00a0' && LA(1) <= '\u00ff'))) {
+ matchRange('\u00a0','\u00ff');
+ }
+ else if (((LA(1) >= '\u0100' && LA(1) <= '\u017f'))) {
+ matchRange('\u0100','\u017f');
+ }
+ else if (((LA(1) >= '\u0180' && LA(1) <= '\u024f'))) {
+ matchRange('\u0180','\u024f');
+ }
+ else if (((LA(1) >= '\u0250' && LA(1) <= '\ufaff'))) {
+ matchRange('\u0250','\ufaff');
+ }
+ else if (((LA(1) >= '\uff00' && LA(1) <= '\uffef'))) {
+ matchRange('\uff00','\uffef');
+ }
+ else {
+ if ( _cnt433>=1 ) { break _loop433; } else {throw new
NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
+ }
+
+ _cnt433++;
+ } 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 mPUNCTUATION(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = PUNCTUATION;
+ int _saveIndex;
+
+ switch ( LA(1)) {
+ case '-':
+ {
+ match('-');
+ break;
+ }
+ case ';':
+ {
+ match(';');
+ break;
+ }
+ case ':':
+ {
+ match(':');
+ break;
+ }
+ case '(':
+ {
+ match('(');
+ break;
+ }
+ case ')':
+ {
+ match(')');
+ break;
+ }
+ case '{':
+ {
+ match('{');
+ break;
+ }
+ case '}':
+ {
+ match('}');
+ break;
+ }
+ case '?':
+ {
+ match('?');
+ break;
+ }
+ case '!':
+ {
+ match('!');
+ break;
+ }
+ case '@':
+ {
+ match('@');
+ break;
+ }
+ case '%':
+ {
+ match('%');
+ break;
+ }
+ case '.':
+ {
+ match('.');
+ break;
+ }
+ case ',':
+ {
+ match(',');
+ break;
+ }
+ case '$':
+ {
+ match('$');
+ 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 mEQ(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = EQ;
+ 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 mUNDERSCORE(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = UNDERSCORE;
+ 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 mSLASH(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = SLASH;
+ 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 mESCAPE(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = ESCAPE;
+ 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 mBAR(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = BAR;
+ 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 mBACKTICK(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = BACKTICK;
+ 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 mTWIDDLE(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = TWIDDLE;
+ 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 mDOUBLEQUOTE(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = DOUBLEQUOTE;
+ 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 mSINGLEQUOTE(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = SINGLEQUOTE;
+ 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 mOPEN(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = OPEN;
+ 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 mCLOSE(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = CLOSE;
+ 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 mHASH(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = HASH;
+ 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 mHAT(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = HAT;
+ 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 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 mAMPERSAND(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = AMPERSAND;
+ 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 mSPACE(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = SPACE;
+ int _saveIndex;
+
+ {
+ int _cnt455=0;
+ _loop455:
+ do {
+ switch ( LA(1)) {
+ case ' ':
+ {
+ match(' ');
+ break;
+ }
+ case '\t':
+ {
+ match('\t');
+ break;
+ }
+ default:
+ {
+ if ( _cnt455>=1 ) { break _loop455; } else {throw new
NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
+ }
+ }
+ _cnt455++;
+ } 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 mNEWLINE(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = NEWLINE;
+ int _saveIndex;
+
+ 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());
+ }
+
+ 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 mEOF(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = Token.EOF_TYPE;
+ int _saveIndex;
+
+ match('\uFFFF');
+ 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 mESCAPED_LT(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = ESCAPED_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 mESCAPED_GT(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = ESCAPED_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 mESCAPED_AMP(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = ESCAPED_AMP;
+ 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 mESCAPED_QOUT(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = ESCAPED_QOUT;
+ 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;
+ }
+
+
+ private static final long[] mk_tokenSet_0() {
+ long[] data = new long[4084];
+ data[2]=-4294967296L;
+ for (int i = 3; i<=1003; i++) { data[i]=-1L; }
+ for (int i = 1020; i<=1022; i++) { data[i]=-1L; }
+ data[1023]=281474976710655L;
+ return data;
+ }
+ public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
+
+ }
Added: trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/HtmlSeamTextParser.java
===================================================================
--- trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/HtmlSeamTextParser.java
(rev 0)
+++
trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/HtmlSeamTextParser.java 2008-10-30
10:04:25 UTC (rev 10975)
@@ -0,0 +1,1581 @@
+// $ANTLR : "html-seamtext.g" -> "HtmlSeamTextParser.java"$
+
+ package org.richfaces.antlr;
+
+import antlr.TokenBuffer;
+import antlr.TokenStreamException;
+import antlr.TokenStreamIOException;
+import antlr.ANTLRException;
+import antlr.LLkParser;
+import antlr.Token;
+import antlr.TokenStream;
+import antlr.RecognitionException;
+import antlr.NoViableAltException;
+import antlr.MismatchedTokenException;
+import antlr.SemanticException;
+import antlr.ParserSharedInputState;
+import antlr.collections.impl.BitSet;
+
+public class HtmlSeamTextParser extends antlr.LLkParser implements
HtmlSeamTextParserTokenTypes
+ {
+
+ public class HtmlRecognitionException extends RecognitionException {
+ Token openingElement;
+ RecognitionException wrappedException;
+
+ public HtmlRecognitionException(Token openingElement, RecognitionException
wrappedException) {
+ this.openingElement = openingElement;
+ this.wrappedException = wrappedException;
+ }
+
+ public Token getOpeningElement() {
+ return openingElement;
+ }
+
+ public String getMessage() {
+ return wrappedException.getMessage();
+ }
+
+ public Throwable getCause() {
+ return wrappedException;
+ }
+ }
+
+
+ public interface Sanitizer {
+
+ public void validateLinkTagURI(Token element, String uri) throws
SemanticException;
+ public void validateHtmlElement(Token element) throws SemanticException;
+ public void validateHtmlAttribute(Token element, Token attribute) throws
SemanticException;
+ public void validateHtmlAttributeValue(Token element, Token attribute, String
attributeValue) throws SemanticException;
+ public void escapeSeamTextToken(Token element);
+ public String getInvalidURIMessage(String uri);
+ public String getInvalidElementMessage(String elementName);
+ public String getInvalidAttributeMessage(String elementName, String
attributeName);
+ public String getInvalidAttributeValueMessage(String elementName, String
attributeName, String value);
+
+ }
+
+ public static class DefaultSanitizer implements HtmlSeamTextParser.Sanitizer {
+
+ protected java.util.Set<String> attributesWhoseValueIsAURI = new
java.util.HashSet(java.util.Arrays.asList(
+ "action", "cite", "href", "longdesc",
"src", "xlink:href", "xml:base"
+ ));
+
+
+ protected java.util.Set<String> uriSchemes = new
java.util.HashSet(java.util.Arrays.asList(
+ "afs", "aim", "callto", "ed2k",
"feed", "ftp", "gopher", "http",
"https",
+ "irc", "mailto", "news", "nntp",
"rsync", "rtsp", "sftp", "ssh", "tag",
+ "tel", "telnet", "urn", "webcal",
"wtai", "xmpp"
+ ));
+
+ protected java.util.Set<String> acceptableElements = new
java.util.HashSet(java.util.Arrays.asList(
+ "a", "abbr", "acronym", "address",
"area", "b", "bdo", "big",
"blockquote",
+ "br", "button", "caption", "center",
"cite", "code", "col", "colgroup",
"dd",
+ "del", "dfn", "dir", "div",
"dl", "dt", "em", "fieldset", "font",
"form",
+ "h1", "h2", "h3", "h4",
"h5", "h6", "hr", "i", "img",
"input", "ins", "kbd",
+ "label", "legend", "li", "map",
"menu", "ol", "optgroup", "option",
"p",
+ "pre", "q", "s", "samp",
"select", "small", "span", "strike",
"strong",
+ "sub", "sup", "table", "tbody",
"td", "textarea", "tfoot", "th",
"thead",
+ "tr", "tt", "u", "ul",
"var", "wbr"
+ ));
+
+ protected java.util.Set<String> mathmlElements = new
java.util.HashSet(java.util.Arrays.asList(
+ "maction", "math", "merror", "mfrac",
"mi", "mmultiscripts", "mn", "mo",
+ "mover", "mpadded", "mphantom",
"mprescripts", "mroot", "mrow", "mspace",
+ "msqrt", "mstyle", "msub", "msubsup",
"msup", "mtable", "mtd", "mtext",
+ "mtr", "munder", "munderover",
"none"
+ ));
+
+ protected java.util.Set<String> svgElements = new
java.util.HashSet(java.util.Arrays.asList(
+ "a", "animate", "animateColor",
"animateMotion", "animateTransform",
+ "circle", "defs", "desc", "ellipse",
"font-face", "font-face-name",
+ "font-face-src", "g", "glyph",
"hkern", "image", "line", "linearGradient",
+ "marker", "metadata", "missing-glyph",
"mpath", "path", "polygon",
+ "polyline", "radialGradient", "rect",
"set", "stop", "svg", "switch", "text",
+ "title", "tspan", "use"
+ ));
+
+ protected java.util.Set<String> acceptableAttributes = new
java.util.HashSet(java.util.Arrays.asList(
+ "abbr", "accept", "accept-charset",
"accesskey", "action", "align", "alt",
+ "axis", "border", "cellpadding",
"cellspacing", "char", "charoff", "charset",
+ "checked", "cite", "class", "clear",
"color", "cols", "colspan", "compact",
+ "coords", "datetime", "dir",
"disabled", "enctype", "for", "frame",
+ "headers", "height", "href",
"hreflang", "hspace", "id", "ismap",
"label",
+ "lang", "longdesc", "maxlength",
"media", "method", "multiple", "name",
+ "nohref", "noshade", "nowrap",
"prompt", "readonly", "rel", "rev",
"rows",
+ "rowspan", "rules", "scope",
"selected", "shape", "size", "span",
"src",
+ "start", "style", "summary",
"tabindex", "target", "title", "type",
"usemap",
+ "valign", "value", "vspace", "width",
"xml:lang"
+ ));
+
+ protected java.util.Set<String> mathmlAttributes = new
java.util.HashSet(java.util.Arrays.asList(
+ "actiontype", "align", "columnalign",
"columnalign", "columnalign",
+ "columnlines", "columnspacing", "columnspan",
"depth", "display",
+ "displaystyle", "equalcolumns", "equalrows",
"fence", "fontstyle",
+ "fontweight", "frame", "height",
"linethickness", "lspace", "mathbackground",
+ "mathcolor", "mathvariant", "mathvariant",
"maxsize", "minsize", "other",
+ "rowalign", "rowalign", "rowalign",
"rowlines", "rowspacing", "rowspan",
+ "rspace", "scriptlevel", "selection",
"separator", "stretchy", "width",
+ "width", "xlink:href", "xlink:show",
"xlink:type", "xmlns", "xmlns:xlink"
+ ));
+
+
+ protected java.util.Set<String> svgAttributes = new
java.util.HashSet(java.util.Arrays.asList(
+ "accent-height", "accumulate", "additive",
"alphabetic", "arabic-form",
+ "ascent", "attributeName", "attributeType",
"baseProfile", "bbox", "begin",
+ "by", "calcMode", "cap-height",
"class", "color", "color-rendering",
+ "content", "cx", "cy", "d",
"descent", "display", "dur", "dx", "dy",
"end",
+ "fill", "fill-rule", "font-family",
"font-size", "font-stretch",
+ "font-style", "font-variant", "font-weight",
"from", "fx", "fy", "g1", "g2",
+ "glyph-name", "gradientUnits", "hanging",
"height", "horiz-adv-x",
+ "horiz-origin-x", "id", "ideographic",
"k", "keyPoints", "keySplines",
+ "keyTimes", "lang", "marker-end",
"marker-mid", "marker-start",
+ "markerHeight", "markerUnits", "markerWidth",
"mathematical", "max", "min",
+ "name", "offset", "opacity",
"orient", "origin", "overline-position",
+ "overline-thickness", "panose-1", "path",
"pathLength", "points",
+ "preserveAspectRatio", "r", "refX",
"refY", "repeatCount", "repeatDur",
+ "requiredExtensions", "requiredFeatures",
"restart", "rotate", "rx", "ry",
+ "slope", "stemh", "stemv",
"stop-color", "stop-opacity",
+ "strikethrough-position", "strikethrough-thickness",
"stroke",
+ "stroke-dasharray", "stroke-dashoffset",
"stroke-linecap", "stroke-linejoin",
+ "stroke-miterlimit", "stroke-opacity",
"stroke-width", "systemLanguage",
+ "target", "text-anchor", "to",
"transform", "type", "u1", "u2",
+ "underline-position", "underline-thickness",
"unicode", "unicode-range",
+ "units-per-em", "values", "version",
"viewBox", "visibility", "width",
+ "widths", "x", "x-height", "x1",
"x2", "xlink:actuate", "xlink:arcrole",
+ "xlink:href", "xlink:role", "xlink:show",
"xlink:title", "xlink:type",
+ "xml:base", "xml:lang", "xml:space",
"xmlns", "xmlns:xlink", "y", "y1",
"y2",
+ "zoomAndPan"
+ ));
+
+ public final java.util.regex.Pattern REGEX_VALID_CSS_VALUE =
java.util.regex.Pattern.compile(
+
"^(#[0-9a-f]{3,6}|rgb\\(\\d{1,3}%?,\\d{1,3}%?,?\\d{1,3}%?\\)?|-?\\d{0,2}\\.?\\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\\))?)$"
+ );
+
+ public final java.util.regex.Pattern REGEX_VALID_CSS_STRING1 =
java.util.regex.Pattern.compile(
+
"^([-:,;#%.\\sa-zA-Z0-9!]|\\w-\\w|'[\\s\\w]+'|\"[\\s\\w]+\"|\\([\\d,\\s]+\\))*$"
+ );
+
+ public final java.util.regex.Pattern REGEX_VALID_CSS_STRING2 =
java.util.regex.Pattern.compile(
+ "^(\\s*[-\\w]+\\s*:\\s*[^:;]*(;|$))*$"
+ );
+
+
+ protected java.util.Set<String> styleProperties = new
java.util.HashSet(java.util.Arrays.asList(
+ "azimuth",
+ "background", "background-attachment",
"background-color", "background-image",
+ "background-position", "background-repeat",
+ "border", "border-bottom",
"border-bottom-color", "border-bottom-style",
+ "border-bottom-width", "border-collapse",
"border-color", "border-left",
+ "border-left-color", "border-left-style",
"border-left-width", "border-right",
+ "border-right-color", "border-right-style",
"border-right-width", "border-spacing",
+ "border-style", "border-top",
"border-top-color", "border-top-style",
+ "border-top-width", "border-width",
+ "clear", "color",
+ "cursor", "direction", "display",
"elevation", "float", "font",
+ "font-family", "font-size", "font-style",
"font-variant", "font-weight",
+ "height", "letter-spacing", "line-height",
+ "margin", "margin-bottom", "margin-left",
"margin-right", "margin-top",
+ "max-height", "max-width", "min-height",
"min-width",
+ "overflow",
+ "padding", "padding-bottom", "padding-left",
"padding-right", "padding-top",
+ "pause", "pause-after", "pause-before",
"pitch",
+ "pitch-range", "richness", "speak",
"speak-header", "speak-numeral",
+ "speak-punctuation", "speech-rate", "stress",
"text-align",
+ "text-decoration", "text-indent",
"unicode-bidi", "vertical-align",
+ "voice-family", "volume", "white-space",
"width"
+ ));
+
+
+ protected java.util.Set<String> stylePropertiesValues = new
java.util.HashSet(java.util.Arrays.asList(
+ "aqua", "auto", "baseline", "black",
"block", "blue", "bold", "both",
"bottom", "brown",
+ "center", "collapse", "dashed",
"dotted", "fuchsia", "gray", "green",
+ "inherit", "italic", "left",
"length", "lime", "maroon", "medium",
"middle", "navy", "none", "normal",
+ "nowrap", "olive", "percentage",
"pointer", "purple", "red", "right",
"silver", "solid", "sub", "super",
+ "teal", "text-bottom", "text-top",
"top", "transparent", "underline", "white",
"yellow"
+ ));
+
+ protected java.util.Set<String> svgStyleProperties = new
java.util.HashSet(java.util.Arrays.asList(
+ "fill", "fill-opacity", "fill-rule",
"stroke", "stroke-linecap",
+ "stroke-linejoin", "stroke-opacity",
"stroke-width"
+ ));
+
+
+ public void validateLinkTagURI(Token element, String uri) throws SemanticException
{
+ if (!validateURI(uri)) {
+ throw createSemanticException("Invalid URI", element);
+ }
+ }
+
+ public void validateHtmlElement(Token element) throws SemanticException {
+ String elementName = element.getText().toLowerCase();
+ if (!acceptableElements.contains(elementName) &&
+ !svgElements.contains(elementName) &&
+ !mathmlElements.contains(elementName)) {
+ throw createSemanticException(getInvalidElementMessage(elementName),
element);
+ }
+ }
+
+ public void validateHtmlAttribute(Token element, Token attribute) throws
SemanticException {
+ String elementName = element.getText().toLowerCase();
+ String attributeName = attribute.getText().toLowerCase();
+ if (!acceptableAttributes.contains(attributeName) &&
+ !svgAttributes.contains(attributeName) &&
+ !mathmlAttributes.contains(attributeName)) {
+ throw createSemanticException(getInvalidAttributeMessage(elementName,
attributeName), element);
+ }
+
+ }
+
+ public void validateHtmlAttributeValue(Token element, Token attribute, String
attributeValue) throws SemanticException{
+
+ if (attributeValue == null || attributeValue.length() == 0) return;
+
+ String elementName = element.getText().toLowerCase();
+ String attributeName = attribute.getText().toLowerCase();
+
+ // Check element with attribute that has URI value (href, src, etc.)
+ if (attributesWhoseValueIsAURI.contains(attributeName) &&
!validateURI(attributeValue)) {
+ throw createSemanticException(getInvalidURIMessage(attributeValue),
element);
+ }
+
+ // Check attribute value of style (CSS filtering)
+ if (attributeName.equals("style")) {
+ if (!REGEX_VALID_CSS_STRING1.matcher(attributeValue).matches() ||
+ !REGEX_VALID_CSS_STRING2.matcher(attributeValue).matches()) {
+ throw createSemanticException(
+ getInvalidAttributeValueMessage(elementName, attributeName,
attributeValue),
+ element
+ );
+ }
+
+ String[] cssProperties = attributeValue.split(";");
+ for (String cssProperty : cssProperties) {
+ if (!cssProperty.contains(":")) {
+ throw createSemanticException(
+ getInvalidAttributeValueMessage(elementName, attributeName,
attributeValue),
+ element
+ );
+ }
+ String[] property = cssProperty.split(":");
+ String propertyName = property[0].trim();
+ String propertyValue = property.length == 2 ? property[1].trim() :
null;
+
+ // CSS property name
+ if (!styleProperties.contains(propertyName) &&
+ !svgStyleProperties.contains(propertyName)) {
+ throw createSemanticException(
+ getInvalidAttributeValueMessage(elementName, attributeName,
attributeValue),
+ element
+ );
+ }
+
+ // CSS property value
+ if (propertyValue != null &&
!stylePropertiesValues.contains(propertyValue)) {
+ // Not in list, now check the regex
+ if (!REGEX_VALID_CSS_VALUE.matcher(propertyValue).matches()) {
+ throw createSemanticException(
+ getInvalidAttributeValueMessage(elementName,
attributeName, attributeValue),
+ element
+ );
+ }
+ }
+ }
+ }
+
+
+ }
+
+ public String getInvalidURIMessage(String uri){
+ return "invalid URI";
+ }
+
+ public String getInvalidElementMessage(String elementName){
+ return "invalid element '" + elementName + "'";
+ }
+
+ public String getInvalidAttributeMessage(String elementName, String
attributeName){
+ return "invalid attribute '" + attributeName + "' for
element '" + elementName + "'";
+ }
+
+ public String getInvalidAttributeValueMessage(String elementName, String
attributeName, String value){
+ return "invalid value of attribute '" + attributeName +
"' for element '" + elementName + "'";
+ }
+
+ public void escapeSeamTextToken(Token element) {
+ }
+
+ protected boolean validateURI(String uri) {
+
+ // Relative URI starts with a slash
+ if (uri.startsWith("/")) return true;
+
+ java.net.URI parsedURI;
+ try {
+ parsedURI = new java.net.URI(uri);
+ } catch (java.net.URISyntaxException ex) {
+ return false;
+ }
+
+ if (!uriSchemes.contains(parsedURI.getScheme())) {
+ return false;
+ }
+ return true;
+ }
+
+ public SemanticException createSemanticException(String message, Token element) {
+ return new SemanticException(
+ message,
+ element.getFilename(), element.getLine(), element.getColumn()
+ );
+ }
+
+ }
+
+
+ private final String SEAMTEXT_MONOSPACE = "|";
+
+ private final String SEAMTEXT_TWIDDLE = "~";
+
+ private final String SEAMTEXT_HASH = "#";
+
+ private final String SEAMTEXT_HAT = "^";
+
+ private final String SEAMTEXT_PLUS = "+";
+
+ private final String SEAMTEXT_STAR = "*";
+
+ private final String SEAMTEXT_UNDERSCORE = "_";
+
+ private final String SEAMTEXT_EQ = "=";
+
+ private final String SEAMTEXT_BACKTICK = "`";
+
+ private final String SEAMTEXT_PARAGRAPH = "\n\n";
+
+ private final String SEAM_DOUBLEQUOTE = "\"";
+
+ private final String SEAM_OPEN = "[";
+
+ private final String SEAM_CLOSE = "]";
+
+ private final String SEAM_GT = ">";
+
+
+ protected java.util.Set<String> seamTextSymbols = new
java.util.HashSet(java.util.Arrays.asList(
+ SEAMTEXT_MONOSPACE, SEAMTEXT_TWIDDLE, SEAMTEXT_HASH, SEAMTEXT_HAT, SEAMTEXT_PLUS,
SEAMTEXT_STAR,
+ SEAMTEXT_UNDERSCORE, SEAMTEXT_EQ, SEAMTEXT_BACKTICK, SEAMTEXT_PARAGRAPH,
SEAM_DOUBLEQUOTE, SEAM_OPEN,
+ SEAM_CLOSE, SEAM_GT
+ ));
+
+ protected java.util.Set<String> htmlSeamTextElements = new
java.util.HashSet(java.util.Arrays.asList(
+ "del", "sup", "pre","p", "q"
,"h1" ,"h2" ,"h3" ,"h4" ,"ul"
,"ol" ,"li" ,"i" ,"tt" ,"u"
,"a"));
+
+ private Sanitizer sanitizer = new DefaultSanitizer();
+
+ private java.util.Stack<Token> htmlElementStack = new
java.util.Stack<Token>();
+
+ private StringBuilder mainBuilder = new StringBuilder();
+
+ private StringBuilder linkValueCollector = new StringBuilder();
+
+ private String linkHolder;
+
+ private StringBuilder builder = mainBuilder;
+
+
+ public void setSanitizer(Sanitizer sanitizer) {
+ this.sanitizer = sanitizer;
+ }
+
+ public String toString() {
+ return builder.toString();
+ }
+
+ private void beginCapture() {
+ builder = new StringBuilder();
+ }
+
+ private String endCapture() {
+ String result = builder.toString();
+ builder = mainBuilder;
+ return result;
+ }
+
+ private void append(String... strings) {
+ for (String string: strings) builder.append(string);
+ }
+
+
+ public boolean isLink(Token token) {
+ String name = token.getText().toLowerCase();
+ return "a".equals(name);
+ }
+
+ private String createSeamTextLink(String link, String value) {
+
+ StringBuilder builder = new StringBuilder();
+ builder.append("[");
+
+ if (value != null) {
+ builder.append(value.trim());
+ }
+
+ builder.append("=>");
+ builder.append(link);
+ builder.append("]");
+
+ return builder.toString();
+
+ }
+
+ public boolean isHeader(Token token) {
+ String name = token.getText().toLowerCase();
+ return ("h1".equals(name) || "h2".equals(name) ||
"h3".equals(name) || "h4".equals(name));
+ }
+
+ public String createSeamTextHeader(Token token) throws SemanticException {
+
+ String name = token.getText();
+ StringBuilder seamHeader = new StringBuilder();
+
+ if("h1".equals(name)) {
+ seamHeader.append("\n").append(SEAMTEXT_PLUS);
+ } else if("h2".equals(name)) {
+ seamHeader.append("\n").append(SEAMTEXT_PLUS).append(SEAMTEXT_PLUS);
+ } else if("h3".equals(name)) {
+
seamHeader.append("\n").append(SEAMTEXT_PLUS).append(SEAMTEXT_PLUS).append(SEAMTEXT_PLUS);
+ } else if("h4".equals(name)) {
+
seamHeader.append("\n").append(SEAMTEXT_PLUS).append(SEAMTEXT_PLUS).append(SEAMTEXT_PLUS).append(SEAMTEXT_PLUS);
+ }
+
+ return seamHeader.toString();
+ }
+
+ public boolean isList(Token token){
+ String name = token.getText();
+ return ("ul".equals(name) || "ol".equals(name));
+ }
+
+ public boolean isListItem(Token token) {
+ String name = token.getText().toLowerCase();
+ return "li".equals(name);
+ }
+
+ public String createSeamTextList(Token token, java.util.Stack <Token>
htmlElementStack) throws SemanticException {
+ String seamText = null;
+
+ Token parent = htmlElementStack.peek();
+ String parentName = parent.getText().toLowerCase();
+ if(parentName.equals("ul")) {
+ seamText = SEAMTEXT_HASH;
+ } else if (parentName.equals("ol")){
+ seamText = SEAMTEXT_EQ;
+ } else {
+ String message = "<li> must follow <ol> or <ul> not <"
+ parent.getText() + ">";
+ throw new SemanticException( message, parent.getFilename(), parent.getLine(),
parent.getColumn());
+ }
+
+ return seamText != null ? seamText : "";
+ }
+
+ // validate lists and headers'
+ public void validateNestedMarkup(Token name, java.util.Stack <Token>
htmlElementStack) throws SemanticException {
+ if(!htmlElementStack.isEmpty()) {
+ for(Token token : htmlElementStack) {
+
+ if(token.getText().equals("h1") ||
token.getText().equals("h2") || token.getText().equals("h3")
+ || token.getText().equals("h4")
|| token.getText().equals("ol") || token.getText().equals("ul")) {
+ String message = "<" + token.getText() + "> contains nested
<" + name.getText() + "> token";
+ throw new SemanticException( message, name.getFilename(), name.getLine(),
name.getColumn());
+ }
+ }
+ }
+
+ }
+
+ public void validateHeaderMarkup(Token token, java.util.Stack <Token>
htmlElementStack) throws TokenStreamException, SemanticException{
+ int EOF = 1;
+ int ALPHANUMERICWORD = 4;
+ int i = 0;
+ int type;
+
+ boolean containText = false;
+
+ Token element = htmlElementStack.peek();
+ String header = element.getText();
+
+ if (header.equals("h1") || header.equals("h2") ||
header.equals("h3") || header.equals("h4")) {
+ do {
+ i++;
+ type = LT(i).getType();
+ if (type == ALPHANUMERICWORD) {
+ containText = true;
+ break;
+ }
+
+ } while ( type != EOF);
+
+ if (!containText) {
+ String message = "You must have some text following a heading";
+ throw new SemanticException( message, element.getFilename(), element.getLine(),
element.getColumn());
+ }
+ }
+
+ }
+
+ public String createSimpleSeamText(Token token) throws SemanticException{
+
+ String name = token.getText().toLowerCase();
+ StringBuilder seamText = new StringBuilder();
+
+ if("tt".equals(name)) {
+ seamText.append(SEAMTEXT_MONOSPACE);
+ } else if("del".equals(name)) {
+ seamText.append(SEAMTEXT_TWIDDLE);
+ } else if("i".equals(name)) {
+ seamText.append(SEAMTEXT_STAR);
+ } else if("sup".equals(name)) {
+ seamText.append(SEAMTEXT_HAT);
+ } else if("u".equals(name)) {
+ seamText.append(SEAMTEXT_UNDERSCORE);
+ } else if("pre".equals(name)) {
+ seamText.append(SEAMTEXT_BACKTICK);
+ } else if("p".equals(name)) {
+ seamText.append(SEAMTEXT_PARAGRAPH);
+ } else if("q".equals(name)) {
+ seamText.append(SEAM_DOUBLEQUOTE);
+ } else if("blockquote".equals(name)) {
+ seamText.append(SEAM_DOUBLEQUOTE);
+ }
+
+ return seamText.toString();
+
+ }
+
+ public boolean isSeamTextElement(Token element){
+ String name = element.getText().toLowerCase();
+ return htmlSeamTextElements.contains(name);
+ }
+
+
+ public String escapeSeamText(Token token, java.util.Stack <Token>
parentHtmlTokens) throws TokenStreamException {
+
+ StringBuilder result = new StringBuilder();
+ String tokenName = token.getText();
+
+ if(parentHtmlTokens != null && !parentHtmlTokens.isEmpty()){
+ Token parentToken = parentHtmlTokens.peek();
+ String parentTokenName = parentToken.getText().toLowerCase();
+
+ if ("tt".equals(parentTokenName) ||
"pre".equals(parentTokenName)) {
+
+ if ("<".equals(tokenName)) {
+ result.append("<");
+ } else if("&".equals(tokenName)) {
+ result.append("&");
+ } else if (">".equals(tokenName)) {
+ result.append(">");
+ } else if(""".equals(tokenName)){
+ result.append("\"");
+ }else if(seamTextSymbols.contains(tokenName)) {
+ result.append(tokenName);
+ }
+ }
+ }
+ result = result.length() != 0 ? result :
result.append("\\").append(tokenName);
+ return result.toString();
+ }
+
+
+
+
+protected HtmlSeamTextParser(TokenBuffer tokenBuf, int k) {
+ super(tokenBuf,k);
+ tokenNames = _tokenNames;
+}
+
+public HtmlSeamTextParser(TokenBuffer tokenBuf) {
+ this(tokenBuf,4);
+}
+
+protected HtmlSeamTextParser(TokenStream lexer, int k) {
+ super(lexer,k);
+ tokenNames = _tokenNames;
+}
+
+public HtmlSeamTextParser(TokenStream lexer) {
+ this(lexer,4);
+}
+
+public HtmlSeamTextParser(ParserSharedInputState state) {
+ super(state,4);
+ tokenNames = _tokenNames;
+}
+
+ public final void startRule() throws RecognitionException, TokenStreamException {
+
+
+ {
+ _loop388:
+ do {
+ if ((LA(1)==NEWLINE)) {
+ newline();
+ }
+ else {
+ break _loop388;
+ }
+
+ } while (true);
+ }
+ {
+ switch ( LA(1)) {
+ case ALPHANUMERICWORD:
+ case UNICODEWORD:
+ case DOUBLEQUOTE:
+ case ESCAPED_LT:
+ case ESCAPED_GT:
+ case ESCAPED_AMP:
+ case ESCAPED_QOUT:
+ case PUNCTUATION:
+ case SINGLEQUOTE:
+ case SLASH:
+ case STAR:
+ case BAR:
+ case HAT:
+ case PLUS:
+ case EQ:
+ case HASH:
+ case ESCAPE:
+ case TWIDDLE:
+ case OPEN:
+ case CLOSE:
+ case BACKTICK:
+ case GT:
+ case SPACE:
+ case LT:
+ {
+ text();
+ eof();
+ break;
+ }
+ case EOF:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ }
+
+ public final void newline() throws RecognitionException, TokenStreamException {
+
+ Token n = null;
+
+ n = LT(1);
+ match(NEWLINE);
+ append(n.getText());
+ }
+
+ public final void text() throws RecognitionException, TokenStreamException {
+
+
+ {
+ int _cnt395=0;
+ _loop395:
+ do {
+ if ((_tokenSet_0.member(LA(1)))) {
+ {
+ switch ( LA(1)) {
+ case STAR:
+ case BAR:
+ case HAT:
+ case PLUS:
+ case EQ:
+ case HASH:
+ case ESCAPE:
+ case TWIDDLE:
+ case OPEN:
+ case CLOSE:
+ case BACKTICK:
+ case GT:
+ {
+ seamCharacters();
+ break;
+ }
+ case ALPHANUMERICWORD:
+ case UNICODEWORD:
+ case PUNCTUATION:
+ case SINGLEQUOTE:
+ case SLASH:
+ case SPACE:
+ {
+ plain();
+ break;
+ }
+ case LT:
+ {
+ html();
+ break;
+ }
+ case DOUBLEQUOTE:
+ case ESCAPED_LT:
+ case ESCAPED_GT:
+ case ESCAPED_AMP:
+ case ESCAPED_QOUT:
+ {
+ htmlSpecialChars();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ {
+ _loop394:
+ do {
+ if ((LA(1)==NEWLINE)) {
+ newline();
+ }
+ else {
+ break _loop394;
+ }
+
+ } while (true);
+ }
+ }
+ else {
+ if ( _cnt395>=1 ) { break _loop395; } else {throw new NoViableAltException(LT(1),
getFilename());}
+ }
+
+ _cnt395++;
+ } while (true);
+ }
+ }
+
+ public final void eof() throws RecognitionException, TokenStreamException {
+
+
+ match(Token.EOF_TYPE);
+ }
+
+ public final void seamCharacters() throws RecognitionException, TokenStreamException {
+
+ Token hat = null;
+ Token hash = null;
+ Token open = null;
+ Token close = null;
+ Token twiddle = null;
+ Token bar = null;
+ Token eq = null;
+ Token plus = null;
+ Token backtick = null;
+ Token st = null;
+ Token e = null;
+ Token gt = null;
+
+ switch ( LA(1)) {
+ case HAT:
+ {
+ hat = LT(1);
+ match(HAT);
+ append(escapeSeamText(hat, htmlElementStack));
+ break;
+ }
+ case HASH:
+ {
+ hash = LT(1);
+ match(HASH);
+ append(escapeSeamText(hash, htmlElementStack));
+ break;
+ }
+ case OPEN:
+ {
+ open = LT(1);
+ match(OPEN);
+ append(escapeSeamText(open, htmlElementStack)) ;
+ break;
+ }
+ case CLOSE:
+ {
+ close = LT(1);
+ match(CLOSE);
+ append(escapeSeamText(close, htmlElementStack));
+ break;
+ }
+ case TWIDDLE:
+ {
+ twiddle = LT(1);
+ match(TWIDDLE);
+ append(escapeSeamText(twiddle, htmlElementStack));
+ break;
+ }
+ case BAR:
+ {
+ bar = LT(1);
+ match(BAR);
+ append(escapeSeamText(bar, htmlElementStack));
+ break;
+ }
+ case EQ:
+ {
+ eq = LT(1);
+ match(EQ);
+ append(escapeSeamText(eq, htmlElementStack));
+ break;
+ }
+ case PLUS:
+ {
+ plus = LT(1);
+ match(PLUS);
+ append(escapeSeamText(plus, htmlElementStack));
+ break;
+ }
+ case BACKTICK:
+ {
+ backtick = LT(1);
+ match(BACKTICK);
+ append(escapeSeamText(backtick, htmlElementStack));
+ break;
+ }
+ case STAR:
+ {
+ st = LT(1);
+ match(STAR);
+ append(escapeSeamText(st, htmlElementStack));
+ break;
+ }
+ case ESCAPE:
+ {
+ e = LT(1);
+ match(ESCAPE);
+ append(escapeSeamText(e, htmlElementStack));
+ break;
+ }
+ case GT:
+ {
+ gt = LT(1);
+ match(GT);
+ append(escapeSeamText(gt, htmlElementStack));
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+
+ public final void plain() throws RecognitionException, TokenStreamException {
+
+
+ {
+ switch ( LA(1)) {
+ case ALPHANUMERICWORD:
+ case UNICODEWORD:
+ {
+ word();
+ break;
+ }
+ case PUNCTUATION:
+ case SINGLEQUOTE:
+ case SLASH:
+ {
+ punctuation();
+ break;
+ }
+ case SPACE:
+ {
+ space();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ }
+
+ public final void html() throws RecognitionException, TokenStreamException {
+
+
+ openTag();
+ {
+ _loop407:
+ do {
+ if ((LA(1)==SPACE) && (LA(2)==SLASH||LA(2)==GT||LA(2)==SPACE)) {
+ space();
+ }
+ else if ((LA(1)==SPACE) && (LA(2)==ALPHANUMERICWORD)) {
+ space();
+ attribute();
+ }
+ else {
+ break _loop407;
+ }
+
+ } while (true);
+ }
+ {
+ switch ( LA(1)) {
+ case GT:
+ {
+ {
+ beforeBody();
+ body();
+ closeTagWithBody();
+ }
+ break;
+ }
+ case SLASH:
+ {
+ closeTagWithNoBody();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ }
+
+ public final void htmlSpecialChars() throws RecognitionException, TokenStreamException
{
+
+ Token lt = null;
+ Token gt = null;
+ Token amp = null;
+ Token qout = null;
+
+ switch ( LA(1)) {
+ case DOUBLEQUOTE:
+ {
+ match(DOUBLEQUOTE);
+ append("\"");
+ break;
+ }
+ case ESCAPED_LT:
+ {
+ lt = LT(1);
+ match(ESCAPED_LT);
+ append(escapeSeamText(lt, htmlElementStack));
+ break;
+ }
+ case ESCAPED_GT:
+ {
+ gt = LT(1);
+ match(ESCAPED_GT);
+ append(escapeSeamText(gt, htmlElementStack));
+ break;
+ }
+ case ESCAPED_AMP:
+ {
+ amp = LT(1);
+ match(ESCAPED_AMP);
+ append(escapeSeamText(amp, htmlElementStack));
+ break;
+ }
+ case ESCAPED_QOUT:
+ {
+ qout = LT(1);
+ match(ESCAPED_QOUT);
+ append(escapeSeamText(qout, htmlElementStack));
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+
+ public final void word() throws RecognitionException, TokenStreamException {
+
+ Token an = null;
+ Token uc = null;
+
+ switch ( LA(1)) {
+ case ALPHANUMERICWORD:
+ {
+ an = LT(1);
+ match(ALPHANUMERICWORD);
+ append( an.getText() );
+ break;
+ }
+ case UNICODEWORD:
+ {
+ uc = LT(1);
+ match(UNICODEWORD);
+ append( uc.getText() );
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+
+ public final void punctuation() throws RecognitionException, TokenStreamException {
+
+ Token p = null;
+ Token sq = null;
+ Token s = null;
+
+ switch ( LA(1)) {
+ case PUNCTUATION:
+ {
+ p = LT(1);
+ match(PUNCTUATION);
+ append( p.getText() );
+ break;
+ }
+ case SINGLEQUOTE:
+ {
+ sq = LT(1);
+ match(SINGLEQUOTE);
+ append( sq.getText() );
+ break;
+ }
+ case SLASH:
+ {
+ s = LT(1);
+ match(SLASH);
+ append( s.getText() );
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+
+ public final void specialChars() throws RecognitionException, TokenStreamException {
+
+ Token st = null;
+ Token b = null;
+ Token h = null;
+ Token p = null;
+ Token eq = null;
+ Token hh = null;
+ Token e = null;
+ Token t = null;
+ Token u = null;
+
+ switch ( LA(1)) {
+ case STAR:
+ {
+ st = LT(1);
+ match(STAR);
+ append( st.getText() );
+ break;
+ }
+ case BAR:
+ {
+ b = LT(1);
+ match(BAR);
+ append( b.getText() );
+ break;
+ }
+ case HAT:
+ {
+ h = LT(1);
+ match(HAT);
+ append( h.getText() );
+ break;
+ }
+ case PLUS:
+ {
+ p = LT(1);
+ match(PLUS);
+ append( p.getText() );
+ break;
+ }
+ case EQ:
+ {
+ eq = LT(1);
+ match(EQ);
+ append( eq.getText() );
+ break;
+ }
+ case HASH:
+ {
+ hh = LT(1);
+ match(HASH);
+ append( hh.getText() );
+ break;
+ }
+ case ESCAPE:
+ {
+ e = LT(1);
+ match(ESCAPE);
+ append( e.getText() );
+ break;
+ }
+ case TWIDDLE:
+ {
+ t = LT(1);
+ match(TWIDDLE);
+ append( t.getText() );
+ break;
+ }
+ case UNDERSCORE:
+ {
+ u = LT(1);
+ match(UNDERSCORE);
+ append( u.getText() );
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+
+ public final void space() throws RecognitionException, TokenStreamException {
+
+ Token s = null;
+
+ s = LT(1);
+ match(SPACE);
+
+
+ if(!htmlElementStack.isEmpty()) {
+ String tokenName = htmlElementStack.peek().getText();
+ if(!("ul".equals(tokenName) || "ol".equals(tokenName))) {
+ append(s.getText());
+ }
+
+ } else {
+ append(s.getText());
+ }
+
+
+ }
+
+ public final void newlineOrEof() throws RecognitionException, TokenStreamException {
+
+
+ switch ( LA(1)) {
+ case NEWLINE:
+ {
+ newline();
+ break;
+ }
+ case EOF:
+ {
+ match(Token.EOF_TYPE);
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+
+ public final void openTag() throws RecognitionException, TokenStreamException {
+
+ Token name = null;
+
+ try { // for error handling
+ match(LT);
+ name = LT(1);
+ match(ALPHANUMERICWORD);
+
+
+
+ sanitizer.validateHtmlElement(name);
+
+ if (isSeamTextElement(name)) {
+ if (isList(name)) {
+ validateNestedMarkup(name, htmlElementStack);
+ } else if (isListItem(name)) {
+ append(createSeamTextList(name,htmlElementStack));
+ } else if (isHeader(name)) {
+ validateNestedMarkup(name, htmlElementStack);
+ append(createSeamTextHeader(name));
+ }
+
+ } else {
+ append("<");
+ append(name.getText());
+ }
+ htmlElementStack.push(name);
+
+
+ }
+ catch (RecognitionException ex) {
+
+ if (htmlElementStack.isEmpty()) throw ex;
+ Token tok = htmlElementStack.peek();
+ if (tok != null) {
+ throw new HtmlRecognitionException(tok, ex);
+ } else {
+ throw ex;
+ }
+
+ }
+ }
+
+ public final void attribute() throws RecognitionException, TokenStreamException {
+
+ Token att = null;
+
+ try { // for error handling
+ att = LT(1);
+ match(ALPHANUMERICWORD);
+ {
+ _loop422:
+ do {
+ if ((LA(1)==SPACE)) {
+ space();
+ }
+ else {
+ break _loop422;
+ }
+
+ } while (true);
+ }
+ match(EQ);
+ {
+ _loop424:
+ do {
+ if ((LA(1)==SPACE)) {
+ space();
+ }
+ else {
+ break _loop424;
+ }
+
+ } while (true);
+ }
+ match(DOUBLEQUOTE);
+
+ Token token = htmlElementStack.peek();
+ sanitizer.validateHtmlAttribute(token, att);
+ boolean isSeamTextProcessed = isSeamTextElement(token);
+
+ if (!isSeamTextProcessed) {
+ append(att.getText());
+ append("=\"");
+ }
+ beginCapture();
+
+ attributeValue();
+
+ String attValue = endCapture();
+ sanitizer.validateHtmlAttributeValue(token, att, attValue);
+
+ if (!isSeamTextProcessed) {
+ append(attValue);
+ } else if(isLink(token) && "href".equals(att.getText())) {
+
+ linkHolder = attValue;
+ }
+
+
+ match(DOUBLEQUOTE);
+
+ if(!isSeamTextProcessed) {
+ append("\"");
+ }
+
+ }
+ catch (RecognitionException ex) {
+
+ if (htmlElementStack.isEmpty()) throw ex;
+ Token tok = htmlElementStack.peek();
+ if (tok != null) {
+ throw new HtmlRecognitionException(tok, ex);
+ } else {
+ throw ex;
+ }
+
+ }
+ }
+
+ public final void beforeBody() throws RecognitionException, TokenStreamException {
+
+
+ try { // for error handling
+ match(GT);
+
+ Token name = htmlElementStack.peek();
+ if(isSeamTextElement(name)){
+ append(createSimpleSeamText(name));
+ } else {
+ append(">");
+ }
+
+ }
+ catch (RecognitionException ex) {
+
+ if (htmlElementStack.isEmpty()) throw ex;
+ Token tok = htmlElementStack.peek();
+ if (tok != null) {
+ throw new HtmlRecognitionException(tok, ex);
+ } else {
+ throw ex;
+ }
+
+ }
+ }
+
+ public final void body() throws RecognitionException, TokenStreamException {
+
+ Token newline = null;
+
+ {
+
+ Token token = htmlElementStack.peek();
+ boolean isLink = isLink(token);
+ linkValueCollector = new StringBuilder();
+
+ {
+ _loop415:
+ do {
+ switch ( LA(1)) {
+ case STAR:
+ case BAR:
+ case HAT:
+ case PLUS:
+ case EQ:
+ case HASH:
+ case ESCAPE:
+ case TWIDDLE:
+ case OPEN:
+ case CLOSE:
+ case BACKTICK:
+ case GT:
+ {
+ seamCharacters();
+ break;
+ }
+ case ALPHANUMERICWORD:
+ case UNICODEWORD:
+ case PUNCTUATION:
+ case SINGLEQUOTE:
+ case SLASH:
+ case SPACE:
+ {
+ if(isLink) {
+ beginCapture();
+ }
+
+
+ plain();
+
+ if(isLink) {
+ String plain = endCapture();
+ linkValueCollector.append(plain);
+ }
+
+
+ break;
+ }
+ case DOUBLEQUOTE:
+ case ESCAPED_LT:
+ case ESCAPED_GT:
+ case ESCAPED_AMP:
+ case ESCAPED_QOUT:
+ {
+ htmlSpecialChars();
+
+ if(isLink) {
+ String message = "unexpected token";
+ throw new SemanticException(message);
+ }
+
+ break;
+ }
+ case NEWLINE:
+ {
+ newline = LT(1);
+ match(NEWLINE);
+ break;
+ }
+ default:
+ if ((LA(1)==LT) && (LA(2)==ALPHANUMERICWORD)) {
+ html();
+ }
+ else {
+ break _loop415;
+ }
+ }
+ } while (true);
+ }
+ }
+ }
+
+ public final void closeTagWithBody() throws RecognitionException, TokenStreamException
{
+
+ Token name = null;
+
+ match(LT);
+ match(SLASH);
+ name = LT(1);
+ match(ALPHANUMERICWORD);
+ match(GT);
+
+ if(isSeamTextElement(name)){
+ if(isLink(name)){
+ append(createSeamTextLink(linkHolder,linkValueCollector.toString().trim()));
+ } else {
+ append(createSimpleSeamText(name));
+ }
+
+ if(isListItem(name) || isHeader(name)) {
+ append("\n");
+ validateHeaderMarkup(name,htmlElementStack);
+ }
+
+ } else {
+ append("</");
+ append(name.getText());
+ append(">");
+ }
+
+
+ htmlElementStack.pop();
+
+ }
+
+ public final void closeTagWithNoBody() throws RecognitionException, TokenStreamException
{
+
+
+ match(SLASH);
+ match(GT);
+ append("/>");
+ htmlElementStack.pop();
+
+ }
+
+ public final void attributeValue() throws RecognitionException, TokenStreamException {
+
+ Token an = null;
+ Token p = null;
+ Token s = null;
+
+ try { // for error handling
+ {
+ _loop427:
+ do {
+ switch ( LA(1)) {
+ case AMPERSAND:
+ {
+ match(AMPERSAND);
+ append("&");
+ break;
+ }
+ case ALPHANUMERICWORD:
+ {
+ an = LT(1);
+ match(ALPHANUMERICWORD);
+ append( an.getText() );
+ break;
+ }
+ case PUNCTUATION:
+ {
+ p = LT(1);
+ match(PUNCTUATION);
+ append( p.getText() );
+ break;
+ }
+ case SLASH:
+ {
+ s = LT(1);
+ match(SLASH);
+ append( s.getText() );
+ break;
+ }
+ case SPACE:
+ {
+ space();
+ break;
+ }
+ case STAR:
+ case BAR:
+ case HAT:
+ case PLUS:
+ case EQ:
+ case HASH:
+ case ESCAPE:
+ case TWIDDLE:
+ case UNDERSCORE:
+ {
+ specialChars();
+ break;
+ }
+ default:
+ {
+ break _loop427;
+ }
+ }
+ } while (true);
+ }
+ }
+ catch (RecognitionException ex) {
+
+ if (htmlElementStack.isEmpty()) throw ex;
+ Token tok = htmlElementStack.peek();
+ if (tok != null) {
+ throw new HtmlRecognitionException(tok, ex);
+ } else {
+ throw ex;
+ }
+
+ }
+ }
+
+
+ public static final String[] _tokenNames = {
+ "<0>",
+ "the end of the text",
+ "<2>",
+ "NULL_TREE_LOOKAHEAD",
+ "letters or digits",
+ "letters or digits",
+ "a doublequote \\\"",
+ "ESCAPED_LT",
+ "ESCAPED_GT",
+ "ESCAPED_AMP",
+ "ESCAPED_QOUT",
+ "a punctuation character",
+ "a single quote '",
+ "a slash '/'",
+ "a star '*'",
+ "a bar or pipe '|'",
+ "a caret '^'",
+ "a plus '+'",
+ "an equals '='",
+ "a hash '#'",
+ "the escaping blackslash '\\'",
+ "a tilde '~'",
+ "an underscore '_'",
+ "an opening square bracket '['",
+ "a closing square bracket ']'",
+ "a backtick '`'",
+ "a closing angle bracket '>'",
+ "a space or tab",
+ "a newline",
+ "an opening angle bracket '<'",
+ "an ampersand '&'"
+ };
+
+ private static final long[] mk_tokenSet_0() {
+ long[] data = { 801112048L, 0L};
+ return data;
+ }
+ public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
+
+ }
Added:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/HtmlSeamTextParserTokenTypes.java
===================================================================
---
trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/HtmlSeamTextParserTokenTypes.java
(rev 0)
+++
trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/HtmlSeamTextParserTokenTypes.java 2008-10-30
10:04:25 UTC (rev 10975)
@@ -0,0 +1,35 @@
+// $ANTLR : "html-seamtext.g" -> "HtmlSeamTextLexer.java"$
+
+ package org.richfaces.antlr;
+
+public interface HtmlSeamTextParserTokenTypes {
+ int EOF = 1;
+ int NULL_TREE_LOOKAHEAD = 3;
+ int ALPHANUMERICWORD = 4;
+ int UNICODEWORD = 5;
+ int DOUBLEQUOTE = 6;
+ int ESCAPED_LT = 7;
+ int ESCAPED_GT = 8;
+ int ESCAPED_AMP = 9;
+ int ESCAPED_QOUT = 10;
+ int PUNCTUATION = 11;
+ int SINGLEQUOTE = 12;
+ int SLASH = 13;
+ int STAR = 14;
+ int BAR = 15;
+ int HAT = 16;
+ int PLUS = 17;
+ int EQ = 18;
+ int HASH = 19;
+ int ESCAPE = 20;
+ int TWIDDLE = 21;
+ int UNDERSCORE = 22;
+ int OPEN = 23;
+ int CLOSE = 24;
+ int BACKTICK = 25;
+ int GT = 26;
+ int SPACE = 27;
+ int NEWLINE = 28;
+ int LT = 29;
+ int AMPERSAND = 30;
+}