DocblockGrammar.php
<?php
namespace Tlf\Lexer\Test;
class DocblockGrammar extends Tester {
protected $thingies = [
// a sample from my php grammar, just as documentation really
// 'Namespace.SeparatedName'=>[
// // 'expect_failure'=>true,
// 'start'=>['namespace'],
// 'input'=>"namespace Abc\\Def\_09;",
// 'expect'=>[
// "namespace"=> 'Abc\\Def\\_09'
// ],
// ],
'Docblock.Empty'=>[
'start'=>['/*'],
'input'=>"/**\n *\n */",
'expect.previous'=>[
"docblock"=>[
'type'=>'docblock',
'description'=>'',
]
]
],
'Docblock.MultilineWithGaps'=>[
'start'=>['/*'],
'input'=>"/**\n *\n * first \n * \n * \n * second \n * \n * \n */",
'expect.previous'=>[
"docblock"=> [
'type'=>'docblock',
'description'=>"first \n\n\nsecond ",
],
],
],
'Docblock.SameNameAttributes'=>[
'start'=>['/*'],
'input'=>" /*\n* abc \n* @cat attr-describe\n still describing def"
."\n * \n*\n @cat (did) a thing\n*/",
'expect.previous'=>[
"docblock"=> [
'type'=>'docblock',
'description'=>" abc ",
'attribute'=>[
0=>[
'type'=>'attribute',
'name'=>'cat',
'description'=>"attr-describe\n still describing def",
],
1=>[
'type'=>'attribute',
'name'=>'cat',
'description'=>"(did) a thing",
],
],
],
],
],
'Docblock.TwoAttributes'=>[
'start'=>['/*'],
'input'=>" /*\n* abc \n* @def attr-describe\n still describing def"
."\n * \n*\n @cat (did) a thing\n*/",
'expect.previous'=>[
"docblock"=> [
'type'=>'docblock',
'description'=>" abc ",
'attribute'=>[
0=>[
'type'=>'attribute',
'name'=>'def',
'description'=>"attr-describe\n still describing def",
],
1=>[
'type'=>'attribute',
'name'=>'cat',
'description'=>"(did) a thing",
],
],
],
],
],
'Docblock.WithAttribute'=>[
'start'=>['/*'],
'input'=>" /*\n* abc \n* @def attr-describe\n still describing def*/",
'expect.previous'=>[
"docblock"=> [
'type'=>'docblock',
'description'=>"abc ",
'attribute'=>[
0=>[
'type'=>'attribute',
'name'=>'def',
'description'=>"attr-describe\nstill describing def",
],
],
],
],
],
'Docblock.VariedIndents'=>[
'start'=>['/*'],
'input'=>" /*01\n * abc \n * def \n ghi*/",
'expect.previous'=>[
"docblock"=> [
'type'=>'docblock',
'description'=>"01\n abc \n def \nghi",
],
],
],
'Docblock.IndentedLines'=>[
'start'=>['/*'],
'input'=>" /* abc \n * def \n*/",
'expect.previous'=>[
"docblock"=> [
'type'=>'docblock',
'description'=>"abc\ndef ",
],
],
],
'Docblock.MultiLine2'=>[
'start'=>['/*'],
'input'=>"/*\n*\n*\n* abc \n* def \n*/",
'expect.previous'=>[
"docblock"=> [
'type'=>'docblock',
'description'=>"abc \ndef ",
],
],
],
'Docblock.MultiLine'=>[
'start'=>['/*'],
'input'=>"/** abc \n* def */",
'expect.previous'=>[
"docblock"=> [
'type'=>'docblock',
'description'=>"abc\ndef ",
],
],
],
'Docblock./**OneLine'=>[
'start'=>['/*'],
'input'=>"/** abc */",
'expect.previous'=>[
"docblock"=> [
'type'=>'docblock',
'description'=>'abc',
],
],
],
'Docblock.OneLine'=>[
'start'=>['/*'],
'input'=>"/* abc */",
'expect.previous'=>[
"docblock"=> [
'type'=>'docblock',
'description'=>'abc',
],
],
],
];
public function testDocblockDirectives(){
$docGram = new \Tlf\Lexer\DocblockGrammar();
$grammars = [
$docGram,
];
// $docGram->buildDirectives();
$this->runDirectiveTests($grammars, $this->thingies);
}
}