KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > prefuse > data > expression > parser > ExpressionParser


1 /* Generated By:JavaCC: Do not edit this line. ExpressionParser.java */
2 package prefuse.data.expression.parser;
3
4 import java.io.StringReader JavaDoc;
5 import java.util.logging.Logger JavaDoc;
6
7 import prefuse.data.expression.AndPredicate;
8 import prefuse.data.expression.ArithmeticExpression;
9 import prefuse.data.expression.BooleanLiteral;
10 import prefuse.data.expression.ColumnExpression;
11 import prefuse.data.expression.ComparisonPredicate;
12 import prefuse.data.expression.Expression;
13 import prefuse.data.expression.Function;
14 import prefuse.data.expression.FunctionTable;
15 import prefuse.data.expression.IfExpression;
16 import prefuse.data.expression.NotPredicate;
17 import prefuse.data.expression.NumericLiteral;
18 import prefuse.data.expression.ObjectLiteral;
19 import prefuse.data.expression.OrPredicate;
20 import prefuse.data.expression.Predicate;
21 import prefuse.data.expression.XorPredicate;
22 import prefuse.util.StringLib;
23
24 /**
25  * Parser for statements written in the prefuse expression language. Text
26  * expression are parsed into {@link prefuse.data.expression.Expression}
27  * instances, and can be used as predicates or to create derived
28  * table columns. This parser is implemented using the
29  * <a HREF="https://javacc.dev.java.net/">JavaCC package</a>. To parse
30  * a text String to an {@link prefuse.data.expression.Expression}, use
31  * the {@link #parse(String)} method. If a parse error occurs, the method
32  * will fail silently and return null. Any generated exception can be
33  * later retrieved using the {@link #getError()} method. One can also
34  * use the {@link #parse(String, boolean)} with a <code>true</code>
35  * boolean argument to request that Exceptions be thrown when
36  * errors occur.
37  *
38  * <h1>Prefuse Expression Language Reference</h1>
39  * <p>
40  * The prefuse expression language provides a convenient way of creating manipulable statements
41  * over data in a prefuse data structure. For example, the expression language can be used to
42  * write {@link prefuse.data.expression.Predicate} instances for querying and filtering a table
43  * or graph, or to create arbitrary expressions over a data set to generate new, derived data
44  * fields that can in turn be subject to additional processing or visualization. For example,
45  * the {@link prefuse.data.tuple.TupleSet#tuples(prefuse.data.expression.Predicate)} method
46  * uses a Predicate to filter the requested set of tuples, and the
47  * {@link prefuse.data.Table#addColumn(java.lang.String,prefuse.data.expression.Expression)}
48  * method creates a new table column whose values are generated by the provided Expression.
49  * The expression machinery is used
50  * throughout the toolkit -- it underlies the filtering and query optimization features,
51  * is a key component of {@link prefuse.data.query dynamic query bindings}, and is used to
52  * create the rule chains evaluated by the
53  * {@link prefuse.render.DefaultRendererFactory},
54  * {@link prefuse.action.assignment.ColorAction},
55  * {@link prefuse.action.assignment.ShapeAction},
56  * {@link prefuse.action.assignment.FontAction}, and
57  * {@link prefuse.action.assignment.SizeAction} classes.
58  * </p>
59  * <p>
60  * The {@link prefuse.data.expression.Expression} interface is quite simple: given a single
61  * Tuple, compute and return a value. The returned value could be an Object, a boolean, an int,
62  * or other primitive type. Individual methods for each type are available, and which ones are
63  * legal to call for any given Expression depends on the type of Expression.
64  * </p>
65  * <p>
66  * Expressions can be created directly in Java, by instantiating and chaining together the
67  * desired Expression instances. This process, however, can be somewhat tedious, so prefuse
68  * also provides a built-in parser/compiler for generating these chains of Expression
69  * instances from a textual language. The language is based on a subset of SQL, the
70  * standard language for database queries. If you have ever written a "WHERE" clause in
71  * a SQL "SELECT" query, you probably know most of the language already. To parse an
72  * expression, simply pass a text string containing an expression statement to the
73  * {@link prefuse.data.expression.parser.ExpressionParser#parse(java.lang.String)}
74  * method. If the string parses successfully, the parsed Expression instance will be
75  * returned.
76  * </p>
77  * <p>
78  * Below is the reference for the language, including literal types, data field references,
79  * basic operators, and included functions. If need be, you can also introduce a new
80  * function by creating a new instance of the {@link prefuse.data.expression.Function} interface
81  * and registering it with the {@link prefuse.data.expression.FunctionTable} class.
82  * </p>
83  * <p>
84  * All keywords and functions in the prefuse expression language can be written in
85  * either uppercase or lowercase. Writing in mixed-case, however, will likely result in parse
86  * errors.
87  * </p>
88  *
89  * <h2>Literal Values and Data Field References</h2>
90  * <p>The fundamental building blocks of the expression language, representing data values
91  * or referencing the contents of a Tuple data field.</p>
92  * <ul>
93  * <li><strong>Boolean literals (<code>TRUE, FALSE</code>)</strong><br/>
94  * The boolean literals representing true and false conditions, parsed to type <code>boolean</code>
95  * </li>
96  * <li><strong>Integer literals (<code>1, -5, 12340</code>)</strong><br/>
97  * Undecorated, non-decimal numbers are parsed as numbers of type <code>int</code>
98  * </li>
99  * <li><strong>Long literals (<code>1L, -5L, 12340L</code>)</strong><br/>
100  * Integer values decorated with the suffix "L" are parsed as numbers of type <code>long</code>
101  * </li>
102  * <li><strong>Double literals (<code>1.0, 3.1415, 1e-35, 2.3e6</code>)</strong><br/>
103  * Numbers with decimals or exponents in scientific notation are parsed as numbers of type <code>double</code>
104  * </li>
105  * <li><strong>Float literals (<code>1.0f, 3.1415f, 1e-35f, 2.3e6f</code>)</strong><br/>
106  * Floating-point values decorated with the suffix "f" are parsed as numbers of type <code>float</code>
107  * </li>
108  * <li><strong>String literals (<code>"some text", 'a label'</code>)</strong><br/>
109  * Text strings placed in double (") or single (') quotations are parsed as <code>String</code> literals
110  * </li>
111  * <li><strong>Null literal (<code>null</code>)</strong><br/>
112  * The string <code>null</code> is parsed as an ObjectLiteral of type null.
113  * </li>
114  * <li><strong>Data field references (<code>_strokeColor, [a data field]</code>)</strong><br/>
115  * Free-standing strings or those placed within brackets are parsed as a reference to the
116  * data field of that name. Brackets are required for any fields that include spaces or other
117  * unusual characters in their name (e.g., characters like +, -, *, etc), or conflict with
118  * an existing keyword For example, <code>true</code> parses to a boolean literal while
119  * <code>[true]</code> parses to a reference to a data field named 'true'.
120  * </li>
121  * </ul>
122  *
123  * <h2>Operators and Control Flow</h2>
124  * <p>Basic operators and control flow structures for the expression language.</p>
125  * <ul>
126  * <li><strong><code>x + y</code> (addition)</strong><br/>
127  * Add <code>x</code> and <code>y</code>
128  * </li>
129  * <li><strong><code>x - y</code> (subtraction)</strong><br/>
130  * Subtract <code>y</code> from <code>x</code>
131  * </li>
132  * <li><strong><code>x * y</code> (multiplication)</strong><br/>
133  * Multiply <code>x</code> and <code>y</code>
134  * </li>
135  * <li><strong><code>x / y</code> (division)</strong><br/>
136  * Divide <code>x</code> by <code>y</code>
137  * </li>
138  * <li><strong><code>x ^ y</code> (exponentiation, pow)</strong><br/>
139  * Raise <code>x</code> to the exponent <code>y</code>
140  * </li>
141  * <li><strong><code>x % y</code> (modulo)</strong><br/>
142  * Return the remainder of <code>x</code> divded by <code>y</code>
143  * </li>
144  * <li><strong><code>x = y, x == y</code> (equality)</strong><br/>
145  * Indicates if <code>x</code> and <code>y</code> are equal
146  * </li>
147  * <li><strong><code>x != y, x <> y</code> (inequality)</strong><br/>
148  * Indicates if <code>x</code> and <code>y</code> are not equal
149  * </li>
150  * <li><strong><code>x > y</code> (greater than)</strong><br/>
151  * Indicates if <code>x</code> is greater than <code>y</code>
152  * </li>
153  * <li><strong><code>x >= y</code> (greater than or equal to)</strong><br/>
154  * Indicates if <code>x</code> is greater than or equal to <code>y</code>
155  * </li>
156  * <li><strong><code>x < y</code> (less than)</strong><br/>
157  * Indicates if <code>x</code> is less than <code>y</code>
158  * </li>
159  * <li><strong><code>x <= y</code> (less than or equal to)</strong><br/>
160  * Indicates if <code>x</code> is less than or equal to <code>y</code>
161  * </li>
162  * <li><strong><code>x AND y, x && y</code> (and)</strong><br/>
163  * Indicates if both <code>x</code> and <code>y</code> are true
164  * </li>
165  * <li><strong><code>x OR y, x || y</code> (or)</strong><br/>
166  * Indicates if either <code>x</code> or <code>y</code> is true
167  * </li>
168  * <li><strong><code>NOT x, !x</code> (not)</strong><br/>
169  * Indicates if the negation of <code>x</code> is true
170  * </li>
171  * <li><strong><code>x XOR y</code> (exclusive or)</strong><br/>
172  * Indicates if one, but not both, of <code>x</code> or <code>y</code> is true
173  * </li>
174  * <li><strong><code>IF test THEN x ELSE y</code> (if-then-else)</strong><br/>
175  * Evaluates the predicate <code>test</code>, and if true evaluates and returns the
176  * expression <code>x</code>, and if false evaluates and returns the expression
177  * <code>y</code>
178  * </li>
179  * <li><strong><code>()</code> (parentheses)</strong><br/>
180  * Groups expressions together to enfore a particular order of evaluation. For example,
181  * <code>1+2*3</code> evaluates to <code>7</code>, while <code>(1+2)*3</code> evaluates
182  * to <code>9</code>.
183  * </li>
184  * </ul>
185  *
186  * <h2>General Functions</h2>
187  * <p>General purpose functions.</p>
188  * <ul>
189  * <li><strong><code>ROW()</code></strong><br/>
190  * Returns the table row number (or -1 if none) of the current Tuple.
191  * </li>
192  * <li><strong><code>ISNODE()</code></strong><br/>
193  * Returns true if the current Tuple is a graph Node.
194  * </li>
195  * <li><strong><code>ISEDGE()</code></strong><br/>
196  * Returns true if the current Tuple is a graph Edge.
197  * </li>
198  * <li><strong><code>DEGREE()</code></strong><br/>
199  * If the current Tuple is graph Node, returns the Node degree
200  * (the total number of incident edges). Otherwise returns 0.
201  * </li>
202  * <li><strong><code>INDEGREE()</code></strong><br/>
203  * If the current Tuple is graph Node, returns the Node indegree
204  * (the number of incident edges pointing towards this node).
205  * Otherwise returns 0.
206  * </li>
207  * <li><strong><code>OUTDEGREE()</code></strong><br/>
208  * If the current Tuple is graph Node, returns the Node outdegree
209  * (the number of incident edges pointing away from the node).
210  * Otherwise returns 0.
211  * </li>
212  * <li><strong><code>CHILDCOUNT()</code></strong><br/>
213  * If the current Tuple is graph Node, returns the number of tree
214  * children nodes. If the Tuple is not a Node, this method returns 0.
215  * If the Node is part of a Graph (not a Tree), the number of children
216  * nodes in the current spanning tree is returned. If no spanning tree has
217  * been computed, a new spanning tree will be computed using the default
218  * method. See {@link prefuse.data.Graph#getSpanningTree()} for more.
219  * </li>
220  * <li><strong><code>TREEDEPTH()</code></strong><br/>
221  * If the current Tuple is graph Node, returns the depth of this Node
222  * in its Tree or SpanningTree. If the Tuple is not a Node, this method
223  * returns 0. If the Node is part of a Graph (not a Tree), the tree depth
224  * of the node in the current spanning tree is returned. If no spanning
225  * tree has been computed, a new spanning tree will be computed using the
226  * default method. See {@link prefuse.data.Graph#getSpanningTree()} for
227  * more.
228  * </li>
229  * </ul>
230  *
231  * <h2>Mathematical Functions</h2>
232  * <p>Functions for performing mathematical calculations.</p>
233  * <ul>
234  * <li><strong><code>ABS(x)</code></strong><br/>
235  * Returns the absolute value of <code>x</code>
236  * </li>
237  * <li><strong><code>ACOS(x)</code></strong><br/>
238  * Returns the inverse cosine (arc cosine) of a <code>x</code>
239  * </li>
240  * <li><strong><code>ASIN(x)</code></strong><br/>
241  * Returns the inverse sine (arc sine) of a <code>x</code>
242  * </li>
243  * <li><strong><code>ATAN(x)</code></strong><br/>
244  * Returns the inverse tangent (arc tangent) of a <code>x</code>
245  * </li>
246  * <li><strong><code>ATAN2(y, x)</code></strong><br/>
247  * For the Cartesian coordinates <code>x</code>, <code>y</code> return the polar coordinate angle theta
248  * </li>
249  * <li><strong><code>CEIL(x), CEILING(x)</code></strong><br/>
250  * Returns the nearest integer value greater than or equal to <code>x</code>.
251  * </li>
252  * <li><strong><code>COS(x)</code></strong><br/>
253  * Returns the cosine of <code>x</code>
254  * </li>
255  * <li><strong><code>COT(x)</code></strong><br/>
256  * Returns the cotangent of <code>x</code>
257  * </li>
258  * <li><strong><code>DEGREES(x)</code></strong><br/>
259  * Converts <code>x</code> from radians to degrees
260  * </li>
261  * <li><strong><code>EXP(x)</code></strong><br/>
262  * Returns the value of <em>e</em> (the base of natural logarithms) raised to the <code>x</code> power
263  * </li>
264  * <li><strong><code>FLOOR(x)</code></strong><br/>
265  * Returns the nearest integer value less than or equal to <code>x</code>.
266  * </li>
267  * <li><strong><code>LOG(x), LOG(b, x)</code></strong><br/>
268  * With one argument, returns the natural logarithm (logarithm base <em>e</em>) of <code>x</code><br/>
269  * With two arguments, returns the logarithm of <code>x</code> for the provided base <code>b</code>
270  * </li>
271  * <li><strong><code>LOG2(x)</code></strong><br/>
272  * Returns the logarithm base 2 of <code>x</code>
273  * </li>
274  * <li><strong><code>LOG10(x)</code></strong><br/>
275  * Returns the logarithm base 10 of <code>x</code>
276  * </li>
277  * <li><strong><code>MAX(a, b, c, ...)</code></strong><br/>
278  * Returns the maximum value among the provided arguments
279  * </li>
280  * <li><strong><code>MIN(a, b, c, ...)</code></strong><br/>
281  * Returns the minimum value among the provided arguments
282  * </li>
283  * <li><strong><code>MOD(x, y)</code></strong><br/>
284  * Returns <code>x</code> modulo <code>y</code> (the remainder of <code>x</code> divided by <code>y</code>)
285  * </li>
286  * <li><strong><code>PI()</code></strong><br/>
287  * Returns the constant &pi; (= 3.1415926535...), the ratio between the circumference and diameter of a circle
288  * </li>
289  * <li><strong><code>POW(x, y), POWER(x, y)</code></strong><br/>
290  * Return the value of <code>x</code> raised to the exponent <code>y</code>
291  * </li>
292  * <li><strong><code>RADIANS(x)</code></strong><br/>
293  * Converts <code>x</code> from degrees to radians
294  * </li>
295  * <li><strong><code>RAND()</code></strong><br/>
296  * Returns a random floating-point value between 0 and 1
297  * </li>
298  * <li><strong><code>ROUND(x)</code></strong><br/>
299  * Returns the value of <code>x</code> rounded to the nearest integer
300  * </li>
301  * <li><strong><code>SIGN(x)</code></strong><br/>
302  * Returns the sign of <code>x</code>: 1 for positive, -1 for negative
303  * </li>
304  * <li><strong><code>SIN(x)</code></strong><br/>
305  * Returns the sine of <code>x</code>
306  * </li>
307  * <li><strong><code>SQRT(x)</code></strong><br/>
308  * Returns the square root of <code>x</code>
309  * </li>
310  * <li><strong><code>SUM(a, b, c, ...)</code></strong><br/>
311  * Returns the sum of the provided input value
312  * </li>
313  * <li><strong><code>TAN(x)</code></strong><br/>
314  * Returns the tangent of <code>x</code>
315  * </li>
316  * <li><strong><code>SAFELOG10(x)</code></strong><br/>
317  * Returns a "negative safe" logarithm base 10 of <code>x</code>, equivalent to
318  * <code>SIGN(x) * LOG10(ABS(x))</code>
319  * </li>
320  * <li><strong><code>POW(x)</code></strong><br/>
321  * Returns a "negative safe" square root of <code>x</code>, equivalent to
322  * <code>SIGN(x) * SQRT(ABS(x))</code>
323  * </li>
324  * </ul>
325  *
326  * <h2>String Functions</h2>
327  * <p>Functions for processing text strings.</p>
328  * <ul>
329  * <li><strong><code>CAP(str)</code></strong><br/>
330  * Capitalize words in the string <code>str</code>. Individual words/names will be given
331  * uppercase first letters, with all other letters in lowercase.
332  * </li>
333  * <li><strong><code>CONCAT(a, b, c, ...)</code></strong><br/>
334  * Concatenate the input strings into one resulting string.
335  * </li>
336  * <li><strong><code>CONCAT_WS(sep, a, b, c, ...)</code></strong><br/>
337  * Concatenate with separator. Concatenates the input strings into one resulting
338  * string, placing the string <code>sep</code> between each of the other arguments
339  * </li>
340  * <li><strong><code>FORMAT(x, d)</code></strong><br/>
341  * Format the number <code>x</code> as a string of the type "#,###.##", showing <code>d</code> decimal places
342  * </li>
343  * <li><strong><code>INSERT(str, pos, len, newstr)</code></strong><br/>
344  * Replaces the substring of length <code>len</code> starting at position <code>pos</code> in input
345  * string <code>str</code> with the string <code>newstr</code>
346  * </li>
347  * <li><strong><code>LEFT(str, len)</code></strong><br/>
348  * Returns the leftmost <code>len</code> characters of string <code>str</code>
349  * </li>
350  * <li><strong><code>LENGTH(str)</code></strong><br/>
351  * Returns the length, in characters, of the input string <code>str</code>
352  * </li>
353  * <li><strong><code>LOWER(str), LCASE(str)</code></strong><br/>
354  * Returns the string <code>str</code> mapped to lowercase letters
355  * </li>
356  * <li><strong><code>LPAD(str, len, pad)</code></strong><br/>
357  * Pad the left side of string <code>str</code> with copies of string <code>pad</code>,
358  * up to a total padding of <code>len</code> characters
359  * </li>
360  * <li><strong><code>MID(str, pos, len)</code></strong><br/>
361  * Return a substring of <code>str</code> of length <code>len</code>, starting at
362  * position <code>pos</code>
363  * </li>
364  * <li><strong><code>POSITION(substr, str)</code></strong><br/>
365  * Returns the starting position of the first occurrence of substring <code>substr</code>
366  * in the string <code>str</code>. Returns -1 if the substring is not found.
367  * </li>
368  * <li><strong><code>REVERSE(str)</code></strong><br/>
369  * Returns a reversed copy of the input string <code>str</code>
370  * </li>
371  * <li><strong><code>REPEAT(str, count)</code></strong><br/>
372  * Returns a string consisting of <code>str</code> repeated <code>count</code> times
373  * </li>
374  * <li><strong><code>REPLACE(str, orig, replace)</code></strong><br/>
375  * Returns a copy of <code>str</code> in which all occurrences of <code>orig</code> have been
376  * replaced by <code>replace</code>
377  * </li>
378  * <li><strong><code>RIGHT(str, len)</code></strong><br/>
379  * Returns the <code>len</code> rightmost characters of string<code>str</code>
380  * </li>
381  * <li><strong><code>RPAD(x)</code></strong><br/>
382  * Pad the right side of string <code>str</code> with copies of string <code>pad</code>,
383  * up to a total padding of <code>len</code> characters
384  * </li>
385  * <li><strong><code>SPACE(n)</code></strong><br/>
386  * Returns a string consisting of <code>n</code> whitespace characters
387  * </li>
388  * <li><strong><code>SUBSTRING(str,pos), SUBSTRING(str,pos,len)</code></strong><br/>
389  * For two arguments, returns the substring of <code>str</code> starting at position
390  * <code>pos</code> and continuing to the end of the string.<br/>
391  * For three arguments, returns the substring of <code>str</code> of length <code>len</code>,
392  * beginning at position <code>pos</code>
393  * </li>
394  * <li><strong><code>UPPER(str), UCASE(str</code></strong><br/>
395  * Returns the string <code>str</code> mapped to uppercase letters
396  * </li>
397  * </ul>
398  *
399  * <h2>Color Functions</h2>
400  * <p>Functions for generating, translating, and interpolating color values.</p>
401  * <ul>
402  * <li><strong><code>RGB(r, g, b)</code></strong><br/>
403  * Returns an integer representing a fully opaque RGB (red, green, blue) color value
404  * </li>
405  * <li><strong><code>RGBA(r, g, b, a)</code></strong><br/>
406  * Returns an integer representing an RGBA (red, green, blue, alpha/transparency) color value
407  * </li>
408  * <li><strong><code>GRAY(v)</code></strong><br/>
409  * Returns an integer representing a grayscale color value of intensity <code>v</code>
410  * </li>
411  * <li><strong><code>HEX(hex)</code></strong><br/>
412  * Returns an integer representing the RGB color value encoded by the hexadecimal number
413  * <code>hex</code>
414  * </li>
415  * <li><strong><code>HSB(h, s, b)</code></strong><br/>
416  * Maps the given hue (<code>hue</code>), saturation (<code>s</code>), and brightness
417  * (<code>b</code>) color space values (as floating point numbers between 0 and 1) to
418  * an integer representing an RGB color value
419  * </li>
420  * <li><strong><code>HSBA(h, s, b, a)</code></strong><br/>
421  * Maps the given hue (<code>hue</code>), saturation (<code>s</code>), brightness
422  * (<code>b</code>), and alpha (<code>a</code>) color space values (as floating point
423  * numbers between 0 and 1) to an integer representing an RGBA color value
424  * </li>
425  * <li><strong><code>COLORINTERP(c1, c2, f)</code></strong><br/>
426  * Returns an interpolated color value between the input colors <code>c1</code> and
427  * <code>c2</code> determined by the mixing proportion <code>f</code>, a value
428  * between 0 and 1
429  * </li>
430  * </ul>
431  *
432  * <h2>Visualization Functions</h2>
433  * <p>These functions can only be used when the Tuple being evaluated is
434  * a VisualItem, and provide access to data group information of the VisualItem's
435  * Visualization. Individual visual data fields can be accessed directly using
436  * a data field reference. For example, <code>_x</code>, <code>_y</code>,
437  * <code>_hover</code>, <code>_highlight</code>, <code>_fillColor</code> would
438  * evaluate to references for the x-coordinate, y-coordinate, mouse hover status,
439  * highlight status, and fill color, respectively.</p>
440  * <ul>
441  * <li><strong><code>GROUPSIZE(group)</code></strong><br/>
442  * Returns the number of members in the data group <code>group</code>
443  * </li>
444  * <li><strong><code>INGROUP(group)</code></strong><br/>
445  * Returns true if the current VisualItem is a member of data group <code>group</code>
446  * </li>
447  * <li><strong><code>MATCH(group, includeAll)</code></strong><br/>
448  * Returns true if the current VisualItem is currently a search match. This is similar
449  * to <code>INGROUP(group)</code>, but also includes a possible special case when no
450  * query has been issued and all items should be counted as "matches" (indicated
451  * by <code>includeAll</code> being true).
452  * </li>
453  * <li><strong><code>QUERY(group)</code></strong><br/>
454  * Returns the current search query string in a search group of name <code>group</code>
455  * </li>
456  * <li><strong><code>VISIBLE()</code></strong><br/>
457  * Returns true if the current VisualItem is visible, equivalent to <code>_visible</code>
458  * </li>
459  * <li><strong><code>VALIDATED()</code></strong><br/>
460  * Returns true if the current VisualItem's bounds have been validated,
461  * equivalent to <code>_validated</code>
462  * </li>
463  * </ul>
464  *
465  * @author <a HREF="http://jheer.org">jeffrey heer</a>
466  */

