posts - 18,  comments - 0,  trackbacks - 0

          class L extends Lexer;

          options {
           k=5;
           charVocabulary = '\u0000' .. '\uFFFE';
           testLiterals=false;
           caseSensitive = false;
           caseSensitiveLiterals = true;
          }

          ONE_ARG_OP
           : '~';
          TWO_ARG_OP
           : '&' | '|' | '^' | '+' | '-' | '/' | '%'; 
          STAR
           : '*';
          COMPARE_OP
           : '>' | '<' | ">=" | "<=" | "!=" | "<>" | "=";
          NOT_EXIST:
           "not exist";
          EXIST:
           "exist";
          COMMA
           : ',';
          SEMI: ';';
          POINT
           : '.';
          LPAREN
           : '(';
          RPAREN
           : ')';

          PARAM_LPAREN
           : '{';

          PARAM_RPAREN
           : '}';


          COLUMN
           : "column";
          WHERE
           : "where";

          WS : (' '|'\n'|'\r'|'\t')+ {$setType(Token.SKIP);}
              ;

          QUOTED_STRING
           : ('"'|'\'') (ESC|~('\''|'"'|'\\'|'\n'|'\r'))* ('"'|'\'')
           ;
          protected
          ESC
           : '\\'
            ( 'n'
            | 'r'
            | 't'
            | 'b'
            | 'f'
            | '"'
            | '\''
            | '\\'
            | '0'..'3'
             (
              options {
               warnWhenFollowAmbig = false;
              }
             : '0'..'7'
              (
               options {
                warnWhenFollowAmbig = false;
               }
              : '0'..'7'
              )?
             )?
            | '4'..'7'
             (
              options {
               warnWhenFollowAmbig = false;
              }
             : '0'..'7'
             )?
            )
           ;

          PARAM_ID
           : PARAM_LPAREN ID PARAM_RPAREN
           ;

          ID options {testLiterals=true;}
           : ID_START_LETTER ( ID_LETTER )*;

          protected
          ID_START_LETTER
              :    'a'..'z'
              | '_'
              |    '\u0080'..'\ufffe'
              ;
          protected
          ID_LETTER
              : ID_START_LETTER
              | '0'..'9'
              | '/'
              ;

          REAL_NUM
           : NUM (POINT DOT_NUM)?
           ;
          protected
          NUM : '0'
           | NUM_START (NUM_LETTER)*
           ;
          protected
          DOT_NUM
           : (NUM_LETTER)+
           ;
          protected
          NUM_START
           : '1'..'9'
           ;
          protected
          NUM_LETTER
           : '0'..'9'
           ;

          ML_COMMENT
           : "/*"
            ( /* '\r' '\n' can be matched in one alternative or by matching
              '\r' in one iteration and '\n' in another.  I am trying to
              handle any flavor of newline that comes in, but the language
              that allows both "\r\n" and "\r" and "\n" to all be valid
              newline is ambiguous.  Consequently, the resulting grammar
              must be ambiguous.  I'm shutting this warning off.
              */
             options {
              generateAmbigWarnings=false;
             }
            :
             { LA(2)!='/' }? '*'
            | '\r' '\n'  {newline();}
            | '\r'   {newline();}
            | '\n'   {newline();}
            | ~('*'|'\n'|'\r')
            )*
            "*/"
            {$setType(Token.SKIP);}
           ;

          posted on 2007-04-03 17:59 LORD BLOG 閱讀(417) 評論(0)  編輯  收藏 所屬分類: 項目筆記
          主站蜘蛛池模板: 临沧市| 育儿| 绥芬河市| 定襄县| 芮城县| 罗田县| 常州市| 连平县| 延长县| 竹北市| 赤城县| 垣曲县| 龙江县| 芦山县| 绿春县| 弥勒县| 兴业县| 新邵县| 徐闻县| 芜湖市| 阿拉善右旗| 牡丹江市| 曲周县| 洮南市| 秭归县| 尼勒克县| 香格里拉县| 玛纳斯县| 陆河县| 沙坪坝区| 土默特右旗| 手机| 水富县| 平谷区| 元谋县| 博客| 长治县| 镶黄旗| 三明市| 河池市| 江川县|