File: xlformula.flex

package info (click to toggle)
jexcelapi 2.6.12%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,284 kB
  • sloc: java: 43,178; xml: 131; makefile: 13; lisp: 9
file content (129 lines) | stat: -rwxr-xr-x 4,587 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*********************************************************************
*
*      Copyright (C) 2002 Andrew Khan
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/

package jxl.biff.formula;

/**
 * This file is generated by JLex.  Do not alter the contents of this file
 * because changes will be overridden
 */

import jxl.biff.WorkbookMethods;

%%

%{
  int getPos() { return yychar ; }
%}

%{
  private boolean emptyString;
%}

%{
  private ExternalSheet externalSheet;
  private WorkbookMethods nameTable;

  void setExternalSheet(ExternalSheet es)
  {
    externalSheet = es;
  }

  void setNameTable(WorkbookMethods nt)
  {
    nameTable = nt;
  }
%}

%yylexthrow{
 jxl.biff.formula.FormulaException
%yylexthrow}

%line
%char
%unicode
%type ParseItem
%state YYSTRING

ALPHA=[A-Za-z]
DIGIT=[0-9]
RANGE_SEPARATOR=":"
ARGUMENT_SEPARATOR=","
OPEN_PARENTHESES="("
CLOSE_PARENTHESES=")"
INTEGER={DIGIT}+
FLOAT={DIGIT}+"."{DIGIT}+
NON_RELATIVE_CELL_IND="$"
BOOLEAN_TRUE="TRUE"
BOOLEAN_FALSE="FALSE"
QUOTE="\""
STRING=[^\"]*
SINGLE_QUOTE="'"
CELL_REFERENCE={NON_RELATIVE_CELL_IND}?{ALPHA}{ALPHA}?{NON_RELATIVE_CELL_IND}?{INTEGER}
CELL_RANGE={CELL_REFERENCE}{RANGE_SEPARATOR}{CELL_REFERENCE}
NAME={ALPHA}({ALPHA}|{INTEGER}|_)*
SHEET_NAME={SINGLE_QUOTE}[^\']*{SINGLE_QUOTE}
COLUMN_RANGE={NON_RELATIVE_CELL_IND}?{ALPHA}{ALPHA}?{RANGE_SEPARATOR}{NON_RELATIVE_CELL_IND}?{ALPHA}{ALPHA}?
CELL_RANGE_3D={CELL_REFERENCE_3D}:{CELL_REFERENCE}
CELL_REFERENCE_3D={SHEET_NAME}\!{CELL_REFERENCE}
CELL_REFERENCE_3D2=({ALPHA})+\!{CELL_REFERENCE}
COLUMN_RANGE_3D={SHEET_NAME}\!{COLUMN_RANGE}
WHITE_SPACE=[\n\ \t\b\012]
START_FUNCTION={ALPHA}+{OPEN_PARENTHESES}
ERROR_CONSTANT="#NULL!"|"#DIV/0!"|"#VALUE!"|"#REF!"|"#NAME?"|"#NUM!"
%% 

<YYINITIAL> "+"  { return new Plus() ;}
<YYINITIAL> "-"  { return new Minus() ; }
<YYINITIAL> "*"  { return new Multiply() ; }
<YYINITIAL> "/"  { return new Divide() ; }
<YYINITIAL> ">"  { return new GreaterThan() ; }
<YYINITIAL> "="  { return new Equal() ; }
<YYINITIAL> ">=" { return new GreaterEqual() ; }
<YYINITIAL> "<"  { return new LessThan() ; }
<YYINITIAL> "<>" { return new NotEqual() ; }
<YYINITIAL> "<=" { return new LessEqual() ; }
<YYINITIAL> {BOOLEAN_TRUE} {return new BooleanValue(yytext());}
<YYINITIAL> {BOOLEAN_FALSE} {return new BooleanValue(yytext());}
<YYINITIAL> {ARGUMENT_SEPARATOR} { return new ArgumentSeparator() ; }
<YYINITIAL> {INTEGER} { return new IntegerValue(yytext()) ; }
<YYINITIAL> {FLOAT} { return new DoubleValue(yytext()) ; }
<YYINITIAL> {START_FUNCTION} { return new StringFunction(yytext()) ; }
<YYINITIAL> {CELL_REFERENCE} { return new CellReference(yytext()) ; }
<YYINITIAL> {NAME} {return new NameRange(yytext(), nameTable); }
<YYINITIAL> {CELL_RANGE_3D} { return new Area3d(yytext(),externalSheet) ; }
<YYINITIAL> {CELL_RANGE} { return new Area(yytext()) ; }
<YYINITIAL> {COLUMN_RANGE} { return new ColumnRange(yytext()); }
<YYINITIAL> {CELL_REFERENCE_3D} 
             {return new CellReference3d(yytext(),externalSheet) ; }
<YYINITIAL> {CELL_REFERENCE_3D2} 
             {return new CellReference3d(yytext(),externalSheet) ; }
<YYINITIAL> {COLUMN_RANGE_3D} 
             { return new ColumnRange3d(yytext(),externalSheet) ; }
<YYINITIAL> {WHITE_SPACE} {}
<YYINITIAL> {OPEN_PARENTHESES} { return new OpenParentheses() ;}
<YYINITIAL> {CLOSE_PARENTHESES} { return new CloseParentheses() ;}
<YYINITIAL> {RANGE_SEPARATOR} { return new RangeSeparator(); }
<YYINITIAL> {ERROR_CONSTANT} {return new ErrorConstant(yytext());}

<YYINITIAL> {QUOTE} {emptyString = true; yybegin(YYSTRING);}

<YYSTRING>  {STRING} {emptyString = false; return new StringValue(yytext()) ; }
<YYSTRING>  {QUOTE} {yybegin(YYINITIAL); if (emptyString) return new StringValue("");}