~ubuntu-branches/ubuntu/raring/weka/raring

« back to all changes in this revision

Viewing changes to build/classes/weka/core/parser/JFlex/LexScan.flex

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner, Soeren Sonnenburg, Torsten Werner
  • Date: 2008-08-10 21:27:05 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080810212705-tr8etpnkdx2ziktp
Tags: 3.5.8-1
[ Soeren Sonnenburg ]
* Bump Standards Version to 3.8.0.
* Remove references to non-free Java in debian/copyright.

[ Torsten Werner ]
* new upstream release
* Switch to openjdk-6.
* Move package to main.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 
2
 * JFlex 1.4.1                                                             *
 
3
 * Copyright (C) 1998-2004  Gerwin Klein <lsf@jflex.de>                    *
 
4
 * All rights reserved.                                                    *
 
5
 *                                                                         *
 
6
 * This program is free software; you can redistribute it and/or modify    *
 
7
 * it under the terms of the GNU General Public License. See the file      *
 
8
 * COPYRIGHT for more information.                                         *
 
9
 *                                                                         *
 
10
 * This program is distributed in the hope that it will be useful,         *
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
 
13
 * GNU General Public License for more details.                            *
 
14
 *                                                                         *
 
15
 * You should have received a copy of the GNU General Public License along *
 
16
 * with this program; if not, write to the Free Software Foundation, Inc., *
 
17
 * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                 *
 
18
 *                                                                         *
 
19
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
20
 
 
21
package JFlex;
 
22
 
 
23
import java_cup.runtime.Symbol;
 
24
import java.util.Vector;
 
25
import java.io.*;
 
26
import java.util.Stack;
 
27
 
 
28
/**
 
29
 * The lexer of JFlex.
 
30
 *
 
31
 * Generated by <a href="http://www.jflex.de/">JFlex</a>.
 
32
 *
 
33
 * @author Gerwin Klein
 
34
 * @version JFlex 1.4.1, $Revision: 1.1 $, $Date: 2008/05/09 09:14:10 $
 
35
 */
 
36
%%
 
37
 
 
38
%final
 
39
%public
 
40
%class LexScan
 
41
%implements sym, java_cup.runtime.Scanner
 
42
%function next_token
 
43
 
 
44
%type Symbol
 
45
%unicode
 
46
 
 
47
%column
 
48
%line
 
49
 
 
50
%eofclose
 
51
 
 
52
%state COMMENT, STATELIST, MACROS, REGEXPSTART
 
53
%state REGEXP, JAVA_CODE, STATES, STRING_CONTENT
 
54
%state CHARCLASS, COPY, REPEATEXP, EATWSPNL
 
55
 
 
56
%cupdebug
 
