44
55== Class Block and User Code Block
66
7- There's two block on toplevel.
8- one is 'class' block, another is 'user code' block. 'user code' block MUST
9- places after 'class' block.
7+ There are two top-level blocks: the 'class' block, and the 'user code'
8+ block. The 'user code' block MUST be after the 'class' block.
109
1110== Comment
1211
13- You can insert comment about all places. Two style comment can be used,
14- Ruby style (# ..... ) and C style (/* ......*/) .
12+ Comments can be added about everywhere. Two comment styles are
13+ supported: Ruby style (`# ...` ) and C style (`/* ... */`) .
1514
1615== Class Block
1716
1817The class block is formed like this:
1918--
2019class CLASS_NAME
21- [precedance table]
22- [token declearations ]
20+ [precedence table]
21+ [token declarations ]
2322 [expected number of S/R conflict]
2423 [options]
25- [semantic value convertion ]
24+ [semantic value conversion ]
2625 [start rule]
2726rule
2827 GRAMMARS
4342
4443== Grammar Block
4544
46- The grammar block discripts grammar which is able
45+ The grammar block describes the grammar
4746to be understood by parser. Syntax is:
4847--
4948(token): (token) (token) (token).... (action)
@@ -69,7 +68,7 @@ It is value of result, or returned value by "return" statement.
6968Here is an example of whole grammar block.
7069--
7170rule
72- goal: definition ruls source { result = val }
71+ goal: definition rules source { result = val }
7372
7473 definition: /* none */ { result = [] }
7574 | definition startdesig { result[0] = val[1] }
@@ -96,7 +95,7 @@ An array of value of right-hand side (rhs).
9695A stack of values.
9796DO NOT MODIFY this stack unless you know what you are doing.
9897
99- == Operator Precedance
98+ == Operator Precedence
10099
101100This function is equal to '%prec' in yacc.
102101To designate this block:
@@ -128,25 +127,24 @@ rule
128127
129128== expect
130129
131- Racc has bison's "expect" directive.
130+ Racc supports Bison's "expect" directive to declare the expected
131+ number of shift/reduce conflicts.
132132--
133- # Example
134-
135133class MyParser
136134rule
137135 expect 3
138136 :
139137 :
140138--
141- This directive declears "expected" number of shift/reduce conflict.
142- If "expected" number is equal to real number of conflicts,
143- racc does not print confliction warning message.
139+ Then warnings are issued only when the effective number of conflicts differs.
140+
144141
145142== Declaring Tokens
146143
147- By declaring tokens, you can avoid many meanless bugs.
148- If decleared token does not exist/existing token does not decleared,
149- Racc output warnings. Declearation syntax is:
144+ Declaring tokens avoids many bugs.
145+
146+ Racc outputs warnings for declared tokens that do not exist, or existing tokens not declared.
147+ The syntax is:
150148--
151149token TOKEN_NAME AND_IS_THIS
152150 ALSO_THIS_IS AGAIN_AND_AGAIN THIS_IS_LAST
@@ -174,12 +172,12 @@ You can use 'no_' prefix to invert its meanings.
174172
175173Token symbols are, as default,
176174
177- * naked token string in racc file (TOK, XFILE, this_is_token, ...)
175+ * naked token strings in racc file (TOK, XFILE, this_is_token, ...)
178176 --> symbol (:TOK, :XFILE, :this_is_token, ...)
179- * quoted string (':', '.', '(', ...)
177+ * quoted strings (':', '.', '(', ...)
180178 --> same string (':', '.', '(', ...)
181179
182- You can change this default by "convert" block.
180+ You can change this default using a "convert" block.
183181Here is an example:
184182--
185183convert
@@ -202,18 +200,19 @@ end
202200
203201== Start Rule
204202
205- '%start' in yacc. This changes start rule .
203+ '%start' in yacc. This changes the start symbol .
206204--
207205start real_target
208206--
209- This statement will not be used forever, I think.
207+
210208
211209== User Code Block
212210
213- "User Code Block" is a Ruby source code which is copied to output.
214- There are three user code block , "header" "inner" and "footer".
211+ A "User Code Block" is a piece of Ruby source code copied in the output.
212+ There are three user code blocks , "header" "inner" and "footer".
215213
216- Format of user code is like this:
214+ User code blocks are introduced by four '-' at the beginning of a line,
215+ followed by a single-word name:
217216--
218217---- header
219218 ruby statement
@@ -225,6 +224,3 @@ Format of user code is like this:
225224 :
226225 :
227226--
228- If four '-' exist on line head,
229- racc treat it as beginning of user code block.
230- A name of user code must be one word.
0 commit comments