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 閱讀(412) 評論(0)  編輯  收藏 所屬分類: 項目筆記
          主站蜘蛛池模板: 普格县| 台前县| 彭阳县| 会东县| 北流市| 靖安县| 贵南县| 昭觉县| 灌云县| 安塞县| 彭泽县| 禹城市| 雅安市| 亚东县| 福贡县| 白山市| 维西| 额尔古纳市| 高唐县| 尚志市| 响水县| 连江县| 遵义市| 隆子县| 祁东县| 威远县| 南投市| 兴山县| 都江堰市| 墨玉县| 昂仁县| 交城县| 枞阳县| 剑川县| 车险| 金昌市| 新密市| 广丰县| 黑龙江省| 卫辉市| 滕州市|