Google Gruppi non supporta più i nuovi post o le nuove iscrizioni Usenet. I contenuti storici continuano a essere visibili.

[svn:perl6-synopsis] r13516 - doc/trunk/design/syn

7 visualizzazioni
Passa al primo messaggio da leggere

la...@cvs.perl.org

da leggere,
7 gen 2007, 04:39:3507/01/07
a perl6-l...@perl.org
Author: larry
Date: Sun Jan 7 01:39:34 2007
New Revision: 13516

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

Aaron Crane

da leggere,
7 gen 2007, 08:24:2707/01/07
a perl6-l...@perl.org
la...@cvs.perl.org writes:
> +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

There's a typo there -- "grammer" for "grammar".

--
Aaron Crane

Jerry Gay

da leggere,
7 gen 2007, 20:05:4807/01/07
a la...@cvs.perl.org, perl6-l...@perl.org
On 1/7/07, la...@cvs.perl.org <la...@cvs.perl.org> wrote:
> +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
>
"top"--an all lowercase reserved word? it just doesn't stand out. all
grammars i've seen and written so far have used all lower-case rule
names.

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

0 nuovi messaggi