Пример #1
0
 public function __construct(PEG_IParser $elt)
 {
     $dt = PEG::many(PEG::subtract($elt, ':'));
     $dd = PEG::many($elt);
     $this->parser = PEG::many1(PEG::callbackAction(array($this, 'map'), PEG::anything()));
     $this->definitionList = PEG::seq(PEG::drop('-'), $dt, PEG::drop(':'), $dd);
 }
Пример #2
0
 protected function createImageLink()
 {
     $ext = PEG::choice('.jpg', '.png', '.gif');
     $src_char = PEG::pack('[', PEG::seq(PEG::many1(PEG::subtract($this->lineChar, ']', $ext)), $ext), ']');
     $src = PEG::join($src_char);
     $alt_char = PEG::pack('[', PEG::many1(PEG::subtract($this->lineChar, ']')), ']');
     $alt = PEG::join($alt_char);
     $parser = PEG::seq($src, PEG::optional($alt));
     return $this->nodeCreater(OrgModeSyntax_Node::TYPE_IMAGELINK, $parser, array('src', 'alt'));
 }
Пример #3
0
 function __construct(PEG_IParser $elt)
 {
     $this->line = PEG::many($elt);
     $end = new HatenaSyntax_Regex('/\\|<$/');
     $this->parser = PEG::callbackAction(array($this, 'map'), PEG::seq(PEG::drop('>|'), PEG::many(PEG::subtract(PEG::anything(), $end)), $end));
 }
Пример #4
0
 protected function createNullLink()
 {
     $body = PEG::join(PEG::many1(PEG::subtract($this->lineChar, '[]')));
     $parser = PEG::pack(']', $body, '[');
     return $parser;
 }
Пример #5
0
 function __construct(PEG_IParser $child)
 {
     $this->child = $child;
     $this->parser = PEG::seq(PEG::callbackAction(array($this, 'mapHeader'), PEG::anything()), PEG::many(PEG::subtract($this->child, '<<')), PEG::drop('<<'));
 }
Пример #6
0
 function __construct(PEG_IParser $lineelt)
 {
     $cellbody = PEG::many(PEG::subtract($lineelt, '|'));
     $this->parser = PEG::many1(PEG::callbackAction(array($this, 'map'), PEG::anything()));
     $this->line = PEG::second('|', PEG::many1(PEG::optional('*'), $cellbody, PEG::drop('|')), PEG::eos());
 }
Пример #7
0
 public function __construct(PEG_IParser $element)
 {
     $open = PEG::second('<', PEG::choice('del', 'strong', 'ins', 'em'), '>');
     $close = PEG::second('</', PEG::choice('del', 'strong', 'ins', 'em'), '>');
     $this->parser = PEG::seq($open, PEG::many(PEG::subtract($element, $close)), $close);
 }
Пример #8
0
 function __construct()
 {
     $end = new HatenaSyntax_Regex('/\\|\\|<$/');
     $this->parser = PEG::callbackAction(array($this, 'map'), PEG::seq($this->header(), PEG::many(PEG::subtract(PEG::anything(), $end)), $end));
 }
Пример #9
0
 function __construct(PEG_IParser $element)
 {
     $end = new HatenaSyntax_Regex('#</p><$#');
     $this->lineParser = PEG::many($element);
     $this->parser = PEG::seq(PEG::many(PEG::subtract(PEG::anything(), $end)), $end);
 }
Пример #10
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');