Modified:
doc/trunk/design/syn/S03.pod
Log:
Clarification on how a Grammar pattern finds its top rule.
Modified: doc/trunk/design/syn/S03.pod
==============================================================================
--- doc/trunk/design/syn/S03.pod (original)
+++ doc/trunk/design/syn/S03.pod Sun Jan 7 01:39:34 2007
@@ -12,9 +12,9 @@
Maintainer: Larry Wall <la...@wall.org>
Date: 8 Mar 2004
- Last Modified: 6 Jan 2007
+ Last Modified: 7 Jan 2007
Number: 3
- Version: 84
+ Version: 85
=head1 Changes to Perl 5 operators
@@ -756,8 +756,15 @@
If the redefinition occurs at compile time prior to analysis of the
smart match then the information is also available to the optimizer.)
-Matching against a C<Grammar> object will call the first rule defined
-in the grammar.
+Matching against a C<Grammar> object will call the C<top> method
+defined in the grammar. The C<top> method may either be a rule
+itself, or may call the actual top rule automatically. How the
+C<Grammar> determines the top rule is up to the grammar, but normal
+Perl 6 grammars will default to setting top to the first rule in the
+original base grammar. Derived grammars then inherit this idea of
+the top rule. This may be overridden in either the base grammar or a
+derived grammer by explicitly naming a rule "top", or defining your
+own top method to call some other rule.
Matching against a C<Signature> does not actually bind any variables,
but only tests to see if the signature I<could> bind. To really bind
There's a typo there -- "grammer" for "grammar".
--
Aaron Crane
if you're going to explicitly set a top rule, like a main sub, make it
all uppercase.
grammar DerivedGrammar is BaseGrammar;
rule TOP { ... }
that makes it more clear that something is special about that rule..
~jerry