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

« back to all changes in this revision

Viewing changes to build/classes/build/classes/build/classes/weka/core/parser/java_cup/Lexer.jflex

  • 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
 * STANDARD ML OF NEW JERSEY COPYRIGHT NOTICE, LICENSE AND DISCLAIMER.
 
3
 * 
 
4
 * Copyright (c) 1989-1998 by Lucent Technologies
 
5
 * 
 
6
 * Permission to use, copy, modify, and distribute this software and its
 
7
 * documentation for any purpose and without fee is hereby granted, provided
 
8
 * that the above copyright notice appear in all copies and that both the
 
9
 * copyright notice and this permission notice and warranty disclaimer appear
 
10
 * in supporting documentation, and that the name of Lucent Technologies, Bell
 
11
 * Labs or any Lucent entity not be used in advertising or publicity pertaining
 
12
 * to distribution of the software without specific, written prior permission.
 
13
 *
 
14
 * Lucent disclaims all warranties with regard to this software, including all
 
15
 * implied warranties of merchantability and fitness. In no event shall Lucent
 
16
 * be liable for any special, indirect or consequential damages or any damages
 
17
 * whatsoever resulting from loss of use, data or profits, whether in an action
 
18
 * of contract, negligence or other tortious action, arising out of or in
 
19
 * connection with the use or performance of this software. 
 
20
 *
 
21
 * Taken from this URL:
 
22
 * http://www.smlnj.org/license.html
 
23
 * 
 
