From 1891a12e12c3ad93ef9e1de060e47617082a3da1 Mon Sep 17 00:00:00 2001 From: Paul Cochrane Date: Thu, 5 Feb 2015 10:16:45 +0100 Subject: [PATCH] Typographical etc. corrections to grammars.pod --- lib/Language/grammars.pod | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/Language/grammars.pod b/lib/Language/grammars.pod index 815eff308..5efd3fc2f 100644 --- a/lib/Language/grammars.pod +++ b/lib/Language/grammars.pod @@ -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, 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. @@ -26,8 +26,9 @@ document, I regexes have a special syntax, similar to subroutine definitions:N -=for code :allow -my B \d+ [ \. \d+ ]? B<}> + =begin code :allow + my B \d+ [ \. \d+ ]? B<}> + =end code In this case, we have to specify that the regex is lexically scoped using the C keyword, because named regexes are normally used within @@ -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 string. If a parse of only a part of the string is desired, use L. -Returns the resulting L object, and also sets the caller's C<$/> -variable to the result Match object. +The method returns the resulting L object and also sets the caller's C<$/> +variable to the Match object. =begin code :allow say CSVB<.parse>( q:to/EOCSV/ ); @@ -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, C will allow the grammar to match only part of the supplied string. @@ -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 method, -passing along any named options in C<%opts>. +passing any named options in C<%opts>. =head1 Action Classes