57
 
 
58
%{  
 
59
  int balance = 0;
 
60
  int commentbalance = 0;
 
61
  int action_line = 0;
 
62
  int bufferSize = 16384;
 
63
 
 
64
  File file;
 
65
  Stack files = new Stack();
 
66
 
 
67
  StringBuffer userCode   = new StringBuffer();
 
68
  
 
69
  String classCode;
 
70
  String initCode;   
 
71
  String initThrow;
 
72
  String eofCode;
 
73
  String eofThrow;
 
74
  String lexThrow;
 
75
  String eofVal;
 
76
  String scanErrorException;
 
77
  String cupSymbol = "sym";
 
78
 
 
79
  StringBuffer actionText = new StringBuffer();
 
80
  StringBuffer string     = new StringBuffer();
 
81
  
 
82
  boolean charCount;
 
83
  boolean lineCount;
 
84
  boolean columnCount;
 
85
  boolean cupCompatible;  
 
86
  boolean cupDebug;
 
87
  boolean isInteger;
 
88
  boolean isIntWrap;
 
89
  boolean isYYEOF;
 
90
  boolean notUnix;
 
91
  boolean isPublic;
 
92
  boolean isFinal;
 
93
  boolean isAbstract;
 
94
  boolean lookAheadUsed;
 
95
  boolean bolUsed;
 
96
  boolean standalone;
 
97
  boolean debugOption;
 
98
  boolean useRowMap = Options.gen_method == Options.PACK || Options.gen_method == Options.TABLE;
 
99
  boolean packed = Options.gen_method == Options.PACK;
 
100
  boolean caseless;
 
101
  boolean inclusive_states;
 
102
  boolean eofclose;
 
103
    
 
104
  String isImplementing;
 
105
  String isExtending;
 
106
  String className = "Yylex";
 
107
  String functionName;
 
108
  String tokenType;
 
109
  String visibility = "public";
 
110
    
 
111
  LexicalStates states = new LexicalStates();
 
112
 
 
113
  Vector actions = new Vector();
 
114
  
 
115
  private int nextState;
 
116
 
 
117
  boolean macroDefinition;
 
118
 
 
119
  Timer t = new Timer();
 
120
 
 
121
  public int currentLine() {
 
122
    return yyline;
 
123
  }    
 
124
 
 
125
  public void setFile(File file) {
 
126
    this.file = file;
 
127
  }
 
128
 
 
129
  private Symbol symbol(int type, Object value) {
 
130
    return new Symbol(type, yyline, yycolumn, value);
 
131
  }
 
132
 
 
133
  private Symbol symbol(int type) {
 
134
    return new Symbol(type, yyline, yycolumn);
 
135
  }
 
136
   
 
137
  // updates line and column count to the beginning of the first
 
138
  // non whitespace character in yytext, but leaves yyline+yycolumn 
 
139
  // untouched
 
140
  private Symbol symbol_countUpdate(int type, Object value) {
 
141
     int lc = yyline;
 
142
     int cc = yycolumn;
 
143
     String text = yytext();
 
144
 
 
145
     for (int i=0; i < text.length(); i++) {
 
146
      char c = text.charAt(i);
 
147
 
 
148
      if (c != '\n' && c != '\r' && c != ' ' && c != '\t' ) 
 
149
        return new Symbol(type, lc, cc, value);
 
150
 
 
151
      if (c == '\n') {
 
152
        lc++;
 
153
        cc = 0;
 
154
      }
 
155
      else
 
156
        cc++;
 
157
    }
 
158
   
 
159
    return new Symbol(type, yyline, yycolumn, value);
 
160
  }
 
161
 
 
162
  private String makeMacroIdent() {
 
163
    String matched = yytext().trim();
 
164
    return matched.substring(1, matched.length()-1).trim();
 
165
  }
 
166
 
 
167
  public static String conc(Object a, Object b) {
 
168
    if (a == null && b == null) return null;
 
169
    if (a == null) return b.toString();
 
170
    if (b == null) return a.toString();
 
171
    
 
172
    return a.toString()+b.toString();
 
173
  }
 
174
 
 
175
  public static String concExc(Object a, Object b) {
 
176
    if (a == null && b == null) return null;
 
177
    if (a == null) return b.toString();
 
178
    if (b == null) return a.toString();
 
179
    
 
180
    return a.toString()+", "+b.toString();
 
181
  }
 
182
%}
 
183
 
 
184
%init{
 
185
  states.insert("YYINITIAL", true);
 
186
%init}
 
187
 
 
188
 
 
189
Digit      = [0-9]
 
190
HexDigit   = [0-9a-fA-F]
 
191
OctDigit   = [0-7]
 
192
 
 
193
Number     = {Digit}+
 
194
HexNumber  = \\ x {HexDigit} {2}
 
195
Unicode    = \\ u {HexDigit} {1, 4}
 
196
OctNumber  = \\ [0-3]? {OctDigit} {1, 2}  
 
197
 
 
198
// see http://www.unicode.org/unicode/reports/tr18/
 
199
WSP        = [ \t\b]
 
200
WSPNL      = [\u2028\u2029\u000A\u000B\u000C\u000D\u0085\t\b\ ]
 
201
NL         = [\u2028\u2029\u000A\u000B\u000C\u000D\u0085] | \u000D\u000A
 
