KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > javacc > parser > Expansion


1 /*
2  * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
3  * California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
4  * intellectual property rights relating to technology embodied in the product
5  * that is described in this document. In particular, and without limitation,
6  * these intellectual property rights may include one or more of the U.S.
7  * patents listed at http://www.sun.com/patents and one or more additional
8  * patents or pending patent applications in the U.S. and in other countries.
9  * U.S. Government Rights - Commercial software. Government users are subject
10  * to the Sun Microsystems, Inc. standard license agreement and applicable
11  * provisions of the FAR and its supplements. Use is subject to license terms.
12  * Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
13  * trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
14  * product is covered and controlled by U.S. Export Control laws and may be
15  * subject to the export or import laws in other countries. Nuclear, missile,
16  * chemical biological weapons or nuclear maritime end uses or end users,
17  * whether direct or indirect, are strictly prohibited. Export or reexport
18  * to countries subject to U.S. embargo or to entities identified on U.S.
19  * export exclusion lists, including, but not limited to, the denied persons
20  * and specially designated nationals lists is strictly prohibited.
21  */

22
23 package org.javacc.parser;
24
25 /**
26  * Describes expansions - entities that may occur on the
27  * right hand sides of productions. This is the base class of
28  * a bunch of other more specific classes.
29  */

30
31 public class Expansion {
32
33   /**
34    * The line and column number of the construct that corresponds
35    * most closely to this node.
36    */

37   int line, column;
38
39   /**
40    * A reimplementing of Object.hashCode() to be deterministic. This uses
41    * the line and column fields to generate an arbitrary number - we assume
42    * that this method is called only after line and column are set to
43    * their actual values.
44    */

45   public int hashCode() {
46     return line + column;
47   }
48
49   /**
50    * An internal name for this expansion. This is used to generate parser
51    * routines.
52    */

53   String JavaDoc internal_name = "";
54
55   /**
56    * The parser routines are generated in three phases. The generation
57    * of the second and third phase are on demand only, and the third phase
58    * can be recursive. This variable is used to keep track of the
59    * expansions for which phase 3 generations have been already added to
60    * a list so that the recursion can be terminated.
61    */

62   boolean phase3done = false;
63
64   /**
65    * The parent of this expansion node. In case this is the top level
66    * expansion of the production it is a reference to the production node
67    * otherwise it is a reference to another Expansion node. In case this
68    * is the top level of a lookahead expansion,then the parent is null.
69    */

70   public Object JavaDoc parent;
71
72   /**
73    * The ordinal of this node with respect to its parent.
74    */

75   int ordinal;
76
77   /**
78    * To avoid right-recursive loops when calculating follow sets, we use
79    * a generation number which indicates if this expansion was visited
80    * by LookaheadWalk.genFollowSet in the same generation. New generations
81    * are obtained by incrementing the static counter below, and the current
82    * generation is stored in the non-static variable below.
83    */

84   public static long nextGenerationIndex = 1;
85   public long myGeneration = 0;
86
87   /**
88    * This flag is used for bookkeeping by the minimumSize method in class
89    * ParseEngine.
90    */

91   public boolean inMinimumSize = false;
92
93    public static void reInit()
94    {
95       nextGenerationIndex = 1;
96    }
97
98 }
99
Popular Tags