#=============================================================================== # # DESCRIPTION: Pod6 Grammars # # AUTHOR: Aliaksandr P. Zahatski, #=============================================================================== package Perl6::Pod::Grammars; =pod =head1 NAME Perl6::Pod::Grammars - set of grammars for Pod6 =head1 SYNOPSIS my $r = qr{ \A \Z }xms; my $tree ; if ( $src =~ $r ) { $tree = Perl6::Pod::Lex->new(%args)->make_tree( $/{File} ); } else { return undef; } =head1 DESCRIPTION Perl6::Pod::Grammars - set of grammars for Pod6 =cut our $VERSION = '0.01'; use strict; use warnings; use v5.10; use Regexp::Grammars; qr{ [ \t]* [ \t] [ \t]+ <.hs1>* \n ^ <.hs> \n (?{$MATCH{type}="file"})<[content=block_content]>+ begin | for | END | end | config code #io blocks | input | output | comment | table # Named blocks | # .*? (?:(?!^=\w+).)* # match everythig, except # it looks like directive # (?:(?!^?=\w+).)* # match everythig, except # # it looks like directive (?{ $MATCH{type} = "raw"}) | | | | | | | # | (?{ $MATCH{type} = "ambient"}) \s+ (?{ $MATCH{type} = "directive"}) ^ ? = ( ( <.newline> = )? <.hs> <[attr=pair]>+ % <.hs> )* <.newline> (?{ $MATCH{type} = "directive"}) ^ ? = <.newline> (?{ $MATCH{type} = "directive"}) ^ ? = <.hsp> ( ( <.newline> = )? <.hsp> <[text=([^\n\r]+)]> )+ <.newline> | \' \' | \" \" | (?:\=\>) \: ? (?{ $MATCH{type} = 'bool' }) ( # :key[1,2,3] \[ <[items]>+ % [,\s] \] (?{ $MATCH{type} = 'list' }) | # :key('str') \( \) (?{ $MATCH{type} = 'string' }) | # :key \< \> (?{ $MATCH{type} = 'string' }) | # :key<1 2 3> \< <[items]>+ % [\s] \> (?{ $MATCH{type} = 'list' }) | # :key{1=>1, 2=> 3 } \{ <[items=kv]>+ % <.delim=([,\s]+)> \} (?{ $MATCH{type} = 'hash' }) )? (?{ $MATCH{type} eq 'bool' && ( $MATCH{items} = $MATCH{not} ? 0 : 1 ) }) (?{ $MATCH{type} = "block"}) ^ ? =begin <.hs> ( ( <.newline> = )? <.hs> <[attr=pair]>+ % <.hs> )* <.newline> <[content=raw_content]>? ^ ? =end <.hsp> <\_name> <.hs> <.newline>? (?{ $MATCH{type} = "block"}) ^ ? =begin <.hs> ( ( <.newline> = )? <.hs> <[attr=pair]>+ % <.hs> )* <.newline> <[content=block_content]>* <.emptyline>* ^ ? =end <.hs> <\_name> <.hs> <.newline>? (?{ $MATCH{type} = "block"}) ^ ? =for <.hs> ( (?{ $MATCH{content_type} = "raw"}) | ) ( ( <.newline> = )? <.hs> <[attr=pair]>+ % <.hs> )* <.newline> <[content=text_content(:content_type)]>* <.newline>? (^ ? (?! <.emptyline> | ? \=\w+ ) # not start with directive [^\n]+ <.newline>)+ (?{ $MATCH{type} = $ARG{content_type} // "text"}) ( (?! <.emptyline> | ? \=\w+ ) # not start with directive [^\n]+ <.newline>)+ (?{ $MATCH{type} = $ARG{content_type} // "text"}) (?{ $MATCH{type} = "block"}) ^ ? = ( (?{ $MATCH{content_type} = "raw" }) | ) <.newline>? <[content=text_abbr_content(:content_type)]>* <.emptyline>? }; qr{ }; 1; __END__ =head1 SEE ALSO L, Perldoc Pod to HTML converter: L, Perl6::Pod::Lib =head1 AUTHOR Zahatski Aliaksandr, =head1 COPYRIGHT AND LICENSE Copyright (C) 2009-2015 by Zahatski Aliaksandr This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available. =cut