示例#1
0
文件: ListOf.php 项目: ngyuki/PHPPEG
<?php

include_once dirname(__FILE__) . '/t/t.php';
$t = new lime_test();
$parser = PEG::listof(PEG::char('abc'), PEG::token(','));
$context = PEG::context('a,b,c');
$t->is($parser->parse($context), array('a', 'b', 'c'));
$t->ok($context->eos());
示例#2
0
<?php

include_once dirname(__FILE__) . '/t/t.php';
$t = new lime_test();
$p = PEG::subtract(PEG::char('abc'), 'a');
$t->is($p->parse(PEG::context('a')), PEG::failure());
$t->is($p->parse(PEG::context('b')), 'b');
示例#3
0
 public function __construct(PEG_IParser $lineelt)
 {
     $item = PEG::callbackAction(array($this, 'mapLine'), PEG::anything());
     $this->parser = PEG::callbackAction(array('OrgModeSyntax_Tree', 'make'), PEG::many1($item));
     $this->li = PEG::callbackAction(array('OrgModeSyntax_Util', 'processListItem'), PEG::seq(PEG::many(PEG::char('+')), PEG::many($lineelt)));
 }
示例#4
0
文件: Char.php 项目: ngyuki/PHPPEG
<?php

include_once dirname(__FILE__) . '/t/t.php';
$t = new lime_test();
$p = PEG::char('abc');
$t->is($p->parse(PEG::context('a')), 'a');
$t->is($p->parse(PEG::context('d')), PEG::failure());
$p = PEG::char('abc', true);
$t->is($p->parse(PEG::context('b')), PEG::failure());
$t->is($p->parse(PEG::context('d')), 'd');
$p = PEG::char('0');
$t->ok($p->parse(PEG::context('')) instanceof PEG_Failure);