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 blocks on toplevel. One is 'class' block, another is 'user code'
8+ block. 'user code' block MUST be placed after 'class' block.
109
11- == Comment
10+ == Comments
1211
13- You can insert comment about all places. Two style comment can be used,
14- Ruby style (#.....) and C style (/*......*/) .
12+ You can insert comments about all places. Two style comments can be used, Ruby style '#.....' and C style '/\*......*\/'.
1513
1614== Class Block
1715
1816The class block is formed like this:
1917
2018 class CLASS_NAME
2119 [precedance table]
22- [token declearations ]
23- [expected number of S/R conflict ]
20+ [token declarations ]
21+ [expected number of S/R conflicts ]
2422 [options]
2523 [semantic value convertion]
2624 [start rule]
2725 rule
2826 GRAMMARS
2927
30- CLASS_NAME is a name of parser class.
31- This is the name of generating parser class.
28+ CLASS_NAME is a name of parser class. This is the name of generating parser
29+ class.
3230
33- If CLASS_NAME includes '::', Racc outputs module clause.
34- For example, writing "class M::C" causes creating the code bellow:
31+ If CLASS_NAME includes '::', Racc outputs module clause. For example, writing
32+ "class M::C" causes creating the code bellow:
3533
3634 module M
3735 class C
@@ -42,8 +40,8 @@ For example, writing "class M::C" causes creating the code bellow:
4240
4341== Grammar Block
4442
45- The grammar block discripts grammar which is able
46- to be understood by parser. Syntax is:
43+ The grammar block describes grammar which is able to be understood by parser.
44+ Syntax is:
4745
4846 (token): (token) (token) (token).... (action)
4947
@@ -59,28 +57,27 @@ to be understood by parser. Syntax is:
5957
6058Note that you cannot use '%' string, here document, '%r' regexp in action.
6159
62- Actions can be omitted.
63- When it is omitted, '' (empty string) is used.
60+ Actions can be omitted. When it is omitted, '' (empty string) is used.
6461
65- A return value of action is a value of left side value ($$).
66- It is value of result, or returned value by " return" statement.
62+ A return value of action is a value of left side value ($$). It is value of
63+ result, or returned value by ` return` statement.
6764
6865Here is an example of whole grammar block.
6966
7067 rule
71- goal: definition ruls source { result = val }
68+ goal: definition rules source { result = val }
7269
7370 definition: /* none */ { result = [] }
7471 | definition startdesig { result[0] = val[1] }
7572 | definition
76- precrule # this line continue from upper line
73+ precrule # this line continues from upper line
7774 {
7875 result[1] = val[1]
7976 }
8077
8178 startdesig: START TOKEN
8279
83- You can use following special local variables in action.
80+ You can use the following special local variables in action:
8481
8582* result ($$)
8683
@@ -92,8 +89,7 @@ An array of value of right-hand side (rhs).
9289
9390* _values (...$-2,$-1,$0)
9491
95- A stack of values.
96- DO NOT MODIFY this stack unless you know what you are doing.
92+ A stack of values. DO NOT MODIFY this stack unless you know what you are doing.
9793
9894== Operator Precedence
9995
@@ -107,9 +103,9 @@ To designate this block:
107103 right '='
108104 preclow
109105
110- `right' is yacc's %right, `left' is yacc's %left.
106+ `right` is yacc's %right, `left` is yacc's %left.
111107
112- `=' + (symbol) means yacc's %prec:
108+ `=` + (symbol) means yacc's %prec:
113109
114110 prechigh
115111 nonassoc UMINUS
@@ -136,42 +132,42 @@ Racc has bison's "expect" directive.
136132 :
137133 :
138134
139- This directive declears "expected" number of shift/reduce conflict.
140- If "expected" number is equal to real number of conflicts,
141- racc does not print confliction warning message.
135+ This directive declares "expected" number of shift/reduce conflicts. If
136+ "expected" number is equal to real number of conflicts, Racc does not print
137+ conflict warning message.
142138
143139== Declaring Tokens
144140
145- By declaring tokens, you can avoid many meanless bugs.
146- If decleared token does not exist/ existing token does not decleared,
147- Racc output warnings. Declearation syntax is:
141+ By declaring tokens, you can avoid many meaningless bugs. If declared token
142+ does not exist or existing token does not decleared, Racc output warnings.
143+ Declaration syntax is:
148144
149145 token TOKEN_NAME AND_IS_THIS
150146 ALSO_THIS_IS AGAIN_AND_AGAIN THIS_IS_LAST
151147
152148== Options
153149
154- You can write options for racc command in your racc file.
150+ You can write options for Racc command in your Racc file.
155151
156152 options OPTION OPTION ...
157153
158154Options are:
159155
160156* omit_action_call
161157
162- omit empty action call or not.
158+ omits empty action call or not.
163159
164160* result_var
165161
166- use/does not use local variable "result"
162+ uses local variable "result" or not.
167163
168- You can use 'no_' prefix to invert its meanings.
164+ You can use 'no_' prefix to invert their meanings.
169165
170166== Converting Token Symbol
171167
172168Token symbols are, as default,
173169
174- * naked token string in racc file (TOK, XFILE, this_is_token, ...)
170+ * naked token string in Racc file (TOK, XFILE, this_is_token, ...)
175171 --> symbol (:TOK, :XFILE, :this_is_token, ...)
176172 * quoted string (':', '.', '(', ...)
177173 --> same string (':', '.', '(', ...)
@@ -185,7 +181,7 @@ Here is an example:
185181 end
186182
187183We can use almost all ruby value can be used by token symbol,
188- except 'false' and 'nil'. These are causes unexpected parse error.
184+ except 'false' and 'nil'. These cause unexpected parse error.
189185
190186If you want to use String as token symbol, special care is required.
191187For example:
@@ -202,12 +198,10 @@ For example:
202198
203199 start real_target
204200
205- This statement will not be used forever, I think.
206-
207201== User Code Block
208202
209- "User Code Block" is a Ruby source code which is copied to output.
210- There are three user code block , "header" "inner" and "footer".
203+ "User Code Block" is a Ruby source code which is copied to output. There are
204+ three user code blocks , "header" "inner" and "footer".
211205
212206Format of user code is like this:
213207
@@ -221,6 +215,5 @@ Format of user code is like this:
221215 :
222216 :
223217
224- If four '-' exist on line head,
225- racc treat it as beginning of user code block.
226- A name of user code must be one word.
218+ If four '-' exist on line head, Racc treat it as beginning of user code block.
219+ The name of user code block must be one word.
0 commit comments