Skip to content

Commit dc091d3

Browse files
authored
Merge pull request #2947 from gdonald/grammer-improvements
Improve readability. Adjust token `letter` indentation.
2 parents 1853164 + f22ea17 commit dc091d3

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

doc/Language/grammars.pod6

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ simply take the C<.made> value from the C«$<calc-op>» match object. And the
162162
actions for individual alternations now follow the same naming pattern as in the
163163
grammar: C«method calc-op:sym<add>» and C«method calc-op:sym<sub>».
164164
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
167167
calculator:
168168
169169
=begin code :preamble<grammar Calculator {}; class Calculations {}>
@@ -180,7 +180,7 @@ calculator:
180180
# OUTPUT: «6␤»
181181
=end code
182182
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
184184
the thing works—all thanks to proto regexes.
185185
186186
=head2 Special tokens
@@ -193,12 +193,12 @@ the thing works—all thanks to proto regexes.
193193
}
194194
195195
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
197197
L<C<.parse>|/type/Grammar#method_parse> method, C<token TOP> is automatically
198198
anchored to the start and end of the string. If you don't want to parse the
199199
whole string, look up L<C<.subparse>|/type/Grammar#method_subparse>.
200200
201-
Using C<rule TOP> or C<regex TOP> are also acceptable.
201+
Using C<rule TOP> or C<regex TOP> is also acceptable.
202202
203203
A different token can be chosen to be matched first using the C<:rule> named
204204
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,
225225
which we are not interested in. Since in general whitespace is a separator, this
226226
is how it's mostly found.
227227
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
230230
non-capturing call to C<ws>, written as C«<.ws>» where C<.> means non-capturing.
231231
That is to say:
232232
@@ -263,11 +263,11 @@ the C<:sym> adverb for that particular regex:
263263
grammar Foo {
264264
token TOP { <letter>+ }
265265
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<*> { . }
271271
}.parse("I ♥ Perl", actions => class {
272272
method TOP($/) { make $<letter>.grep(*.<sym>).join }
273273
}).made.say; # OUTPUT: «Perl␤»
@@ -321,8 +321,8 @@ as they return a L<Match|/type/Match>:
321321
token num-basic { <[0..9]>+ }
322322
}
323323
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:
326326
327327
=begin code :preamble<grammar DigitMatcher{};>
328328
say +DigitMatcher.subparse: '12७१७९०९', args => \(:full-unicode);

0 commit comments

Comments
 (0)