GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  PUGS::COMPILER::GRAMMAR (3)

.ds Aq ’

NAME

Pugs::Compiler::Grammar - Compiler for Perl 6 Grammars

CONTENTS

SYNOSPIS



    use Pugs::Compiler::Grammar;
    my $grammar = q{
        grammar MyC;

        token def {
            <type> <?ws> <var_list> <?ws>? ;
        }

        token type { int | float | double | char }

        token var_list {
            <ident>**{1} <?ws>? [ , <?ws>? <ident> ]*
        }

        grammar MyVB;

        token def {
            Dim <?ws> <MyC.var_list>
            [ <?ws> As <?ws> <MyC.type> ]? <?ws>? ;
        }
    };
    my $obj = Pugs::Compiler::Grammar->compile($grammar);
    my $perl5 = $obj->perl5;
    eval $perl5; die $@ if $@;
    my $match = MyC->def("float foo;");
    print "type: ", $match->{type}, "\n";
    print "vars: ", $match->{var_list}, "\n";
    $match = MyVB->def("Dim foo, bar;");
    print "vars: ", $match->{MyC.var_list}, "\n";



METHODS

$obj = Pugs::Compile::Grammar->compile($src) Acts as contructor. Accepts a string containing the grammar specs and returns a Pugs::Compiler::Grammar instance.
$perl5 = $obj->perl5() Returns a string containing the Perl source for the grammars compiled.

AUTHOR

The Pugs contributors <perl6-compiler@perl.org>.

COPYRIGHT

Copyright 2007 by Agent Zhang and others.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See <http://www.perl.com/perl/misc/Artistic.html>

SEE ALSO

compile_p6grammar.pl, Pugs::Compiler::Regex, Pugs::Grammar::Rule, Pugs::Emitter::Grammar::Perl5.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 PUGS::COMPILER::GRAMMAR (3) 2008-07-29

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.