Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Deindent
  • Loading branch information
JJ committed Jun 1, 2019
1 parent bbe06be commit 2cb9441
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions doc/Language/grammars.pod6
Expand Up @@ -26,20 +26,20 @@ of this document, I<named> regexes have a special syntax, similar to
subroutine definitions: N<In fact, named regexes can even take extra
arguments, using the same syntax as subroutine parameter lists>
=begin code
my regex number { \d+ [ \. \d+ ]? }
=end code
=begin code
my regex number { \d+ [ \. \d+ ]? }
=end code
In this case, we have to specify that the regex is lexically scoped using
the C<my> keyword, because named regexes are normally used within grammars.
Being named gives us the advantage of being able to easily reuse the regex
elsewhere:
=begin code :preamble<my regex number{...};>
say so "32.51" ~~ &number; # OUTPUT: «True␤»
say so "15 + 4.5" ~~ /<number>\s* '+' \s*<number>/ # OUTPUT: «True␤»
=end code
=begin code :preamble<my regex number{...};>
say so "32.51" ~~ &number; # OUTPUT: «True␤»
say so "15 + 4.5" ~~ /<number>\s* '+' \s*<number>/ # OUTPUT: «True␤»
=end code
B<C<regex>> isn't the only declarator for named regexes. In fact, it's the
least common. Most of the time, the B<C<token>> or B<C<rule>> declarators
Expand Down Expand Up @@ -151,7 +151,7 @@ adverbs on tokens:
# OUTPUT: «5␤»
In the grammar, the alternation has now been replaced with C«<calc-op>»,
In this grammar the alternation has now been replaced with C«<calc-op>»,
which is essentially the name of a group of values we'll create. We do so by
defining a rule prototype with C<proto rule calc-op>. Each of our previous
alternations have been replaced by a new C<rule calc-op> definition and the
Expand Down

0 comments on commit 2cb9441

Please sign in to comment.