directives.php
<?php
return [
'/*'=>[
'is'=>[
':docblock',
],
],
/**
* Start of a docblock that uses `/*` (or `/**`
*/
'docblock'=>[
'start'=>[
'match'=>'/\\/\*/',
'ast.new'=>[
'_setHead'=>true,
'type'=>'docblock',
],
'then :star',
'then :attribute',
'then :newline',
'then :docblock_end',
//'then :string',
//'then :whitespace',
'previous.set line' => '',
'buffer.clear',
],
'stop'=>[
'match'=>'*/',
// 'directive.pop 1',
'rewind 2',
//'this:processDocblock',
'forward 2',
'buffer.clear',
]
],
/**
* For other directives to start. Handles clearing the stack
*/
'docblock_end'=>[
'start' => [
'match' => '*/',
'rewind 2',
'previous.append line !' => '_token:buffer',
'buffer.clear',
'forward 2',
'buffer.clear',
'ast.set description !' => '_lexer:previous line',
'buffer.clear',
'stop',
],
],
'star'=>[
'start'=>[
'match'=>'/^\s*\*/',
'buffer.not_match_next 1' => '/\//',
// next char match
'buffer.clear',
'stop',
],
],
'attribute'=>[
'start'=>[
'match'=>'/^\s*\@([a-zA-Z\_0-9]+)[^a-zA-Z\_0-9]/',
'ast.new'=>[
'type'=>'attribute',
'_setHead'=>true,
'_addto'=>'attribute',
'name !'=>'_token:match 1',
'description'=>'',
],
'then +:emptyline'=>[],
'then +:attribute'=>[],
],
'stop'=>[
// Another attribute or a full, blank line?
],
],
'newline'=>[
'start'=>[
'match'=> "/\r?\n/",
'previous.append line !' => '_token:buffer',
'buffer.clear',
'stop',
],
],
//'string'=>[
//'start'=>[
//'match'=>'/[^\s\*]/',
//'directive.add_started :docblock_end',
//'ast.append description',
//'buffer.clear',
//],
//'match'=>[
//'not_match'=>'/(\*|\*\/)/',
//'ast.append description',
//'buffer.clear',
//],
//'stop'=>[
//'match'=>'/(\r\n|\n)/',
//],
//],
//'whitespace'=>[
//'start'=>[
//'match'=>'/\s+$/',
//'buffer.clear',
//'stop'
//],
//],
];