24
 * This license is compatible with the GNU GPL (see section "Standard ML of New
 
25
 * Jersey Copyright License"):
 
26
 * http://www.gnu.org/licenses/license-list.html#StandardMLofNJ
 
27
 */
 
28
 
 
29
/*
 
30
 * Copyright 1996-1999 by Scott Hudson, Frank Flannery, C. Scott Ananian
 
31
 */
 
32
 
 
33
package weka.core.parser.java_cup;
 
34
 
 
35
import weka.core.parser.java_cup.runtime.ComplexSymbolFactory;
 
36
import weka.core.parser.java_cup.runtime.ComplexSymbolFactory.Location;
 
37
import weka.core.parser.java_cup.runtime.Symbol;
 
38
import java.lang.Error;
 
39
import java.io.InputStreamReader;
 
40
 
 
41
%%
 
42
 
 
43
%class Lexer
 
44
%implements sym
 
45
%public
 
46
%unicode
 
47
%line
 
48
%column
 
49
%cup
 
50
%{
 
51
    public Lexer(ComplexSymbolFactory sf){
 
52
        this(new InputStreamReader(System.in));
 
53
        symbolFactory = sf;
 
54
    }
 
55
    private StringBuffer sb;
 
56
    private ComplexSymbolFactory symbolFactory;
 
57
    private int csline,cscolumn;
 
58
    public Symbol symbol(String name, int code){
 
59
//      System.out.println("code:"+code+" "+yytext());
 
60
        return symbolFactory.newSymbol(name, code,new Location(yyline+1,yycolumn+1-yylength()),new Location(yyline+1,yycolumn+1));
 
61
    }
 
62
    public Symbol symbol(String name, int code, String lexem){
 
63
//      System.out.println("code:"+code+", lexem :"+lexem);
 
64
        return symbolFactory.newSymbol(name, code, new Location(yyline+1, yycolumn +1), new Location(yyline+1,yycolumn+yylength()), lexem);
 
65
    }
 
66
    protected void emit_warning(String message){
 
67
        ErrorManager.getManager().emit_warning("Scanner at " + (yyline+1) + "(" + (yycolumn+1) + "): " + message);
 
68
    }
 
69
    protected void emit_error(String message){
 
70
        ErrorManager.getManager().emit_error("Scanner at " + (yyline+1) + "(" + (yycolumn+1) +  "): " + message);
 
71
    }
 
72
%}
 
73
 
 
74
Newline = \r | \n | \r\n
 
75
Whitespace = [ \t\f] | {Newline}
 
76
 
 
77
/* comments */
 
78
Comment = {TraditionalComment} | {EndOfLineComment}
 
79
TraditionalComment = "/*" {CommentContent} \*+ "/"
 
80
EndOfLineComment = "//" [^\r\n]* {Newline}
 
81
CommentContent = ( [^*] | \*+[^*/] )*
 
82
 
 
83
ident = ([:jletter:] | "_" ) ([:jletterdigit:] | [:jletter:] | "_" )*
 
84
 
 
85
 
 
86
%eofval{
 
87
    return symbolFactory.newSymbol("EOF",sym.EOF);
 
88
%eofval}
 
89
 
 
90
%state CODESEG
 
91
 
 
92
%%  
 
93
 
 
94
<YYINITIAL> {
 
95
 
 
96
  {Whitespace}  {                                              }
 
97
  "?"           { return symbol("QESTION",QUESTION);           }
 
98
  ";"           { return symbol("SEMI",SEMI);                  }
 
99
  ","           { return symbol("COMMA",COMMA);                }
 
100
  "*"           { return symbol("STAR",STAR);                  }
 
101
  "."           { return symbol("DOT",DOT);                    }
 
102
  "|"           { return symbol("BAR",BAR);                    }
 
103
  "["           { return symbol("LBRACK",LBRACK);              }
 
104
  "]"           { return symbol("RBRACK",RBRACK);              }
 
105
  ":"           { return symbol("COLON",COLON);                }
 
106
  "::="         { return symbol("COLON_COLON_EQUALS",COLON_COLON_EQUALS);   }
 
107
  "%prec"       { return symbol("PERCENT_PREC",PERCENT_PREC);  }
 
108
  ">"           { return symbol("GT",GT);                      }
 
109
  "<"           { return symbol("LT",LT);                      }
 
110
  {Comment}     {                                              }
 
111
  "{:"          { sb = new StringBuffer(); csline=yyline+1; cscolumn=yycolumn+1; yybegin(CODESEG);    }
 
112
  "package"     { return symbol("PACKAGE",PACKAGE);            } 
 
113
  "import"      { return symbol("IMPORT",IMPORT);              }
 
114
  "code"        { return symbol("CODE",CODE);                  }
 
115
  "action"      { return symbol("ACTION",ACTION);              }
 
116
  "parser"      { return symbol("PARSER",PARSER);              }
 
117
  "terminal"    { return symbol("PARSER",TERMINAL);            }
 
118
  "non"         { return symbol("NON",NON);                    }
 
119
  "nonterminal" { return symbol("NONTERMINAL",NONTERMINAL);    }
 
120
  "init"        { return symbol("INIT",INIT);                  }
 
121
  "scan"        { return symbol("SCAN",SCAN);                  }
 
122
  "with"        { return symbol("WITH",WITH);                  }
 
123
  "start"       { return symbol("START",START);                }
 
124
  "precedence"  { return symbol("PRECEDENCE",PRECEDENCE);      }
 
125
  "left"        { return symbol("LEFT",LEFT);                  }
 
126
  "right"       { return symbol("RIGHT",RIGHT);                }
 
127
  "nonassoc"    { return symbol("NONASSOC",NONASSOC);          }
 
128
  "extends"     { return symbol("EXTENDS",EXTENDS);            }
 
129
  "super"       { return symbol("SUPER",SUPER);                }
 
130
  {ident}       { return symbol("ID",ID,yytext());             }
 
131
  
 
132
}
 
133
 
 
134
<CODESEG> {
 
135
  ":}"         { yybegin(YYINITIAL); return symbolFactory.newSymbol("CODE_STRING",CODE_STRING, new Location(csline, cscolumn),new Location(yyline+1,yycolumn+1+yylength()), sb.toString()); }
 
136
  .|\n            { sb.append(yytext()); }
 
137
}
 
138
 
 
139
// error fallback
 
140
.|\n          { emit_warning("Unrecognized character '" +yytext()+"' -- ignored"); }