202
NNL        = [^\u2028\u2029\u000A\u000B\u000C\u000D\u0085]
 
203
 
 
204
Ident      = {IdentStart} {IdentPart}*
 
205
QualIdent  = {Ident} ( {WSP}* "." {WSP}* {Ident} )*
 
206
QUIL       = {QualIdent} ( {WSP}* "," {WSP}* {QualIdent} )*
 
207
Array      = "[" {WSP}* "]"
 
208
ArrType    = {QualIdent} ({WSP}* {Array})*
 
209
 
 
210
IdentStart = [:jletter:]
 
211
IdentPart  = [:jletterdigit:]
 
212
 
 
213
JFlexCommentChar = [^*/]|"/"+[^*/]|"*"+[^*/]
 
214
JFlexComment = {JFlexCommentChar}*
 
215
 
 
216
/* Java comments */
 
217
JavaComment = {TraditionalComment}|{EndOfLineComment}
 
218
TraditionalComment = "/*"{CommentContent}\*+"/"
 
219
EndOfLineComment = "//".*{NL}
 
220
 
 
221
CommentContent = ([^*]|\*+[^*/])*
 
222
 
 
223
StringCharacter = [^\u2028\u2029\u000A\u000B\u000C\u000D\u0085\"\\]
 
224
 
 
225
CharLiteral = \'([^\u2028\u2029\u000A\u000B\u000C\u000D\u0085\'\\]|{EscapeSequence})\'
 
226
StringLiteral = \"({StringCharacter}|{EscapeSequence})*\"
 
227
 
 
228
EscapeSequence = \\[^\u2028\u2029\u000A\u000B\u000C\u000D\u0085]|\\+u{HexDigit}{4}|\\[0-3]?{OctDigit}{1,2}
 
229
 
 
230
/* \\(b|t|n|f|r|\"|\'|\\|[0-3]?{OctDigit}{1,2}|u{HexDigit}{4}) */
 
231
 
 
232
JavaRest = [^\{\}\"\'/]|"/"[^*/]      
 
233
JavaCode = ({JavaRest}|{StringLiteral}|{CharLiteral}|{JavaComment})+
 
234
 
 
235
%%
 
236
 
 
237
<YYINITIAL> {
 
238
  "%%".*{NL}?              { 
 
239
                             t.start(); 
 
240
                             yybegin(MACROS); 
 
241
                             macroDefinition = true; 
 
242
                             return symbol(USERCODE,userCode); 
 
243
                           }
 
244
  .*{NL}                   { userCode.append(yytext()); }            
 
245
  .*                       { return symbol(EOF); }
 
246
}
 
247
 
 
248
<MACROS>   ("%{"|"%init{"|"%initthrow{"|"%eof{"|"%eofthrow{"|"%yylexthrow{"|"%eofval{").*{NL}
 
249
                                     { string.setLength(0); yybegin(COPY); }
 
250
<COPY> {
 
251
  "%}".*{NL}                    { classCode = conc(classCode,string);  yybegin(MACROS);  }
 
252
  "%init}".*{NL}                { initCode = conc(initCode,string);    yybegin(MACROS);  }
 
253
  "%initthrow}".*{NL}           { initThrow = concExc(initThrow,string);  yybegin(MACROS); }
 
254
  "%eof}".*{NL}                 { eofCode = conc(eofCode,string); yybegin(MACROS); }
 
255
  "%eofthrow}".*{NL}            { eofThrow = concExc(eofThrow,string); yybegin(MACROS); }
 
256
  "%yylexthrow}".*{NL}          { lexThrow = concExc(lexThrow,string); yybegin(MACROS); }
 
257
  "%eofval}".*{NL}              { eofVal = string.toString(); yybegin(MACROS); }
 
258
 
 
259
  .*{NL}                        { string.append(yytext()); }
 
260
 
 
261
  <<EOF>>                       { throw new ScannerException(file,ErrorMessages.EOF_IN_MACROS); }
 
262
}
 
263
 
 
264
 
 
265
<MACROS> ^"%s" ("tate" "s"?)? {WSP}+   { inclusive_states = true; yybegin(STATELIST); }
 
266
<MACROS> ^"%x" ("state" "s"?)? {WSP}+  { inclusive_states = false; yybegin(STATELIST); }
 
267
<STATELIST> {
 
268
  {Ident}                             { states.insert(yytext(),inclusive_states); }
 
269
  ([\ \t]*","[\ \t]*)|([\ \t]+)       { }
 
270
  {NL}                                { yybegin(MACROS);  }
 
271
  <<EOF>>                       { throw new ScannerException(file,ErrorMessages.EOF_IN_MACROS); }
 
272
}
 
273
 
 
274
<MACROS> {
 
275
  "%char"                     { charCount = true;  }
 
276
  "%line"                     { lineCount = true;  }
 
277
  "%column"                   { columnCount = true; }
 
278
  "%byaccj"                   { isInteger = true;
 
279
                                if (eofVal == null)
 
280
                                  eofVal = "return 0;";
 
281
                                eofclose = true;
 
282
                              }
 
283
  "%cup"                      { cupCompatible = true;  
 
284
                                isImplementing = concExc(isImplementing, "java_cup.runtime.Scanner");
 
285
                                if (functionName == null)
 
286
                                  functionName = "next_token";
 
287
                                if (tokenType == null)
 
288
                                  tokenType = "java_cup.runtime.Symbol";
 
289
                                if (eofVal == null)
 
290
                                  eofVal = "return new java_cup.runtime.Symbol("+cupSymbol+".EOF);";
 
291
                                if (!Options.jlex) eofclose = true;
 
292
                              }
 
293
  "%cupsym"{WSP}+{QualIdent} {WSP}*  { cupSymbol = yytext().substring(8).trim(); 
 
294
                                if (cupCompatible) Out.warning(ErrorMessages.CUPSYM_AFTER_CUP, yyline); }
 
295
  "%cupsym"{WSP}+{NNL}*       { throw new ScannerException(file,ErrorMessages.QUIL_CUPSYM, yyline); }
 
296
  "%cupdebug"                 { cupDebug = true; }
 
297
  "%eofclose"({WSP}+"true")?  { eofclose = true; }
 
298
  "%eofclose"({WSP}+"false")  { eofclose = false; }
 
299
  "%class"{WSP}+{Ident} {WSP}*      { className = yytext().substring(7).trim();  }
 
300
  "%function"{WSP}+{Ident} {WSP}*   { functionName = yytext().substring(10).trim(); }
 
301
  "%type"{WSP}+{ArrType} {WSP}*     { tokenType = yytext().substring(6).trim(); }
 
302
  "%integer"|"%int"           { isInteger = true;  }
 
303
  "%intwrap"                  { isIntWrap = true;  }
 
304
  "%yyeof"                    { isYYEOF = true;  }
 
305
  "%notunix"                  { notUnix = true;  }
 
306
  "%7bit"                     {  }
 
307
  "%full"|"%8bit"             { return symbol(FULL); }
 
308
  "%unicode"|"%16bit"         { return symbol(UNICODE);  }
 
309
  "%caseless"|"%ignorecase"   { caseless = true; }
 
310
  "%implements"{WSP}+.*       { isImplementing = concExc(isImplementing, yytext().substring(12).trim());  }
 
311
  "%extends"{WSP}+{QualIdent}{WSP}* { isExtending = yytext().substring(9).trim(); }
 
312
  "%public"                   { isPublic = true; }
 
313
  "%apiprivate"               { visibility = "private"; Skeleton.makePrivate(); }
 
314
  "%final"                    { isFinal = true; }
 
315
  "%abstract"                 { isAbstract = true; }
 
316
  "%debug"                    { debugOption = true; }
 
317
  "%standalone"               { standalone = true; isInteger = true; }
 
318
  "%switch"                   { packed = false; useRowMap = false; }
 
319
  "%table"                    { packed = false; useRowMap = true; }
 
320
  "%pack"                     { packed = true; useRowMap = true; }
 
321
  "%include" {WSP}+ .*        { File f = new File(yytext().substring(9).trim());
 
322
                                if ( !f.canRead() )
 
323
                                  throw new ScannerException(file,ErrorMessages.NOT_READABLE, yyline); 
 
324
                                // check for cycle
 
325
                                if (files.search(f) > 0)
 
326
                                  throw new ScannerException(file,ErrorMessages.FILE_CYCLE, yyline);
 
327
                                try {
 
328
                                  yypushStream( new FileReader(f) );
 
329
                                  files.push(file);
 
330
                                  file = f;
 
331
                                  Out.println("Including \""+file+"\"");
 
332
                                }
 
333
                                catch (FileNotFoundException e) {
 
334
                                  throw new ScannerException(file,ErrorMessages.NOT_READABLE, yyline); 
 
335
                                } 
 
336
                              }
 
337
  "%buffer" {WSP}+ {Number} {WSP}*   { bufferSize = Integer.parseInt(yytext().substring(8).trim()); }
 
338
  "%buffer" {WSP}+ {NNL}*     { throw new ScannerException(file,ErrorMessages.NO_BUFFER_SIZE, yyline); }
 
339
  "%initthrow" {WSP}+ {QUIL} {WSP}* { initThrow = concExc(initThrow,yytext().substring(11).trim()); }
 
340
  "%initthrow" {WSP}+ {NNL}*  { throw new ScannerException(file,ErrorMessages.QUIL_INITTHROW, yyline); }
 
341
  "%eofthrow"  {WSP}+ {QUIL} {WSP}*  { eofThrow = concExc(eofThrow,yytext().substring(10).trim()); }
 
342
  "%eofthrow"  {WSP}+ {NNL}*  { throw new ScannerException(file,ErrorMessages.QUIL_EOFTHROW, yyline); }
 
343
  "%yylexthrow"{WSP}+ {QUIL} {WSP}*  { lexThrow = concExc(lexThrow,yytext().substring(12).trim()); }
 
344
  "%throws"    {WSP}+ {QUIL} {WSP}*  { lexThrow = concExc(lexThrow,yytext().substring(8).trim()); }
 
345
  "%yylexthrow"{WSP}+ {NNL}*  { throw new ScannerException(file,ErrorMessages.QUIL_YYLEXTHROW, yyline); }
 
346
  "%throws"    {WSP}+ {NNL}*  { throw new ScannerException(file,ErrorMessages.QUIL_THROW, yyline); }
 
347
  "%scanerror" {WSP}+ {QualIdent} {WSP}* { scanErrorException = yytext().substring(11).trim(); }
 
348
  "%scanerror" {WSP}+ {NNL}*  { throw new ScannerException(file,ErrorMessages.QUIL_SCANERROR, yyline); }
 
349
 
 
350
  {Ident}                     { return symbol(IDENT, yytext()); }
 
351
  "="{WSP}*                   { yybegin(REGEXP); return symbol(EQUALS); }
 
352
 
 
353
  "/*"                        { nextState = MACROS; yybegin(COMMENT); }
 
354
  
 
355
  {EndOfLineComment}          { }
 
356
 
 
357
  /* no {NL} at the end of this expression, because <REGEXPSTART> 
 
358
     needs at least one {WSPNL} to start a regular expression! */   
 
359
  ^"%%" {NNL}*                { macroDefinition = false; yybegin(REGEXPSTART); return symbol(DELIMITER); }
 
360
  "%"{Ident}                  { throw new ScannerException(file,ErrorMessages.UNKNOWN_OPTION, yyline, yycolumn); }
 
361
  "%"                         { throw new ScannerException(file,ErrorMessages.UNKNOWN_OPTION, yyline, yycolumn); }
 
362
  ^{WSP}+"%"                  { Out.warning(ErrorMessages.NOT_AT_BOL, yyline); yypushback(1); }
 
363
 
 
364
  {WSP}+                      { }
 
365
  {NL}+                       { }                        
 
366
  <<EOF>>                     { if ( yymoreStreams() ) {
 
367
                                  file = (File) files.pop();
 
368
                                  yypopStream();
 
369
                                }
 
370
                                else
 
371
                                  throw new ScannerException(file,ErrorMessages.EOF_IN_MACROS); 
 
372
                              }
 
373
}
 
374
 
 
375
<REGEXPSTART> {
 
376
  {WSPNL}* "/*"               { nextState = REGEXPSTART; yybegin(COMMENT); }
 
377
  {WSPNL}+                    { yybegin(REGEXP); }
 
378
  {WSPNL}* "<"                { yybegin(STATES); return symbol_countUpdate(LESSTHAN, null); }
 
379
  {WSPNL}* "}"                { return symbol_countUpdate(RBRACE, null); }
 
380
  {WSPNL}* "//" {NNL}*        { }  
 
381
  {WSPNL}* "<<EOF>>" {WSPNL}* "{" 
 
382
                              { actionText.setLength(0); yybegin(JAVA_CODE); 
 
383
                                Symbol s = symbol_countUpdate(EOFRULE, null);
 
384
                                action_line = s.left+1; 
 
385
                                return s;
 
386
                              }
 
387
}
 
388
 
 
389
<STATES> {
 
390
  {Ident}                     { return symbol(IDENT, yytext()); }
 
391
  ","                         { return symbol(COMMA); }
 
392
  {WSPNL}+                    { }
 
393
 
 
394
  // "{" will be caught in REGEXP  
 
395
  ">"{WSPNL}*                 { yybegin(REGEXP); return symbol(MORETHAN); }
 
396
 
 
397
  <<EOF>>                     { throw new ScannerException(file,ErrorMessages.EOF_IN_STATES); }
 
398
}
 
399
 
 
400
 
 
401
<REGEXP> {
 
402
  "<<EOF>>" {WSPNL}+ "{"  { actionText.setLength(0); yybegin(JAVA_CODE); action_line = yyline+1; return symbol(EOFRULE); }
 
403
  "<<EOF>>"               { throw new ScannerException(file,ErrorMessages.EOF_WO_ACTION); }
 
404
 
 
405
  {WSPNL}*"|"{WSP}*$      { if (macroDefinition) {
 
406
                              yybegin(EATWSPNL);
 
407
                              return symbol(BAR); 
 
408
                            }
 
409
                            else { 
 
410
                              yybegin(REGEXPSTART); 
 
411
                              return symbol(NOACTION); 
 
412
                            }
 
413
                          }
 
414
 
 
415
  // stategroup
 
416
  "{"          { yybegin(REGEXPSTART); return symbol(LBRACE); }
 
417
 
 
418
  {WSPNL}*"|"  { return symbol(BAR); }
 
419
 
 
420
  {WSPNL}*\"   { string.setLength(0); nextState = REGEXP; yybegin(STRING_CONTENT); }
 
421
  {WSPNL}*"!"  { return symbol(BANG); }
 
422
  {WSPNL}*"~"  { return symbol(TILDE); }
 
423
  {WSPNL}*"("  { return symbol(OPENBRACKET); }
 
424
  {WSPNL}*")"  { return symbol(CLOSEBRACKET); }
 
425
  {WSPNL}*"*"  { return symbol(STAR); }
 
426
  {WSPNL}*"+"  { return symbol(PLUS); }
 
427
  {WSPNL}*"?"  { return symbol(QUESTION); }
 
428
  {WSPNL}*"$"  { lookAheadUsed = true; return symbol(DOLLAR); }
 
429
  {WSPNL}*"^"  { bolUsed = true; return symbol(HAT); }
 
430
  {WSPNL}*"."  { return symbol(POINT); }
 
431
  {WSPNL}*"["  { yybegin(CHARCLASS); return symbol(OPENCLASS); }
 
432
  {WSPNL}*"/"  { lookAheadUsed = true; return symbol(LOOKAHEAD); }
 
433
  
 
434
  {WSPNL}* "{" {WSP}* {Ident} {WSP}* "}" { return symbol_countUpdate(MACROUSE, makeMacroIdent()); }
 
435
  {WSPNL}* "{" {WSP}* {Number}   { yybegin(REPEATEXP); return symbol(REPEAT, new Integer(yytext().trim().substring(1).trim())); }
 
436
 
 
437
  {WSPNL}+ "{"    { actionText.setLength(0); yybegin(JAVA_CODE); action_line = yyline+1; return symbol(REGEXPEND); }
 
438
  {NL}            { if (macroDefinition) { yybegin(MACROS); } return symbol(REGEXPEND); }
 
439
 
 
440
  {WSPNL}*"/*"    { nextState = REGEXP; yybegin(COMMENT); }
 
441
 
 
442
  {WSPNL}*"//"{NNL}*  { }
 
443
 
 
444
  {WSP}+          { }
 
445
 
 
446
  <CHARCLASS> {
 
447
    {WSPNL}*"[:jletter:]"  { return symbol(JLETTERCLASS); }
 
448
    {WSPNL}*"[:jletterdigit:]" { return symbol(JLETTERDIGITCLASS); }
 
449
    {WSPNL}*"[:letter:]"     { return symbol(LETTERCLASS); }
 
450
    {WSPNL}*"[:digit:]"      { return symbol(DIGITCLASS); }
 
451
    {WSPNL}*"[:uppercase:]"  { return symbol(UPPERCLASS); }
 
452
    {WSPNL}*"[:lowercase:]"  { return symbol(LOWERCLASS); }
 
453
  }
 
454
 
 
455
  . { return symbol(CHAR, new Character(yytext().charAt(0))); }
 
456
}
 
457
 
 
458
<EATWSPNL> {WSPNL}+  { yybegin(REGEXP); }
 
459
 
 
460
 
 
461
<REPEATEXP> {
 
462
  "}"          { yybegin(REGEXP); return symbol(RBRACE); }
 
463
  "," {WSP}* {Number}  { return symbol(REPEAT, new Integer(yytext().substring(1).trim())); }
 
464
  {WSP}+       { }
 
465
 
 
466
  <<EOF>>                 { throw new ScannerException(file,ErrorMessages.EOF_IN_REGEXP); }
 
467
}
 
468
 
 
469
<CHARCLASS> {
 
470
  "{"{Ident}"}" { return symbol(MACROUSE, yytext().substring(1,yytext().length()-1)); }
 
471
  "["  { balance++; return symbol(OPENCLASS); }
 
472
  "]"  { if (balance > 0) balance--; else yybegin(REGEXP); return symbol(CLOSECLASS); }
 
473
  "^"  { return symbol(HAT); }
 
474
  "-"  { return symbol(DASH); }
 
475
 
 
476
  // this is a hack to keep JLex compatibilty with char class 
 
477
  // expressions like [+-]
 
478
  "-]" { yypushback(1); yycolumn--; return symbol(CHAR, new Character(yytext().charAt(0))); }  
 
479
 
 
480
  \"   { string.setLength(0); nextState = CHARCLASS; yybegin(STRING_CONTENT); }
 
481
 
 
482
  .    { return symbol(CHAR, new Character(yytext().charAt(0))); }
 
483
 
 
484
  \n   { throw new ScannerException(file,ErrorMessages.EOL_IN_CHARCLASS,yyline,yycolumn); }
 
485
 
 
486
  <<EOF>>     { throw new ScannerException(file,ErrorMessages.EOF_IN_REGEXP); }
 
487
}
 
488
 
 
489
<STRING_CONTENT> {
 
490
  \"       { yybegin(nextState); return symbol(STRING, string.toString()); }
 
491
  \\\"     { string.append('\"'); }
 
492
  [^\"\\\u2028\u2029\u000A\u000B\u000C\u000D\u0085]+ { string.append(yytext()); }
 
493
 
 
494
  {NL}     { throw new ScannerException(file,ErrorMessages.UNTERMINATED_STR, yyline, yycolumn); }
 
495
 
 
496
  {HexNumber} { string.append( (char) Integer.parseInt(yytext().substring(2,yytext().length()), 16)); }
 
497
  {Unicode}   { string.append( (char) Integer.parseInt(yytext().substring(2,yytext().length()), 16)); }
 
498
  {OctNumber} { string.append( (char) Integer.parseInt(yytext().substring(1,yytext().length()), 8)); }
 
499
 
 
500
  \\b { string.append('\b'); }
 
501
  \\n { string.append('\n'); }
 
502
  \\t { string.append('\t'); }
 
503
  \\f { string.append('\f'); }
 
504
  \\r { string.append('\r'); }
 
505
 
 
506
  \\. { string.append(yytext().charAt(1)); }
 
507
 
 
508
  <<EOF>>     { throw new ScannerException(file,ErrorMessages.EOF_IN_STRING); }
 
509
}
 
510
 
 
511
 
 
512
<REGEXP, CHARCLASS> {
 
513
  {HexNumber} { return symbol(CHAR, new Character( (char) Integer.parseInt(yytext().substring(2,yytext().length()), 16))); }
 
514
  {Unicode} { return symbol(CHAR, new Character( (char) Integer.parseInt(yytext().substring(2,yytext().length()), 16))); }
 
515
  {OctNumber} { return symbol(CHAR, new Character( (char) Integer.parseInt(yytext().substring(1,yytext().length()), 8))); }
 
516
 
 
517
  \\b { return symbol(CHAR,new Character('\b')); }
 
518
  \\n { return symbol(CHAR,new Character('\n')); }
 
519
  \\t { return symbol(CHAR,new Character('\t')); }
 
520
  \\f { return symbol(CHAR,new Character('\f')); }
 
521
  \\r { return symbol(CHAR,new Character('\r')); }
 
522
 
 
523
  \\. { return symbol(CHAR, new Character(yytext().charAt(1))); }
 
524
}
 
525
 
 
526
 
 
527
<JAVA_CODE> {
 
528
  "{"        { balance++; actionText.append('{'); }
 
529
  "}"        { if (balance > 0) {
 
530
                 balance--;     
 
531
                 actionText.append('}'); 
 
532
               }
 
533
               else {
 
534
                 yybegin(REGEXPSTART); 
 
535
                 Action a = new Action(actionText.toString(), action_line);
 
536
                 actions.addElement(a);
 
537
                 return symbol(ACTION, a);
 
538
               }
 
539
             } 
 
540
           
 
541
  {JavaCode}     { actionText.append(yytext()); } 
 
542
 
 
543
  <<EOF>>     { throw new ScannerException(file,ErrorMessages.EOF_IN_ACTION, action_line-1); }
 
544
}
 
545
 
 
546
<COMMENT> {
 
547
   
 
548
  "/"+ "*"  { commentbalance++; }
 
549
  "*"+ "/"  { if (commentbalance > 0) 
 
550
                commentbalance--; 
 
551
              else
 
552
                yybegin(nextState); 
 
553
            }
 
554
  
 
555
  {JFlexComment} { /* ignore */ }
 
556
 
 
557
  <<EOF>>     { throw new ScannerException(file,ErrorMessages.EOF_IN_COMMENT); }
 
558
}
 
559
 
 
560
 
 
561
.  { throw new ScannerException(file,ErrorMessages.UNEXPECTED_CHAR, yyline, yycolumn); }
 
562
\n { throw new ScannerException(file,ErrorMessages.UNEXPECTED_NL, yyline, yycolumn); }
 
563
 
 
564
<<EOF>>  { if ( yymoreStreams() ) {
 
565
             file = (File) files.pop();
 
566
             yypopStream();
 
567
           }
 
568
           else 
 
569
             return symbol(EOF); }