Skip to content

Commit

Permalink
Typographical etc. corrections to grammars.pod
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Cochrane committed Feb 5, 2015
1 parent 1124b3c commit 1891a12
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/Language/grammars.pod
Expand Up @@ -11,7 +11,7 @@ For example, Perl 6 is parsed and executed using a Perl 6-style grammar.
An example that's more practical to the common Perl 6 user is the
L<JSON::Simple module|https://github.com/moritz/json>, which can
deserialize any valid JSON file, and yet the deserializing code is
deserialize any valid JSON file, however the deserializing code is
written in less than 100 lines of simple, extensible code.
If you didn't like grammar in school, don't let that scare you off grammars.
Expand All @@ -26,8 +26,9 @@ 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>
=for code :allow<B>
my B<regex number {> \d+ [ \. \d+ ]? B<}>
=begin code :allow<B>
my B<regex number {> \d+ [ \. \d+ ]? B<}>
=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
Expand Down Expand Up @@ -115,13 +116,13 @@ be used in conjunction with the grammar.
method parse($str, :$rule = 'TOP', :$actions) returns Match:D
Matches the grammar against C<$str>, using C<$rule> as the starting rule,
optionally applying C<$actions> as actions object.
optionally applying C<$actions> as its actions object.
This will fail if the grammar does not parse the I<entire> string. If a
parse of only a part of the string is desired, use L<subparse>.
Returns the resulting L<Match> object, and also sets the caller's C<$/>
variable to the result Match object.
The method returns the resulting L<Match> object and also sets the caller's C<$/>
variable to the Match object.
=begin code :allow<B>
say CSVB<.parse>( q:to/EOCSV/ );
Expand Down Expand Up @@ -158,7 +159,7 @@ This outputs:
method subparse($str, :$rule = 'TOP', :$actions) returns Match:D
Matches the grammar against C<$str>, using C<$rule> as the starting rule,
optionally applying C<$actions> as actions object.
optionally applying C<$actions> as its actions object.
Unlike L<parse>, C<subparse> will allow the grammar to match only part
of the supplied string.
Expand All @@ -168,7 +169,7 @@ of the supplied string.
method parsefile(Cool $filename as Str, *%opts) returns Match:D
Parses the contents of the file C<$filename> with the L<parse> method,
passing along any named options in C<%opts>.
passing any named options in C<%opts>.
=head1 Action Classes
Expand Down

0 comments on commit 1891a12

Please sign in to comment.