467 public class ExpressionParser implements ExpressionParserConstants {
468
469         private static final Logger JavaDoc s_logger
470             = Logger.getLogger(ExpressionParser.class.getName());
471
472     private static boolean s_init = false;
473     private static Throwable JavaDoc s_error;
474
475     /**
476      * Parse an expression.
477      * @param expr the expression text to parse
478      * @param throwsException true if this method should throw an
479      * exception if an error occurs or should fail quietly
480      * @return the parsed Expression, or null if the parse failed
481      * and throwsException is false
482      */

483     public synchronized static Expression parse(String JavaDoc expr,
484                                                 boolean throwsException)
485     {
486         // initialize the parser
487
if ( !s_init ) {
488             new ExpressionParser(new StringReader JavaDoc(expr));
489             s_init = true;
490         } else {
491             ExpressionParser.ReInit(new StringReader JavaDoc(expr));
492         }
493         // attempt to parse the expression
494
try {
495             Expression e = Parse();
496             s_error = null;
497             s_logger.info("Parsed Expression: "+e);
498             return e;
499         } catch ( ParseException t ) {
500             s_error = t;
501             if ( throwsException ) {
502                 throw t;
503             } else {
504                 s_logger.warning("Expression Parse Error: " + t.getMessage()
505                         + "\n" + StringLib.getStackTrace(t));
506                 return null;
507             }
508         }
509     }
510
511     /**
512      * Parse an expression. This method does not throw an exception if
513      * a parse error occurs. Use {@link #getError()} to access any
514      * generated exceptions.
515      * @param expr the expression text to parse
516      * @return the parsed Expression, or null if the parse failed
517      */

518     public synchronized static Expression parse(String JavaDoc expr) {
519         return parse(expr, false);
520     }
521     
522     /**
523      * Parse an expression as a predicate. This method does not throw an
524      * exception if a parse error occurs. Use {@link #getError()} to access
525      * any generated exceptions.
526      * @param expr the expression text to parse
527      * @return the parsed Expression, or null if the parse failed
528      */

529     public synchronized static Predicate predicate(String JavaDoc expr) {
530         Expression ex = parse(expr, false);
531         if ( ex == null ) {
532             return null;
533         } else if ( ex instanceof Predicate ) {
534             return (Predicate) ex;
535         } else {
536             s_error = new ClassCastException JavaDoc("Expression is not a predicate");
537             return null;
538         }
539     }
540
541     /**
542      * Get the last error, if any, generated by a parse operation.
543      * @return the last error generated during parsing
544      */

545     public synchronized static Throwable JavaDoc getError() {
546         return s_error;
547     }
548
549     /**
550      * Replace escape sequences with represented characters. This
551      * includes newlines, tabs, and quotes.
552      * @param s the input String, possibly with escape sequences
553      * @return a String with recognized escape sequences properly replaced
554      */

555     private static String JavaDoc unescape(String JavaDoc s) {
556         int len = s.length(), base = 0, idx;
557         String JavaDoc escapes = "tnrbf\\\"'";
558         String JavaDoc chars = "\t\n\r\b\f\\\"'";
559
560         StringBuffer JavaDoc sbuf = null;
561
562         while ( (idx=s.indexOf('\\',base)) != -1) {
563             if ( sbuf != null )
564                 sbuf.append(s.substring(base, idx));
565
566             if (idx+1 == len) break;
567
568             // find escape character
569
char c = s.charAt(idx+1);
570
571             // find the index of the escape character
572
int cidx = escapes.indexOf(c);
573             if (cidx == -1) {
574                 // no match, so continue
575
sbuf.append('\\');
576                 sbuf.append(c);
577             } else {
578                 // replace escape sequence with true char
579
if ( sbuf == null )
580                     sbuf = new StringBuffer JavaDoc(s.substring(base, idx));
581                 sbuf.append(chars.charAt(cidx));
582             }
583
584             // skip over escape sequence
585
base = idx + 2;
586         }
587         if ( sbuf != null && base < len )
588             sbuf.append(s.substring(base));
589
590         return ( sbuf == null ? s : sbuf.toString() );
591     }
592
593   // ----------------------------------------------------------------------------
594
// Grammar definitions
595
static final public String JavaDoc Name() throws ParseException {
596   Token t;
597     t = jj_consume_token(IDENTIFIER);
598                    {if (true) return t.image;}
599     throw new Error JavaDoc("Missing return statement in function");
600   }
601
602   static final public String JavaDoc Quoted() throws ParseException {
603   Token t;
604     t = jj_consume_token(QUOTED);
605                {if (true) return t.image.substring(1,t.image.length()-1);}
606     throw new Error JavaDoc("Missing return statement in function");
607   }
608
609   static final public Expression Parse() throws ParseException {
610   Expression e;
611     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
612     case TRUE:
613     case FALSE:
614     case NULL:
615     case IF:
616     case NOT:
617     case INT:
618     case LONG:
619     case DOUBLE:
620     case FLOAT:
621     case STRING:
622     case QUOTED:
623     case IDENTIFIER:
624     case LPAREN:
625     case ADD:
626     case SUB:
627       e = Expression();
628       jj_consume_token(0);
629                          {if (true) return e;}
630       break;
631     case 0:
632       jj_consume_token(0);
633           {if (true) throw new ParseException("No expression provided");}
634       break;
635     default:
636       jj_la1[0] = jj_gen;
637       jj_consume_token(-1);
638       throw new ParseException();
639     }
640     throw new Error JavaDoc("Missing return statement in function");
641   }
642
643   static final public Expression Expression() throws ParseException {
644   Expression e;
645     e = OrExpression();
646                      {if (true) return e;}
647     throw new Error JavaDoc("Missing return statement in function");
648   }
649
650   static final public Expression OrExpression() throws ParseException {
651   Expression l, r;
652     l = XorExpression();
653     label_1:
654     while (true) {
655       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
656       case OR:
657         ;
658         break;
659       default:
660         jj_la1[1] = jj_gen;
661         break label_1;
662       }
663       jj_consume_token(OR);
664       r = XorExpression();
665       if ( l instanceof OrPredicate ) {
666           ((OrPredicate)l).add((Predicate)r);
667       } else {
668           l = new OrPredicate((Predicate)l,(Predicate)r);
669       }
670     }
671        {if (true) return l;}
672     throw new Error JavaDoc("Missing return statement in function");
673   }
674
675   static final public Expression XorExpression() throws ParseException {
676   Expression l, r;
677     l = AndExpression();
678     label_2:
679     while (true) {
680       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
681       case XOR:
682         ;
683         break;
684       default:
685         jj_la1[2] = jj_gen;
686         break label_2;
687       }
688       jj_consume_token(XOR);
689       r = AndExpression();
690       if ( l instanceof XorPredicate ) {
691           ((XorPredicate)l).add((Predicate)r);
692       } else {
693           l = new XorPredicate((Predicate)l,(Predicate)r);
694       }
695     }
696        {if (true) return l;}
697     throw new Error JavaDoc("Missing return statement in function");
698   }
699
700   static final public Expression AndExpression() throws ParseException {
701   Expression l, r;
702     l = EqualityExpression();
703     label_3:
704     while (true) {
705       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
706       case AND:
707         ;
708         break;
709       default:
710         jj_la1[3] = jj_gen;
711         break label_3;
712       }
713       jj_consume_token(AND);
714       r = EqualityExpression();
715       if ( l instanceof AndPredicate ) {
716           ((AndPredicate)l).add((Predicate)r);
717       } else {
718           l = new AndPredicate((Predicate)l,(Predicate)r);
719       }
720     }
721        {if (true) return l;}
722     throw new Error JavaDoc("Missing return statement in function");
723   }
724
725   static final public Expression EqualityExpression() throws ParseException {
726   Expression l, r; Token t; int op;
727     l = RelationalExpression();
728     label_4:
729     while (true) {
730       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
731       case EQ:
732       case NE:
733         ;
734         break;
735       default:
736         jj_la1[4] = jj_gen;
737         break label_4;
738       }
739       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
740       case EQ:
741         t = jj_consume_token(EQ);
742         break;
743       case NE:
744         t = jj_consume_token(NE);
745         break;
746       default:
747         jj_la1[5] = jj_gen;
748         jj_consume_token(-1);
749         throw new ParseException();
750       }
751       r = RelationalExpression();
752       op = (t.kind==EQ ? ComparisonPredicate.EQ : ComparisonPredicate.NEQ);
753       l = new ComparisonPredicate(op, l, r);
754     }
755            {if (true) return l;}
756     throw new Error JavaDoc("Missing return statement in function");
757   }
758
759   static final public Expression RelationalExpression() throws ParseException {
760   Expression l, r; Token t; int op=-1;
761     l = AdditiveExpression();
762     label_5:
763     while (true) {
764       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
765       case GT:
766       case LT:
767       case LE:
768       case GE:
769         ;
770         break;
771       default:
772         jj_la1[6] = jj_gen;
773         break label_5;
774       }
775       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
776       case LT:
777         t = jj_consume_token(LT);
778         break;
779       case GT:
780         t = jj_consume_token(GT);
781         break;
782       case LE:
783         t = jj_consume_token(LE);
784         break;
785       case GE:
786         t = jj_consume_token(GE);
787         break;
788       default:
789         jj_la1[7] = jj_gen;
790         jj_consume_token(-1);
791         throw new ParseException();
792       }
793       r = AdditiveExpression();
794       switch ( t.kind ) {
795       case LT:
796           op = ComparisonPredicate.LT;
797           break;
798       case GT:
799           op = ComparisonPredicate.GT;
800           break;
801       case LE:
802           op = ComparisonPredicate.LTEQ;
803           break;
804       case GE:
805           op = ComparisonPredicate.GTEQ;
806           break;
807       }
808       l = new ComparisonPredicate(op, l, r);
809     }
810            {if (true) return l;}
811     throw new Error JavaDoc("Missing return statement in function");
812   }
813
814   static final public Expression AdditiveExpression() throws ParseException {
815   Expression l, r; Token t; int op=-1;
816     l = MultiplicativeExpression();
817     label_6:
818     while (true) {
819       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
820       case ADD:
821       case SUB:
822       case MOD:
823         ;
824         break;
825       default:
826         jj_la1[8] = jj_gen;
827         break label_6;
828       }
829       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
830       case ADD:
831         t = jj_consume_token(ADD);
832         break;
833       case SUB:
834         t = jj_consume_token(SUB);
835         break;
836       case MOD:
837         t = jj_consume_token(MOD);
838         break;
839       default:
840         jj_la1[9] = jj_gen;
841         jj_consume_token(-1);
842         throw new ParseException();
843       }
844       r = MultiplicativeExpression();
845       switch ( t.kind ) {
846       case ADD:
847         op = ArithmeticExpression.ADD;
848         break;
849       case SUB:
850         op = ArithmeticExpression.SUB;
851         break;
852       case MOD:
853         op = ArithmeticExpression.MOD;
854         break;
855       }
856       l = new ArithmeticExpression(op, l, r);
857     }
858            {if (true) return l;}
859     throw new Error JavaDoc("Missing return statement in function");
860   }
861
862   static final public Expression MultiplicativeExpression() throws ParseException {
863   Expression l, r; Token t; int op=-1;
864     l = UnaryExpression();
865     label_7:
866     while (true) {
867       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
868       case MUL:
869       case DIV:
870       case POW:
871         ;
872         break;
873       default:
874         jj_la1[10] = jj_gen;
875         break label_7;
876       }
877       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
878       case MUL:
879         t = jj_consume_token(MUL);
880         break;
881       case DIV:
882         t = jj_consume_token(DIV);
883         break;
884       case POW:
885         t = jj_consume_token(POW);
886         break;
887       default:
888         jj_la1[11] = jj_gen;
889         jj_consume_token(-1);
890         throw new ParseException();
891       }
892       r = UnaryExpression();
893       switch ( t.kind ) {
894       case MUL:
895         op = ArithmeticExpression.MUL;
896         break;
897       case DIV:
898         op = ArithmeticExpression.DIV;
899         break;
900       case POW:
901         op = ArithmeticExpression.POW;
902         break;
903       }
904       l = new ArithmeticExpression(op, l, r);
905     }
906            {if (true) return l;}
907     throw new Error JavaDoc("Missing return statement in function");
908   }
909
910   static final public Expression UnaryExpression() throws ParseException {
911   Expression e; Token t;
912     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
913     case ADD:
914     case SUB:
915       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
916       case ADD:
917         t = jj_consume_token(ADD);
918         break;
919       case SUB:
920         t = jj_consume_token(SUB);
921         break;
922       default:
923         jj_la1[12] = jj_gen;
924         jj_consume_token(-1);
925         throw new ParseException();
926       }
927       e = UnaryExpression();
928         if ( t.kind == SUB && e instanceof NumericLiteral ) {
929           Number JavaDoc n = (Number JavaDoc)e.get(null);
930           if ( n instanceof Integer JavaDoc ) {
931               {if (true) return new NumericLiteral(-1*n.intValue());}
932           } if ( n instanceof Double JavaDoc ) {
933               {if (true) return new NumericLiteral(-1*n.doubleValue());}
934           } if ( n instanceof Long JavaDoc ) {
935               {if (true) return new NumericLiteral(-1*n.longValue());}
936           } if ( n instanceof Float JavaDoc ) {
937               {if (true) return new NumericLiteral(-1*n.floatValue());}
938           } else {
939               {if (true) return new ArithmeticExpression(ArithmeticExpression.MUL,
940                                               new NumericLiteral(-1), e);}
941           }
942         } else if ( t.kind == SUB ) {
943           {if (true) return new ArithmeticExpression(ArithmeticExpression.MUL,
944                                           new NumericLiteral(-1), e);}
945         } else {
946           {if (true) return e;}
947         }
948       break;
949     case NOT:
950       e = UnaryExpressionNotPlusMinus();
951                                       {if (true) return e;}
952       break;
953     case TRUE:
954     case FALSE:
955     case NULL:
956     case IF:
957     case INT:
958     case LONG:
959     case DOUBLE:
960     case FLOAT:
961     case STRING:
962     case QUOTED:
963     case IDENTIFIER:
964     case LPAREN:
965       e = PrimaryExpression();
966                             {if (true) return e;}
967       break;
968     default:
969       jj_la1[13] = jj_gen;
970       jj_consume_token(-1);
971       throw new ParseException();
972     }
973     throw new Error JavaDoc("Missing return statement in function");
974   }
975
976   static final public Expression UnaryExpressionNotPlusMinus() throws ParseException {
977   Expression e;
978     jj_consume_token(NOT);
979     e = UnaryExpression();
980         if ( e instanceof NotPredicate ) {
981             {if (true) return ((NotPredicate)e).getPredicate();}
982         } else {
983             if ( !(e instanceof Predicate) ) {
984                 {if (true) throw new ParseException("Can't negate a non-predicate");}
985             } else {
986                 {if (true) return new NotPredicate((Predicate)e);}
987             }
988         }
989     throw new Error JavaDoc("Missing return statement in function");
990   }
991
992   static final public Expression PrimaryExpression() throws ParseException {
993   Expression e;
994     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
995     case TRUE:
996     case FALSE:
997     case NULL:
998     case INT:
999     case LONG:
1000    case DOUBLE:
1001    case FLOAT:
1002    case STRING:
1003      e = Literal();
1004                  {if (true) return e;}
1005      break;
1006    case IF:
1007      e = IfStatement();
1008                      {if (true) return e;}
1009      break;
1010    case QUOTED:
1011    case IDENTIFIER:
1012      e = Identifier();
1013                     {if (true) return e;}
1014      break;
1015    case LPAREN:
1016      jj_consume_token(LPAREN);
1017      e = Expression();
1018      jj_consume_token(RPAREN);
1019                                       {if (true) return e;}
1020      break;
1021    default:
1022      jj_la1[14] = jj_gen;
1023      jj_consume_token(-1);
1024      throw new ParseException();
1025    }
1026    throw new Error JavaDoc("Missing return statement in function");
1027  }
1028
1029  static final public Expression Literal() throws ParseException {
1030  Token t;
1031    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1032    case INT:
1033      t = jj_consume_token(INT);
1034              {if (true) return new NumericLiteral(Integer.parseInt(t.image));}
1035      break;
1036    case LONG:
1037      t = jj_consume_token(LONG);
1038               {if (true) return new NumericLiteral(Long.parseLong(t.image));}
1039      break;
1040    case FLOAT:
1041      t = jj_consume_token(FLOAT);
1042                {if (true) return new NumericLiteral(Float.parseFloat(t.image));}
1043      break;
1044    case DOUBLE:
1045      t = jj_consume_token(DOUBLE);
1046                 {if (true) return new NumericLiteral(Double.parseDouble(t.image));}
1047      break;
1048    case STRING:
1049      t = jj_consume_token(STRING);
1050                String JavaDoc s = unescape(t.image.substring(1, t.image.length()-1));
1051                {if (true) return new ObjectLiteral(s);}
1052      break;
1053    case TRUE:
1054      jj_consume_token(TRUE);
1055             {if (true) return new BooleanLiteral(true);}
1056      break;
1057    case FALSE:
1058      jj_consume_token(FALSE);
1059              {if (true) return new BooleanLiteral(false);}
1060      break;
1061    case NULL:
1062      jj_consume_token(NULL);
1063             {if (true) return new ObjectLiteral(null);}
1064      break;
1065    default:
1066      jj_la1[15] = jj_gen;
1067      jj_consume_token(-1);
1068      throw new ParseException();
1069    }
1070    throw new Error JavaDoc("Missing return statement in function");
1071  }
1072
1073  static final public Expression Identifier() throws ParseException {
1074  String JavaDoc s; Function f=null; Expression e;
1075    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1076    case QUOTED:
1077      s = Quoted();
1078                 {if (true) return new ColumnExpression(s);}
1079      break;
1080    case IDENTIFIER:
1081      s = Name();
1082      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1083      case LPAREN:
1084        jj_consume_token(LPAREN);
1085                 f = FunctionTable.createFunction(s);
1086        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1087        case TRUE:
1088        case FALSE:
1089        case NULL:
1090        case IF:
1091        case NOT:
1092        case INT:
1093        case LONG:
1094        case DOUBLE:
1095        case FLOAT:
1096        case STRING:
1097        case QUOTED:
1098        case IDENTIFIER:
1099        case LPAREN:
1100        case ADD:
1101        case SUB:
1102          e = Expression();
1103                         f.addParameter(e);
1104          label_8:
1105          while (true) {
1106            switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1107            case 43:
1108              ;
1109              break;
1110            default:
1111              jj_la1[16] = jj_gen;
1112              break label_8;
1113            }
1114            jj_consume_token(43);
1115            e = Expression();
1116                              f.addParameter(e);
1117          }
1118          break;
1119        default:
1120          jj_la1[17] = jj_gen;
1121          ;
1122        }
1123        jj_consume_token(RPAREN);
1124        break;
1125      default:
1126        jj_la1[18] = jj_gen;
1127        ;
1128      }
1129      {if (true) return f==null ? new ColumnExpression(s) : (Expression)f;}
1130      break;
1131    default:
1132      jj_la1[19] = jj_gen;
1133      jj_consume_token(-1);
1134      throw new ParseException();
1135    }
1136    throw new Error JavaDoc("Missing return statement in function");
1137  }
1138
1139  static final public Expression IfStatement() throws ParseException {
1140  Expression p, t, e;
1141    jj_consume_token(IF);
1142    p = Expression();
1143    jj_consume_token(THEN);
1144    t = Expression();
1145    jj_consume_token(ELSE);
1146    e = Expression();
1147      if ( !(p instanceof Predicate) )
1148          {if (true) throw new ParseException("IF-statement test must be a predicate");}
1149      {if (true) return new IfExpression((Predicate)p, t, e);}
1150    throw new Error JavaDoc("Missing return statement in function");
1151  }
1152
1153  static private boolean jj_initialized_once = false;
1154  static public ExpressionParserTokenManager token_source;
1155  static JavaCharStream jj_input_stream;
1156  static public Token token, jj_nt;
1157  static private int jj_ntk;
1158  static private int jj_gen;
1159  static final private int[] jj_la1 = new int[20];
1160  static private int[] jj_la1_0;
1161  static private int[] jj_la1_1;
1162  static {
1163      jj_la1_0();
1164      jj_la1_1();
1165   }
1166   private static void jj_la1_0() {
1167      jj_la1_0 = new int[] {0x277143c1,0x2000,0x8000,0x1000,0x80000000,0x80000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x277143c0,0x277103c0,0x17101c0,0x0,0x277143c0,0x20000000,0x6000000,};
1168   }
1169   private static void jj_la1_1() {
1170      jj_la1_1 = new int[] {0x60,0x0,0x0,0x0,0x10,0x10,0xf,0xf,0x460,0x460,0x380,0x380,0x60,0x60,0x0,0x0,0x800,0x60,0x0,0x0,};
1171   }
1172
1173  public ExpressionParser(java.io.InputStream JavaDoc stream) {
1174    if (jj_initialized_once) {
1175      System.out.println("ERROR: Second call to constructor of static parser. You must");
1176      System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
1177      System.out.println(" during parser generation.");
1178      throw new Error JavaDoc();
1179    }
1180    jj_initialized_once = true;
1181    jj_input_stream = new JavaCharStream(stream, 1, 1);
1182    token_source = new ExpressionParserTokenManager(jj_input_stream);
1183    token = new Token();
1184    jj_ntk = -1;
1185    jj_gen = 0;
1186    for (int i = 0; i < 20; i++) jj_la1[i] = -1;
1187  }
1188
1189  static public void ReInit(java.io.InputStream JavaDoc stream) {
1190    jj_input_stream.ReInit(stream, 1, 1);
1191    ExpressionParserTokenManager.ReInit(jj_input_stream);
1192    token = new Token();
1193    jj_ntk = -1;
1194    jj_gen = 0;
1195    for (int i = 0; i < 20; i++) jj_la1[i] = -1;
1196  }
1197
1198  public ExpressionParser(java.io.Reader JavaDoc stream) {
1199    if (jj_initialized_once) {
1200      System.out.println("ERROR: Second call to constructor of static parser. You must");
1201      System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
1202      System.out.println(" during parser generation.");
1203      throw new Error JavaDoc();
1204    }
1205    jj_initialized_once = true;
1206    jj_input_stream = new JavaCharStream(stream, 1, 1);
1207    token_source = new ExpressionParserTokenManager(jj_input_stream);
1208    token = new Token();
1209    jj_ntk = -1;
1210    jj_gen = 0;
1211    for (int i = 0; i < 20; i++) jj_la1[i] = -1;
1212  }
1213
1214  static public void ReInit(java.io.Reader JavaDoc stream) {
1215    jj_input_stream.ReInit(stream, 1, 1);
1216    ExpressionParserTokenManager.ReInit(jj_input_stream);
1217    token = new Token();
1218    jj_ntk = -1;
1219    jj_gen = 0;
1220    for (int i = 0; i < 20; i++) jj_la1[i] = -1;
1221  }
1222
1223  public ExpressionParser(ExpressionParserTokenManager tm) {
1224    if (jj_initialized_once) {
1225      System.out.println("ERROR: Second call to constructor of static parser. You must");
1226      System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
1227      System.out.println(" during parser generation.");
1228      throw new Error JavaDoc();
1229    }
1230    jj_initialized_once = true;
1231    token_source = tm;
1232    token = new Token();
1233    jj_ntk = -1;
1234    jj_gen = 0;
1235    for (int i = 0; i < 20; i++) jj_la1[i] = -1;
1236  }
1237
1238  public void ReInit(ExpressionParserTokenManager tm) {
1239    token_source = tm;
1240    token = new Token();
1241    jj_ntk = -1;
1242    jj_gen = 0;
1243    for (int i = 0; i < 20; i++) jj_la1[i] = -1;
1244  }
1245
1246  static final private Token jj_consume_token(int kind) throws ParseException {
1247    Token oldToken;
1248    if ((oldToken = token).next != null) token = token.next;
1249    else token = token.next = ExpressionParserTokenManager.getNextToken();
1250    jj_ntk = -1;
1251    if (token.kind == kind) {
1252      jj_gen++;
1253      return token;
1254    }
1255    token = oldToken;
1256    jj_kind = kind;
1257    throw generateParseException();
1258  }
1259
1260  static final public Token getNextToken() {
1261    if (token.next != null) token = token.next;
1262    else token = token.next = ExpressionParserTokenManager.getNextToken();
1263    jj_ntk = -1;
1264    jj_gen++;
1265    return token;
1266  }
1267
1268  static final public Token getToken(int index) {
1269    Token t = token;
1270    for (int i = 0; i < index; i++) {
1271      if (t.next != null) t = t.next;
1272      else t = t.next = ExpressionParserTokenManager.getNextToken();
1273    }
1274    return t;
1275  }
1276
1277  static final private int jj_ntk() {
1278    if ((jj_nt=token.next) == null)
1279      return (jj_ntk = (token.next=ExpressionParserTokenManager.getNextToken()).kind);
1280    else
1281      return (jj_ntk = jj_nt.kind);
1282  }
1283
1284  static private java.util.Vector JavaDoc jj_expentries = new java.util.Vector JavaDoc();
1285  static private int[] jj_expentry;
1286  static private int jj_kind = -1;
1287
1288  static public ParseException generateParseException() {
1289    jj_expentries.removeAllElements();
1290    boolean[] la1tokens = new boolean[44];
1291    for (int i = 0; i < 44; i++) {
1292      la1tokens[i] = false;
1293    }
1294    if (jj_kind >= 0) {
1295      la1tokens[jj_kind] = true;
1296      jj_kind = -1;
1297    }
1298    for (int i = 0; i < 20; i++) {
1299      if (jj_la1[i] == jj_gen) {
1300        for (int j = 0; j < 32; j++) {
1301          if ((jj_la1_0[i] & (1<<j)) != 0) {
1302            la1tokens[j] = true;
1303          }
1304          if ((jj_la1_1[i] & (1<<j)) != 0) {
1305            la1tokens[32+j] = true;
1306          }
1307        }
1308      }
1309    }
1310    for (int i = 0; i < 44; i++) {
1311      if (la1tokens[i]) {
1312        jj_expentry = new int[1];
1313        jj_expentry[0] = i;
1314        jj_expentries.addElement(jj_expentry);
1315      }
1316    }
1317    int[][] exptokseq = new int[jj_expentries.size()][];
1318    for (int i = 0; i < jj_expentries.size(); i++) {
1319      exptokseq[i] = (int[])jj_expentries.elementAt(i);
1320    }
1321    return new ParseException(token, exptokseq, tokenImage);
1322  }
1323
1324  static final public void enable_tracing() {
1325  }
1326
1327  static final public void disable_tracing() {
1328  }
1329
1330}
1331
Popular Tags