grammar Perl6doc::Grammar is PCT::Grammar;

token TOP { [ .*? <pod_comment> ]* {*} }

token unsp { \\ <.before [\s|'#']> [ \v | \h+ ]* }

#### pod ####

## The <pod_comment> token is used to match perl 6 pod comments. ## It's currently incomplete, but so is the spec.

token pod_comment { $<block>=[ | <pod_delimited_block> | <pod_paragraph_block> | <pod_abbreviated_block> ] \n {*} }

token pod_delimited_block { ^^ '=' <.unsp>? 'begin' <.ws> <block_type> <pod_numbered>? <pod_option>* \n $<body>=(.*?):! ^^ '=' <.unsp>? 'end' <.ws> $<block_type> \N* {*} }

token pod_numbered { <.ws> '#' <.ws> }

token pod_option { [ \n '=' ]? <.ws> $<option>=[ ':' [ | [ nested | numbered | term | formatted | like | allow ] >> | <ident> ] ] }

token pod_paragraph_block { ^^ '=for' <.ws> <block_type> <pod_option>* \n $<body>=(.*?):! <.before \n ^^ [ '=' | \h* $$ ]> {*} }

token pod_abbreviated_block { ^^ '=' <block_type> <.ws> $<body>=(.*?):! <.before \n ^^ [ '=' | \h* $$ ]> }

token block_type { <ident> }


parrot