|
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> |
|
2 <!--NewPage--> |
|
3 <html> |
|
4 <head> |
|
5 <!-- generated by pizzadoc on Thu Oct 30 13:46:18 GMT+00:00 1997 --> |
|
6 <title> |
|
7 public class G4ip.Parser |
|
8 </title> |
|
9 </head> |
|
10 <body bgcolor=FFFFFF> |
|
11 <a name="_top_"></a> |
|
12 <code><font size=-1> |
|
13 [<a href="index.html">all packages</a>] |
|
14 [<a href="G4ip.html">package G4ip</a>] |
|
15 [<a href="tree-pd.html">class hierarchy</a>] |
|
16 [<a href="names-pd.html">index</a>] |
|
17 </font></code> |
|
18 <hr> |
|
19 <h1>public class G4ip.Parser</h1> |
|
20 (source file: Parser.pizza)<br> |
|
21 <pre> |
|
22 <a href="http://java.sun.com:80/products/jdk/1.1/docs/api/java.lang.Object.html">java.lang.Object</a> |
|
23 | |
|
24 +----G4ip.Parser |
|
25 </pre> |
|
26 <hr> |
|
27 <pre> |
|
28 public class <a href="G4ip.Parser.html">Parser</a> |
|
29 </pre> |
|
30 <dl> |
|
31 <dd> A left-to-right, rightmost-derivation parser.<p> |
|
32 The following grammar is implemented:<p> |
|
33 <dl> |
|
34 <dd><u>Formula</u> ::= <u>Id</u> </dd> |
|
35 <dd><code>| false</code> </dd> |
|
36 <dd><code>|</code> ( <u>Formula</u> ) </dd> |
|
37 <dd><code>|</code> <u>Formula</u> <u>Binop</u> <u>Formula</u></dd> |
|
38 </dl><p> |
|
39 <dl> |
|
40 <dd><u>Id</u> is a string of lower case letters</dd> |
|
41 </dl><p> |
|
42 <dl> |
|
43 <dd><u>Binop</u> is either <code>&, v, -></code> or <code><-></code></dd> |
|
44 </dl><p> |
|
45 <dl> |
|
46 <dd><u>FormulaList</u> ::= <em>empty</em></dd> |
|
47 <dd><code>|</code> [ <u>FormulaList</u> ,]* <u>Formula</u></dd> |
|
48 <dl><p> |
|
49 The parser uses a stack where two actions are performed: |
|
50 <dl> |
|
51 <dd><b>shift</b> moves the next token to the top of the stack (getNextToken)</dd> |
|
52 <dd><b>reduce</b> chooses a grammar rule, X -> A B C; pops A, B, C from the |
|
53 top of the stack and pushes X onto the stack |
|
54 </dl><p></dd> |
|
55 <dd><dl><dt></dt> |
|
56 <dt> <b>Author:</b></dt> |
|
57 <dd> Christian Urban</dd> |
|
58 </dl></dd> |
|
59 </dl> |
|
60 <hr> |
|
61 <p><h2><img src="p-images/constructor-index.gif" alt="Constuctor Index"></h2> |
|
62 <dl> |
|
63 <dt><img src="p-images/yellow-ball-small.gif" alt="O "> <b><a href="G4ip.Parser.html#Parser(String)">Parser</a></b>(String) |
|
64 <dd> |
|
65 </dl> |
|
66 <p><h2><img src="p-images/method-index.gif" alt="Methods"></h2> |
|
67 <dl> |
|
68 <dt><img src="p-images/red-ball-small.gif" alt="O "> <b><a href="G4ip.Parser.html#getNextToken()">getNextToken</a></b>() |
|
69 <dd>tokens are: identifiers<code>( ) , & v -> <-> false</code> |
|
70 and <code>EOI</code> |
|
71 <dt><img src="p-images/red-ball-small.gif" alt="O "> <b><a href="G4ip.Parser.html#parseFormula()">parseFormula</a></b>() |
|
72 <dd>parses a single formula |
|
73 <dt><img src="p-images/red-ball-small.gif" alt="O "> <b><a href="G4ip.Parser.html#parseFormulae()">parseFormulae</a></b>() |
|
74 <dd>parses a list of formulae separated by commas |
|
75 <dt><img src="p-images/red-ball-small.gif" alt="O "> <b><a href="G4ip.Parser.html#reduce()">reduce</a></b>() |
|
76 <dd>Implements the grammar rules. |
|
77 </dl> |
|
78 <p><h2><img src="p-images/constructors.gif" alt="Constructors"></h2> |
|
79 <img src="p-images/yellow-ball.gif" alt="O "> <a name="<init>"></a><a name="Parser(String)"></a><b>Parser</b><br> |
|
80 <pre> |
|
81 public Parser(<a href="http://java.sun.com:80/products/jdk/1.1/docs/api/java.lang.String.html">String</a> init_in); |
|
82 </pre> |
|
83 <p> |
|
84 <p><h2><img src="p-images/methods.gif" alt="Methods"></h2> |
|
85 <img src="p-images/red-ball.gif" alt="O "> <a name="getNextToken"></a><a name="getNextToken()"></a><b>getNextToken</b><br> |
|
86 <pre> |
|
87 public <a href="G4ip.Token.html">Token</a> getNextToken() |
|
88 throws <a href="http://java.sun.com:80/products/jdk/1.1/docs/api/java.lang.Exception.html">Exception</a>; |
|
89 </pre> |
|
90 <dl> |
|
91 <dd> tokens are: identifiers<code>( ) , & v -> <-> false</code> |
|
92 and <code>EOI</code> <em>(end of input)</em> <p></dd> |
|
93 <dd><dl><dt></dt> |
|
94 <dt> <b>Overrides:</b></dt> |
|
95 <dd><dl> |
|
96 <dt><b><a href="G4ip.Parser.html#getNextToken()">getNextToken</a></b> in class <a href="G4ip.Parser.html">Parser</a></dt> |
|
97 </dl></dd> |
|
98 </dl></dd> |
|
99 </dl> |
|
100 <p> |
|
101 <img src="p-images/red-ball.gif" alt="O "> <a name="reduce"></a><a name="reduce()"></a><b>reduce</b><br> |
|
102 <pre> |
|
103 public void reduce(); |
|
104 </pre> |
|
105 <dl> |
|
106 <dd> Implements the grammar rules.<p></dd> |
|
107 <dd><dl><dt></dt> |
|
108 <dt> <b>Overrides:</b></dt> |
|
109 <dd><dl> |
|
110 <dt><b><a href="G4ip.Parser.html#reduce()">reduce</a></b> in class <a href="G4ip.Parser.html">Parser</a></dt> |
|
111 </dl></dd> |
|
112 </dl></dd> |
|
113 </dl> |
|
114 <p> |
|
115 <img src="p-images/red-ball.gif" alt="O "> <a name="parseFormula"></a><a name="parseFormula()"></a><b>parseFormula</b><br> |
|
116 <pre> |
|
117 public <a href="G4ip.Form.html">Form</a> parseFormula() |
|
118 throws <a href="http://java.sun.com:80/products/jdk/1.1/docs/api/java.lang.Exception.html">Exception</a>; |
|
119 </pre> |
|
120 <dl> |
|
121 <dd> parses a single formula<p></dd> |
|
122 <dd><dl><dt></dt> |
|
123 <dt> <b>Overrides:</b></dt> |
|
124 <dd><dl> |
|
125 <dt><b><a href="G4ip.Parser.html#parseFormula()">parseFormula</a></b> in class <a href="G4ip.Parser.html">Parser</a></dt> |
|
126 </dl></dd> |
|
127 </dl></dd> |
|
128 </dl> |
|
129 <p> |
|
130 <img src="p-images/red-ball.gif" alt="O "> <a name="parseFormulae"></a><a name="parseFormulae()"></a><b>parseFormulae</b><br> |
|
131 <pre> |
|
132 public <a href="G4ip.Context.html">Context</a> parseFormulae() |
|
133 throws <a href="http://java.sun.com:80/products/ |