@@ -162,8 +162,8 @@ simply take the C<.made> value from the C«$<calc-op>» match object. And the
162
162
actions for individual alternations now follow the same naming pattern as in the
163
163
grammar: C « method calc-op:sym<add> » and C « method calc-op:sym<sub> » .
164
164
165
- The real beauty of this method can be seen when you subclass that grammar
166
- and actions class . Let's say we want to add a multiplication feature to the
165
+ The real beauty of this method can be seen when you subclass the grammar
166
+ and action classes . Let's say we want to add a multiplication feature to the
167
167
calculator:
168
168
169
169
= begin code :preamble<grammar Calculator {}; class Calculations {}>
@@ -180,7 +180,7 @@ calculator:
180
180
# OUTPUT: «6»
181
181
= end code
182
182
183
- All we had to add are additional rule and action to the C < calc-op > group and
183
+ All we had to add are an additional rule and action to the C < calc-op > group and
184
184
the thing works—all thanks to proto regexes.
185
185
186
186
= head2 Special tokens
@@ -193,12 +193,12 @@ the thing works—all thanks to proto regexes.
193
193
}
194
194
195
195
The C < TOP > token is the default first token attempted to match
196
- when parsing with a grammar. Note that if you're parsing with
196
+ when parsing with a grammar. Note that if you're parsing with the
197
197
L < C < .parse > |/type/Grammar#method_parse> method, C < token TOP > is automatically
198
198
anchored to the start and end of the string. If you don't want to parse the
199
199
whole string, look up L < C < .subparse > |/type/Grammar#method_subparse> .
200
200
201
- Using C < rule TOP > or C < regex TOP > are also acceptable.
201
+ Using C < rule TOP > or C < regex TOP > is also acceptable.
202
202
203
203
A different token can be chosen to be matched first using the C < :rule > named
204
204
argument to C < .parse > , C < .subparse > , or C < .parsefile > . These are all C < Grammar >
@@ -225,8 +225,8 @@ Please bear in mind that we're preceding C<ws> with a dot to avoid capturing,
225
225
which we are not interested in. Since in general whitespace is a separator, this
226
226
is how it's mostly found.
227
227
228
- When C < rule > instead of C < token > is used , C < :sigspace > is enabled by default and
229
- any whitespace after terms and closing parenthesis/brackets is turned into a
228
+ When C < rule > is used instead of C < token > , C < :sigspace > is enabled by default and
229
+ any whitespace after terms and closing parenthesis/brackets are turned into a
230
230
non-capturing call to C < ws > , written as C « <.ws> » where C < . > means non-capturing.
231
231
That is to say:
232
232
@@ -263,11 +263,11 @@ the C<:sym> adverb for that particular regex:
263
263
grammar Foo {
264
264
token TOP { <letter>+ }
265
265
proto token letter {*}
266
- token letter:sym<P> { <sym> }
267
- token letter:sym<e> { <sym> }
268
- token letter:sym<r> { <sym> }
269
- token letter:sym<l> { <sym> }
270
- token letter:sym<*> { . }
266
+ token letter:sym<P> { <sym> }
267
+ token letter:sym<e> { <sym> }
268
+ token letter:sym<r> { <sym> }
269
+ token letter:sym<l> { <sym> }
270
+ token letter:sym<*> { . }
271
271
}.parse("I ♥ Perl", actions => class {
272
272
method TOP($/) { make $<letter>.grep(*.<sym>).join }
273
273
}).made.say; # OUTPUT: «Perl»
@@ -321,8 +321,8 @@ as they return a L<Match|/type/Match>:
321
321
token num-basic { <[0..9]>+ }
322
322
}
323
323
324
- The grammar above will attempt different matches depending on the arguments
325
- provided by parse methods:
324
+ The grammar above will attempt different matches depending on the argument
325
+ provided to the subparse methods:
326
326
327
327
= begin code :preamble<grammar DigitMatcher{};>
328
328
say +DigitMatcher.subparse: '12७१७९०९', args => \(:full-unicode);
0 commit comments