Great PHP Symbol Renaming; debug build works, optimised build segfaults. is it gcc? fuck it all and let travis sort it out
This commit is contained in:
parent
bd48af7b90
commit
b9ce12f3b6
40 changed files with 228 additions and 192 deletions
|
|
@ -19,20 +19,20 @@ class ActionTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = action(sequence(choice(ch("a"), ch("A")), choice(ch("b"), ch("B"))), "actTest");
|
||||
$this->parser = hammer_action(hammer_sequence(hammer_choice(hammer_ch("a"), hammer_ch("A")), hammer_choice(hammer_ch("b"), hammer_ch("B"))), "actTest");
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
$result1 = h_parse($this->parser, "ab");
|
||||
$result2 = h_parse($this->parser, "AB");
|
||||
$result3 = h_parse($this->parser, "aB");
|
||||
$result1 = hammer_parse($this->parser, "ab");
|
||||
$result2 = hammer_parse($this->parser, "AB");
|
||||
$result3 = hammer_parse($this->parser, "aB");
|
||||
$this->assertEquals(["A", "B"], $result1);
|
||||
$this->assertEquals(["A", "B"], $result2);
|
||||
$this->assertEquals(["A", "B"], $result3);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "XX");
|
||||
$result = hammer_parse($this->parser, "XX");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,26 +9,26 @@ class AndTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser1 = sequence(h_and(ch("0")), ch("0"));
|
||||
$this->parser2 = sequence(h_and(ch("0")), ch("1"));
|
||||
$this->parser3 = sequence(ch("1"), h_and(ch("2")));
|
||||
$this->parser1 = hammer_sequence(hammer_and(hammer_ch("0")), hammer_ch("0"));
|
||||
$this->parser2 = hammer_sequence(hammer_and(hammer_ch("0")), hammer_ch("1"));
|
||||
$this->parser3 = hammer_sequence(hammer_ch("1"), hammer_and(hammer_ch("2")));
|
||||
}
|
||||
|
||||
public function testSuccess1()
|
||||
{
|
||||
$result = h_parse($this->parser1, "0");
|
||||
$result = hammer_parse($this->parser1, "0");
|
||||
$this->assertEquals(array("0"), $result);
|
||||
}
|
||||
|
||||
public function testFailure2()
|
||||
{
|
||||
$result = h_parse($this->parser2, "0");
|
||||
$result = hammer_parse($this->parser2, "0");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
|
||||
public function testSuccess3()
|
||||
{
|
||||
$result = h_parse($this->parser3, "12");
|
||||
$result = hammer_parse($this->parser3, "12");
|
||||
$this->assertEquals(array("1"), $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,27 +8,27 @@ class ButNotTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser1 = h_butnot(ch("a"), h_token("ab"));
|
||||
$this->parser2 = h_butnot(h_ch_range('0', '9'), ch('6'));
|
||||
$this->parser1 = hammer_butnot(hammer_ch("a"), hammer_token("ab"));
|
||||
$this->parser2 = hammer_butnot(hammer_ch_range('0', '9'), hammer_ch('6'));
|
||||
}
|
||||
|
||||
public function testSuccess1()
|
||||
{
|
||||
$result1 = h_parse($this->parser1, "a");
|
||||
$result2 = h_parse($this->parser1, "aa");
|
||||
$result1 = hammer_parse($this->parser1, "a");
|
||||
$result2 = hammer_parse($this->parser1, "aa");
|
||||
$this->assertEquals("a", $result1);
|
||||
$this->assertEquals("a", $result1);
|
||||
}
|
||||
|
||||
public function testFailure1()
|
||||
{
|
||||
$result = h_parse($this->parser1, "ab");
|
||||
$result = hammer_parse($this->parser1, "ab");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
|
||||
public function testFailure2()
|
||||
{
|
||||
$result = h_parse($this->parser2, "6");
|
||||
$result = hammer_parse($this->parser2, "6");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,16 +8,16 @@ class ChRangeTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = ch_range("a", "c");
|
||||
$this->parser = hammer_ch_range("a", "c");
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, "b");
|
||||
$result = hammer_parse($this->parser, "b");
|
||||
$this->assertEquals("b", $result);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "d");
|
||||
$result = hammer_parse($this->parser, "d");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,16 +8,16 @@ class ChTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = ch("\xa2");
|
||||
$this->parser = hammer_ch("\xa2");
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, "\xa2");
|
||||
$result = hammer_parse($this->parser, "\xa2");
|
||||
$this->assertEquals("\xa2", $result);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "95");
|
||||
$result = hammer_parse($this->parser, "95");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,20 +7,20 @@ class ChoiceTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = choice(ch("a"), ch("b"));
|
||||
$this->parser = hammer_choice(hammer_ch("a"), hammer_ch("b"));
|
||||
}
|
||||
|
||||
public function testSuccess()
|
||||
{
|
||||
$result1 = h_parse($this->parser, "a");
|
||||
$result2 = h_parse($this->parser, "b");
|
||||
$result1 = hammer_parse($this->parser, "a");
|
||||
$result2 = hammer_parse($this->parser, "b");
|
||||
$this->assertEquals("a", $result1);
|
||||
$this->assertEquals("b", $result2);
|
||||
}
|
||||
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "c");
|
||||
$result = hammer_parse($this->parser, "c");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,18 +7,18 @@ class DifferenceTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_difference(h_token("ab"), ch("a"));
|
||||
$this->parser = hammer_difference(hammer_token("ab"), hammer_ch("a"));
|
||||
}
|
||||
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, "ab");
|
||||
$result = hammer_parse($this->parser, "ab");
|
||||
$this->assertEquals("ab", $result);
|
||||
}
|
||||
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "a");
|
||||
$result = hammer_parse($this->parser, "a");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,17 +7,17 @@ class EndPTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = sequence(ch("a"), h_end_p());
|
||||
$this->parser = hammer_sequence(hammer_ch("a"), hammer_end());
|
||||
}
|
||||
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, "a");
|
||||
$result = hammer_parse($this->parser, "a");
|
||||
$this->assertEquals(array("a"), $result);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "aa");
|
||||
$result = hammer_parse($this->parser, "aa");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,26 +9,26 @@ class EpsilonPTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser1 = sequence(ch("a"), h_epsilon_p(), ch("b"));
|
||||
$this->parser2 = sequence(h_epsilon_p(), ch("a"));
|
||||
$this->parser3 = sequence(ch("a"), h_epsilon_p());
|
||||
$this->parser1 = hammer_sequence(hammer_ch("a"), hammer_epsilon(), hammer_ch("b"));
|
||||
$this->parser2 = hammer_sequence(hammer_epsilon(), hammer_ch("a"));
|
||||
$this->parser3 = hammer_sequence(hammer_ch("a"), hammer_epsilon());
|
||||
}
|
||||
|
||||
public function testSuccess1()
|
||||
{
|
||||
$result = h_parse($this->parser1, "ab");
|
||||
$result = hammer_parse($this->parser1, "ab");
|
||||
$this->assertEquals(array("a", "b"), $result);
|
||||
}
|
||||
|
||||
public function testSuccess2()
|
||||
{
|
||||
$result = h_parse($this->parser2, "a");
|
||||
$result = hammer_parse($this->parser2, "a");
|
||||
$this->assertEquals(array("a"), $result);
|
||||
}
|
||||
|
||||
public function testSuccess3()
|
||||
{
|
||||
$result = h_parse($this->parser3, "ab");
|
||||
$result = hammer_parse($this->parser3, "ab");
|
||||
$this->assertEquals(array("a"), $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,18 +7,18 @@ class IgnoreTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = sequence(ch("a"), h_ignore(ch("b")), ch("c"));
|
||||
$this->parser = hammer_sequence(hammer_ch("a"), hammer_ignore(hammer_ch("b")), hammer_ch("c"));
|
||||
}
|
||||
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, "abc");
|
||||
$result = hammer_parse($this->parser, "abc");
|
||||
$this->assertEquals(array("a", "c"), $result);
|
||||
}
|
||||
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "ac");
|
||||
$result = hammer_parse($this->parser, "ac");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@ class InTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = in("abc");
|
||||
$this->parser = hammer_in("abc");
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, "b");
|
||||
$result = hammer_parse($this->parser, "b");
|
||||
$this->assertEquals("b", $result);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "d");
|
||||
$result = hammer_parse($this->parser, "d");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,22 +8,22 @@ class Int16Test extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_int16();
|
||||
$this->parser = hammer_int16();
|
||||
}
|
||||
public function testNegative()
|
||||
{
|
||||
$result = h_parse($this->parser, "\xfe\x00");
|
||||
$result = hammer_parse($this->parser, "\xfe\x00");
|
||||
$this->assertEquals(-0x200, $result);
|
||||
}
|
||||
public function testPositive() {
|
||||
$result = h_parse($this->parser, "\x02\x00");
|
||||
$result = hammer_parse($this->parser, "\x02\x00");
|
||||
$this->assertEquals(0x200, $result);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "\xfe");
|
||||
$result = hammer_parse($this->parser, "\xfe");
|
||||
$this->assertEquals(NULL, $result);
|
||||
$result = h_parse($this->parser, "\x02");
|
||||
$result = hammer_parse($this->parser, "\x02");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,23 +8,23 @@ class Int32Test extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_int32();
|
||||
$this->parser = hammer_int32();
|
||||
}
|
||||
public function testNegative()
|
||||
{
|
||||
$result = h_parse($this->parser, "\xff\xfe\x00\x00");
|
||||
$result = hammer_parse($this->parser, "\xff\xfe\x00\x00");
|
||||
$this->assertEquals(-0x20000, $result);
|
||||
}
|
||||
public function testPositive()
|
||||
{
|
||||
$result = h_parse($this->parser, "\x00\x02\x00\x00");
|
||||
$result = hammer_parse($this->parser, "\x00\x02\x00\x00");
|
||||
$this->assertEquals(0x20000, $result);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "\xff\xfe\x00");
|
||||
$result = hammer_parse($this->parser, "\xff\xfe\x00");
|
||||
$this->assertEquals(NULL, $result);
|
||||
$result = h_parse($this->parser, "\x00\x02\x00");
|
||||
$result = hammer_parse($this->parser, "\x00\x02\x00");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,16 +8,16 @@ class Int64Test extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_int64();
|
||||
$this->parser = hammer_int64();
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, "\xff\xff\xff\xfe\x00\x00\x00\x00");
|
||||
$result = hammer_parse($this->parser, "\xff\xff\xff\xfe\x00\x00\x00\x00");
|
||||
$this->assertEquals(-0x200000000, $result);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "\xff\xff\xff\xfe\x00\x00\x00");
|
||||
$result = hammer_parse($this->parser, "\xff\xff\xff\xfe\x00\x00\x00");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,16 +8,16 @@ class Int8Test extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_int8();
|
||||
$this->parser = hammer_int8();
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, "\x88");
|
||||
$result = hammer_parse($this->parser, "\x88");
|
||||
$this->assertEquals(-0x78, $result);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "");
|
||||
$result = hammer_parse($this->parser, "");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@ class IntRangeTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_int_range(h_uint8(), 3, 10);
|
||||
$this->parser = hammer_int_range(hammer_uint8(), 3, 10);
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, "\x05");
|
||||
$result = hammer_parse($this->parser, "\x05");
|
||||
$this->assertEquals(5, $result);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "\xb");
|
||||
$result = hammer_parse($this->parser, "\xb");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,18 +7,18 @@ class LeftTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_left(ch("a"), ch(" "));
|
||||
$this->parser = hammer_left(hammer_ch("a"), hammer_ch(" "));
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, "a ");
|
||||
$result = hammer_parse($this->parser, "a ");
|
||||
$this->assertEquals("a", $result);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result1 = h_parse($this->parser, "a");
|
||||
$result2 = h_parse($this->parser, " ");
|
||||
$result3 = h_parse($this->parser, "ab");
|
||||
$result1 = hammer_parse($this->parser, "a");
|
||||
$result2 = hammer_parse($this->parser, " ");
|
||||
$result3 = hammer_parse($this->parser, "ab");
|
||||
$this->assertEquals(NULL, $result1);
|
||||
$this->assertEquals(NULL, $result2);
|
||||
$this->assertEquals(NULL, $result3);
|
||||
|
|
|
|||
|
|
@ -7,27 +7,27 @@ class LeftrecTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_indirect();
|
||||
h_bind_indirect($this->parser, choice(sequence($this->parser, ch("a")), ch("a")));
|
||||
$this->parser = hammer_indirect();
|
||||
hammer_bind_indirect($this->parser, hammer_choice(hammer_sequence($this->parser, hammer_ch("a")), hammer_ch("a")));
|
||||
}
|
||||
|
||||
public function testSuccess1()
|
||||
{
|
||||
$result = h_parse($this->parser, "a");
|
||||
$result = hammer_parse($this->parser, "a");
|
||||
$this->assertEquals("a", $result);
|
||||
}
|
||||
/* These don't work in the underlying C so they won't work here either */
|
||||
/*
|
||||
public function testSuccess2()
|
||||
{
|
||||
$result = h_parse($this->parser, "aa");
|
||||
$result = hammer_parse($this->parser, "aa");
|
||||
var_dump($result);
|
||||
$this->assertEquals(array("a", "a"), $result);
|
||||
}
|
||||
|
||||
public function testSuccess3()
|
||||
{
|
||||
$result = h_parse($this->parser, "aaa");
|
||||
$result = hammer_parse($this->parser, "aaa");
|
||||
var_dump($result);
|
||||
$this->assertEquals(array(array("a", "a"), "a"), $result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@ class Many1Test extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_many1(choice(ch("a"), ch("b")));
|
||||
$this->parser = hammer_many1(hammer_choice(hammer_ch("a"), hammer_ch("b")));
|
||||
}
|
||||
|
||||
public function testSuccess()
|
||||
{
|
||||
$result1 = h_parse($this->parser, "a");
|
||||
$result2 = h_parse($this->parser, "b");
|
||||
$result3 = h_parse($this->parser, "aabbaba");
|
||||
$result1 = hammer_parse($this->parser, "a");
|
||||
$result2 = hammer_parse($this->parser, "b");
|
||||
$result3 = hammer_parse($this->parser, "aabbaba");
|
||||
$this->assertEquals(array("a"), $result1);
|
||||
$this->assertEquals(array("b"), $result2);
|
||||
$this->assertEquals(array("a", "a", "b", "b", "a", "b", "a"), $result3);
|
||||
|
|
@ -22,8 +22,8 @@ class Many1Test extends PHPUnit_Framework_TestCase
|
|||
|
||||
public function testFailure()
|
||||
{
|
||||
$result1 = h_parse($this->parser, "");
|
||||
$result2 = h_parse($this->parser, "daabbabadef");
|
||||
$result1 = hammer_parse($this->parser, "");
|
||||
$result2 = hammer_parse($this->parser, "daabbabadef");
|
||||
$this->assertEquals(NULL, $result1);
|
||||
$this->assertEquals(NULL, $result2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,15 +7,15 @@ class ManyTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_many(choice(ch("a"), ch("b")));
|
||||
$this->parser = hammer_many(hammer_choice(hammer_ch("a"), hammer_ch("b")));
|
||||
}
|
||||
|
||||
public function testSuccess()
|
||||
{
|
||||
$result1 = h_parse($this->parser, "");
|
||||
$result2 = h_parse($this->parser, "a");
|
||||
$result3 = h_parse($this->parser, "b");
|
||||
$result4 = h_parse($this->parser, "aabbaba");
|
||||
$result1 = hammer_parse($this->parser, "");
|
||||
$result2 = hammer_parse($this->parser, "a");
|
||||
$result3 = hammer_parse($this->parser, "b");
|
||||
$result4 = hammer_parse($this->parser, "aabbaba");
|
||||
$this->assertEquals(array(), $result1);
|
||||
$this->assertEquals(array("a"), $result2);
|
||||
$this->assertEquals(array("b"), $result3);
|
||||
|
|
|
|||
|
|
@ -7,22 +7,22 @@ class MiddleTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_middle(ch(" "), ch("a"), ch(" "));
|
||||
$this->parser = hammer_middle(hammer_ch(" "), hammer_ch("a"), hammer_ch(" "));
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, " a ");
|
||||
$result = hammer_parse($this->parser, " a ");
|
||||
$this->assertEquals("a", $result);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result1 = h_parse($this->parser, "a");
|
||||
$result2 = h_parse($this->parser, " ");
|
||||
$result3 = h_parse($this->parser, " a");
|
||||
$result4 = h_parse($this->parser, "a ");
|
||||
$result5 = h_parse($this->parser, " b ");
|
||||
$result6 = h_parse($this->parser, "ba ");
|
||||
$result7 = h_parse($this->parser, " ab");
|
||||
$result1 = hammer_parse($this->parser, "a");
|
||||
$result2 = hammer_parse($this->parser, " ");
|
||||
$result3 = hammer_parse($this->parser, " a");
|
||||
$result4 = hammer_parse($this->parser, "a ");
|
||||
$result5 = hammer_parse($this->parser, " b ");
|
||||
$result6 = hammer_parse($this->parser, "ba ");
|
||||
$result7 = hammer_parse($this->parser, " ab");
|
||||
$this->assertEquals(NULL, $result1);
|
||||
$this->assertEquals(NULL, $result2);
|
||||
$this->assertEquals(NULL, $result3);
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@ class NotInTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = not_in("abc");
|
||||
$this->parser = hammer_not_in("abc");
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, "d");
|
||||
$result = hammer_parse($this->parser, "d");
|
||||
$this->assertEquals("d", $result);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "b");
|
||||
$result = hammer_parse($this->parser, "b");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,26 +8,26 @@ class NotTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser1 = sequence(ch("a"), choice(ch("+"), h_token("++")), ch("b"));
|
||||
$this->parser2 = sequence(ch("a"), choice(sequence(ch("+"), h_not(ch("+"))), h_token("++")), ch("b"));
|
||||
$this->parser1 = hammer_sequence(hammer_ch("a"), hammer_choice(hammer_ch("+"), hammer_token("++")), hammer_ch("b"));
|
||||
$this->parser2 = hammer_sequence(hammer_ch("a"), hammer_choice(hammer_sequence(hammer_ch("+"), hammer_not(hammer_ch("+"))), hammer_token("++")), hammer_ch("b"));
|
||||
}
|
||||
|
||||
public function testSuccess1()
|
||||
{
|
||||
$result = h_parse($this->parser1, "a+b");
|
||||
$result = hammer_parse($this->parser1, "a+b");
|
||||
$this->assertEquals(array("a", "+", "b"), $result);
|
||||
}
|
||||
|
||||
public function testFailure1()
|
||||
{
|
||||
$result = h_parse($this->parser1, "a++b");
|
||||
$result = hammer_parse($this->parser1, "a++b");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
|
||||
public function testSuccess2()
|
||||
{
|
||||
$result1 = h_parse($this->parser2, "a+b");
|
||||
$result2 = h_parse($this->parser2, "a++b");
|
||||
$result1 = hammer_parse($this->parser2, "a+b");
|
||||
$result2 = hammer_parse($this->parser2, "a++b");
|
||||
$this->assertEquals(array("a", array("+"), "b"), $result1);
|
||||
$this->assertEquals(array("a", "++", "b"), $result2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ class NothingPTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_nothing_p();
|
||||
$this->parser = hammer_nothing();
|
||||
}
|
||||
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "a");
|
||||
$result = hammer_parse($this->parser, "a");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@ class OptionalTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = sequence(ch("a"), h_optional(choice(ch("b"), ch("c"))), ch("d"));
|
||||
$this->parser = hammer_sequence(hammer_ch("a"), hammer_optional(hammer_choice(hammer_ch("b"), hammer_ch("c"))), hammer_ch("d"));
|
||||
}
|
||||
|
||||
public function testSuccess()
|
||||
{
|
||||
$result1 = h_parse($this->parser, "abd");
|
||||
$result2 = h_parse($this->parser, "acd");
|
||||
$result3 = h_parse($this->parser, "ad");
|
||||
$result1 = hammer_parse($this->parser, "abd");
|
||||
$result2 = hammer_parse($this->parser, "acd");
|
||||
$result3 = hammer_parse($this->parser, "ad");
|
||||
$this->assertEquals(array("a", "b", "d"), $result1);
|
||||
$this->assertEquals(array("a", "c", "d"), $result2);
|
||||
$this->assertEquals(array("a", NULL, "d"), $result3);
|
||||
|
|
@ -22,9 +22,9 @@ class OptionalTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
public function testFailure()
|
||||
{
|
||||
$result1 = h_parse($this->parser, "aed");
|
||||
$result2 = h_parse($this->parser, "ab");
|
||||
$result3 = h_parse($this->parser, "ac");
|
||||
$result1 = hammer_parse($this->parser, "aed");
|
||||
$result2 = hammer_parse($this->parser, "ab");
|
||||
$result3 = hammer_parse($this->parser, "ac");
|
||||
$this->assertEquals(NULL, $result1);
|
||||
$this->assertEquals(NULL, $result2);
|
||||
$this->assertEquals(NULL, $result3);
|
||||
|
|
|
|||
|
|
@ -12,18 +12,18 @@ class PredicateTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = predicate(h_many1(choice(ch('a'), ch('b'))), "predTest");
|
||||
$this->parser = hammer_predicate(hammer_many1(hammer_choice(hammer_ch('a'), hammer_ch('b'))), "predTest");
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
$result1 = h_parse($this->parser, "aa");
|
||||
$result2 = h_parse($this->parser, "bb");
|
||||
$result1 = hammer_parse($this->parser, "aa");
|
||||
$result2 = hammer_parse($this->parser, "bb");
|
||||
$this->assertEquals(["a", "a"], $result1);
|
||||
$this->assertEquals(["b", "b"], $result2);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "ab");
|
||||
$result = hammer_parse($this->parser, "ab");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,19 +7,19 @@ class RepeatNTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_repeat_n(choice(ch("a"), ch("b")), 2);
|
||||
$this->parser = hammer_repeat_n(hammer_choice(hammer_ch("a"), hammer_ch("b")), 2);
|
||||
}
|
||||
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, "abdef");
|
||||
$result = hammer_parse($this->parser, "abdef");
|
||||
$this->assertEquals(array("a", "b"), $result);
|
||||
}
|
||||
|
||||
public function testFailure()
|
||||
{
|
||||
$result1 = h_parse($this->parser, "adef");
|
||||
$result2 = h_parse($this->parser, "dabdef");
|
||||
$result1 = hammer_parse($this->parser, "adef");
|
||||
$result2 = hammer_parse($this->parser, "dabdef");
|
||||
$this->assertEquals(NULL, $result1);
|
||||
$this->assertEquals(NULL, $result2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,18 +7,18 @@ class RightTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_right(ch(" "), ch("a"));
|
||||
$this->parser = hammer_right(hammer_ch(" "), hammer_ch("a"));
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, " a");
|
||||
$result = hammer_parse($this->parser, " a");
|
||||
$this->assertEquals("a", $result);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result1 = h_parse($this->parser, "a");
|
||||
$result2 = h_parse($this->parser, " ");
|
||||
$result3 = h_parse($this->parser, "ba");
|
||||
$result1 = hammer_parse($this->parser, "a");
|
||||
$result2 = hammer_parse($this->parser, " ");
|
||||
$result3 = hammer_parse($this->parser, "ba");
|
||||
$this->assertEquals(NULL, $result1);
|
||||
$this->assertEquals(NULL, $result2);
|
||||
$this->assertEquals(NULL, $result3);
|
||||
|
|
|
|||
|
|
@ -7,15 +7,15 @@ class RightrecTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_indirect();
|
||||
h_bind_indirect($this->parser, choice(sequence(ch("a"), $this->parser), h_epsilon_p()));
|
||||
$this->parser = hammer_indirect();
|
||||
hammer_bind_indirect($this->parser, hammer_choice(hammer_sequence(hammer_ch("a"), $this->parser), hammer_epsilon()));
|
||||
}
|
||||
|
||||
public function testSuccess()
|
||||
{
|
||||
$result1 = h_parse($this->parser, "a");
|
||||
$result2 = h_parse($this->parser, "aa");
|
||||
$result3 = h_parse($this->parser, "aaa");
|
||||
$result1 = hammer_parse($this->parser, "a");
|
||||
$result2 = hammer_parse($this->parser, "aa");
|
||||
$result3 = hammer_parse($this->parser, "aaa");
|
||||
$this->assertEquals(array("a"), $result1);
|
||||
$this->assertEquals(array("a", array("a")), $result2);
|
||||
$this->assertEquals(array("a", array("a", array("a"))), $result3);
|
||||
|
|
|
|||
|
|
@ -7,15 +7,15 @@ class SepBy1Test extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_sepBy1(choice(ch("1"), ch("2"), ch("3")), ch(","));
|
||||
$this->parser = hammer_sep_by1(hammer_choice(hammer_ch("1"), hammer_ch("2"), hammer_ch("3")), hammer_ch(","));
|
||||
}
|
||||
|
||||
public function testSuccess()
|
||||
{
|
||||
$result1 = h_parse($this->parser, "1,2,3");
|
||||
$result2 = h_parse($this->parser, "1,3,2");
|
||||
$result3 = h_parse($this->parser, "1,3");
|
||||
$result4 = h_parse($this->parser, "3");
|
||||
$result1 = hammer_parse($this->parser, "1,2,3");
|
||||
$result2 = hammer_parse($this->parser, "1,3,2");
|
||||
$result3 = hammer_parse($this->parser, "1,3");
|
||||
$result4 = hammer_parse($this->parser, "3");
|
||||
$this->assertEquals(array("1", "2", "3"), $result1);
|
||||
$this->assertEquals(array("1", "3", "2"), $result2);
|
||||
$this->assertEquals(array("1", "3"), $result3);
|
||||
|
|
@ -24,7 +24,7 @@ class SepBy1Test extends PHPUnit_Framework_TestCase
|
|||
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "");
|
||||
$result = hammer_parse($this->parser, "");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@ class SepByTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_sepBy(choice(ch("1"), ch("2"), ch("3")), ch(","));
|
||||
$this->parser = hammer_sep_by(hammer_choice(hammer_ch("1"), hammer_ch("2"), hammer_ch("3")), hammer_ch(","));
|
||||
}
|
||||
|
||||
public function testSuccess()
|
||||
{
|
||||
$result1 = h_parse($this->parser, "1,2,3");
|
||||
$result2 = h_parse($this->parser, "1,3,2");
|
||||
$result3 = h_parse($this->parser, "1,3");
|
||||
$result4 = h_parse($this->parser, "3");
|
||||
$result5 = h_parse($this->parser, "");
|
||||
$result1 = hammer_parse($this->parser, "1,2,3");
|
||||
$result2 = hammer_parse($this->parser, "1,3,2");
|
||||
$result3 = hammer_parse($this->parser, "1,3");
|
||||
$result4 = hammer_parse($this->parser, "3");
|
||||
$result5 = hammer_parse($this->parser, "");
|
||||
$this->assertEquals(array("1", "2", "3"), $result1);
|
||||
$this->assertEquals(array("1", "3", "2"), $result2);
|
||||
$this->assertEquals(array("1", "3"), $result3);
|
||||
|
|
|
|||
|
|
@ -8,29 +8,29 @@ class SequenceTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser1 = sequence(ch("a"), ch("b"));
|
||||
$this->parser2 = sequence(ch("a"), h_whitespace(ch("b")));
|
||||
$this->parser1 = hammer_sequence(hammer_ch("a"), hammer_ch("b"));
|
||||
$this->parser2 = hammer_sequence(hammer_ch("a"), hammer_whitespace(hammer_ch("b")));
|
||||
}
|
||||
|
||||
public function testSuccess1()
|
||||
{
|
||||
$result = h_parse($this->parser1, "ab");
|
||||
$result = hammer_parse($this->parser1, "ab");
|
||||
$this->assertEquals(array("a", "b"), $result);
|
||||
}
|
||||
|
||||
public function testFailure1()
|
||||
{
|
||||
$result1 = h_parse($this->parser1, "a");
|
||||
$result2 = h_parse($this->parser2, "b");
|
||||
$result1 = hammer_parse($this->parser1, "a");
|
||||
$result2 = hammer_parse($this->parser2, "b");
|
||||
$this->assertEquals(NULL, $result1);
|
||||
$this->assertEquals(NULL, $result2);
|
||||
}
|
||||
|
||||
public function testSuccess2()
|
||||
{
|
||||
$result1 = h_parse($this->parser2, "ab");
|
||||
$result2 = h_parse($this->parser2, "a b");
|
||||
$result3 = h_parse($this->parser2, "a b");
|
||||
$result1 = hammer_parse($this->parser2, "ab");
|
||||
$result2 = hammer_parse($this->parser2, "a b");
|
||||
$result3 = hammer_parse($this->parser2, "a b");
|
||||
$this->assertEquals(array("a", "b"), $result1);
|
||||
$this->assertEquals(array("a", "b"), $result2);
|
||||
$this->assertEquals(array("a", "b"), $result3);
|
||||
|
|
|
|||
|
|
@ -8,16 +8,16 @@ class TokenTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_token("95\xa2");
|
||||
$this->parser = hammer_token("95\xa2");
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, "95\xa2");
|
||||
$result = hammer_parse($this->parser, "95\xa2");
|
||||
$this->assertEquals("95\xa2", $result);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "95");
|
||||
$result = hammer_parse($this->parser, "95");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,16 +8,16 @@ class Uint16Test extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_uint16();
|
||||
$this->parser = hammer_uint16();
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, "\x02\x00");
|
||||
$result = hammer_parse($this->parser, "\x02\x00");
|
||||
$this->assertEquals(0x200, $result);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "\x02");
|
||||
$result = hammer_parse($this->parser, "\x02");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,16 +8,16 @@ class Uint32Test extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_uint32();
|
||||
$this->parser = hammer_uint32();
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, "\x00\x02\x00\x00");
|
||||
$result = hammer_parse($this->parser, "\x00\x02\x00\x00");
|
||||
$this->assertEquals(0x20000, $result);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "\x00\x02\x00");
|
||||
$result = hammer_parse($this->parser, "\x00\x02\x00");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,16 +8,16 @@ class Uint64Test extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_uint64();
|
||||
$this->parser = hammer_uint64();
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, "\x00\x00\x00\x02\x00\x00\x00\x00");
|
||||
$result = hammer_parse($this->parser, "\x00\x00\x00\x02\x00\x00\x00\x00");
|
||||
$this->assertEquals(0x200000000, $result);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "\x00\x00\x00\x02\x00\x00\x00");
|
||||
$result = hammer_parse($this->parser, "\x00\x00\x00\x02\x00\x00\x00");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,16 +8,16 @@ class Uint8Test extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_uint8();
|
||||
$this->parser = hammer_uint8();
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
$result = h_parse($this->parser, "\x78");
|
||||
$result = hammer_parse($this->parser, "\x78");
|
||||
$this->assertEquals(0x78, $result);
|
||||
}
|
||||
public function testFailure()
|
||||
{
|
||||
$result = h_parse($this->parser, "");
|
||||
$result = hammer_parse($this->parser, "");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,15 +8,15 @@ class WhitespaceTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser1 = h_whitespace(ch("a"));
|
||||
$this->parser2 = h_whitespace(h_end_p());
|
||||
$this->parser1 = hammer_whitespace(hammer_ch("a"));
|
||||
$this->parser2 = hammer_whitespace(hammer_end());
|
||||
}
|
||||
public function testSuccess1()
|
||||
{
|
||||
$result1 = h_parse($this->parser1, "a");
|
||||
$result2 = h_parse($this->parser1, " a");
|
||||
$result3 = h_parse($this->parser1, " a");
|
||||
$result4 = h_parse($this->parser1, "\ta");
|
||||
$result1 = hammer_parse($this->parser1, "a");
|
||||
$result2 = hammer_parse($this->parser1, " a");
|
||||
$result3 = hammer_parse($this->parser1, " a");
|
||||
$result4 = hammer_parse($this->parser1, "\ta");
|
||||
$this->assertEquals("a", $result1);
|
||||
$this->assertEquals("a", $result2);
|
||||
$this->assertEquals("a", $result3);
|
||||
|
|
@ -24,19 +24,19 @@ class WhitespaceTest extends PHPUnit_Framework_TestCase
|
|||
}
|
||||
public function testFailure1()
|
||||
{
|
||||
$result = h_parse($this->parser1, "_a");
|
||||
$result = hammer_parse($this->parser1, "_a");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
public function testSuccess2()
|
||||
{
|
||||
$result1 = h_parse($this->parser2, "");
|
||||
$result2 = h_parse($this->parser2, " ");
|
||||
$result1 = hammer_parse($this->parser2, "");
|
||||
$result2 = hammer_parse($this->parser2, " ");
|
||||
$this->assertEquals(NULL, $result1);
|
||||
$this->assertEquals(NULL, $result2);
|
||||
}
|
||||
public function testFailure2()
|
||||
{
|
||||
$result = h_parse($this->parser2, " x");
|
||||
$result = hammer_parse($this->parser2, " x");
|
||||
$this->assertEquals(NULL, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,21 +7,21 @@ class XorTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = h_xor(ch_range("0", "6"), ch_range("5", "9"));
|
||||
$this->parser = hammer_xor(hammer_ch_range("0", "6"), hammer_ch_range("5", "9"));
|
||||
}
|
||||
|
||||
public function testSuccess()
|
||||
{
|
||||
$result1 = h_parse($this->parser, "0");
|
||||
$result2 = h_parse($this->parser, "9");
|
||||
$result1 = hammer_parse($this->parser, "0");
|
||||
$result2 = hammer_parse($this->parser, "9");
|
||||
$this->assertEquals("0", $result1);
|
||||
$this->assertEquals("9", $result2);
|
||||
}
|
||||
|
||||
public function testFailure()
|
||||
{
|
||||
$result1 = h_parse($this->parser, "5");
|
||||
$result2 = h_parse($this->parser, "a");
|
||||
$result1 = hammer_parse($this->parser, "5");
|
||||
$result2 = hammer_parse($this->parser, "a");
|
||||
$this->assertEquals(NULL, $result1);
|
||||
$this->assertEquals(NULL, $result2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,42 @@
|
|||
}
|
||||
}
|
||||
|
||||
%rename("hammer_token") h_token;
|
||||
%rename("hammer_int_range") h_int_range;
|
||||
%rename("hammer_bits") h_bits;
|
||||
%rename("hammer_int64") h_int64;
|
||||
%rename("hammer_int32") h_int32;
|
||||
%rename("hammer_int16") h_int16;
|
||||
%rename("hammer_int8") h_int8;
|
||||
%rename("hammer_uint64") h_uint64;
|
||||
%rename("hammer_uint32") h_uint32;
|
||||
%rename("hammer_uint16") h_uint16;
|
||||
%rename("hammer_uint8") h_uint8;
|
||||
%rename("hammer_whitespace") h_whitespace;
|
||||
%rename("hammer_left") h_left;
|
||||
%rename("hammer_right") h_right;
|
||||
%rename("hammer_middle") h_middle;
|
||||
%rename("hammer_end") h_end_p;
|
||||
%rename("hammer_nothing") h_nothing_p;
|
||||
%rename("hammer_butnot") h_butnot;
|
||||
%rename("hammer_difference") h_difference;
|
||||
%rename("hammer_xor") h_xor;
|
||||
%rename("hammer_many") h_many;
|
||||
%rename("hammer_many1") h_many1;
|
||||
%rename("hammer_repeat_n") h_repeat_n;
|
||||
%rename("hammer_optional") h_optional;
|
||||
%rename("hammer_ignore") h_ignore;
|
||||
%rename("hammer_sep_by") h_sepBy;
|
||||
%rename("hammer_sep_by1") h_sepBy1;
|
||||
%rename("hammer_epsilon") h_epsilon_p;
|
||||
%rename("hammer_length_value") h_length_value;
|
||||
%rename("hammer_and") h_and;
|
||||
%rename("hammer_not") h_not;
|
||||
%rename("hammer_indirect") h_indirect;
|
||||
%rename("hammer_bind_indirect") h_bind_indirect;
|
||||
%rename("hammer_compile") h_compile;
|
||||
%rename("hammer_parse") h_parse;
|
||||
|
||||
%include "../swig/hammer.i";
|
||||
|
||||
%inline {
|
||||
|
|
@ -158,52 +194,52 @@
|
|||
return Z_LVAL_P(ret);
|
||||
}
|
||||
|
||||
HParser* action(HParser *parser, const char *name) {
|
||||
HParser* hammer_action(HParser *parser, const char *name) {
|
||||
return h_action(parser, call_action, (void*)name);
|
||||
}
|
||||
|
||||
HParser* predicate(HParser *parser, const char *name) {
|
||||
HParser* hammer_predicate(HParser *parser, const char *name) {
|
||||
return h_attr_bool(parser, call_predicate, (void*)name);
|
||||
}
|
||||
}
|
||||
|
||||
%pragma(php) code="
|
||||
|
||||
function ch($ch)
|
||||
function hammer_ch($ch)
|
||||
{
|
||||
if (is_string($ch))
|
||||
return h_token($ch);
|
||||
return hammer_token($ch);
|
||||
else
|
||||
return h_ch($ch);
|
||||
}
|
||||
|
||||
function choice()
|
||||
function hammer_choice()
|
||||
{
|
||||
$arg_list = func_get_args();
|
||||
$arg_list[] = NULL;
|
||||
return h_choice__a($arg_list);
|
||||
}
|
||||
|
||||
function sequence()
|
||||
function hammer_sequence()
|
||||
{
|
||||
$arg_list = func_get_args();
|
||||
$arg_list[] = NULL;
|
||||
return h_sequence__a($arg_list);
|
||||
}
|
||||
|
||||
function ch_range($low, $high)
|
||||
function hammer_ch_range($low, $high)
|
||||
{
|
||||
return action(h_ch_range($low, $high), \"chr\");
|
||||
return hammer_action(h_ch_range($low, $high), \"chr\");
|
||||
}
|
||||
|
||||
function in($charset)
|
||||
function hammer_in($charset)
|
||||
{
|
||||
return action(h_in($charset), \"chr\");
|
||||
return hammer_action(h_in($charset), \"chr\");
|
||||
}
|
||||
|
||||
function not_in($charset)
|
||||
function hammer_not_in($charset)
|
||||
{
|
||||
return action(h_not_in($charset), \"chr\");
|
||||
return hammer_action(h_not_in($charset), \"chr\");
|
||||
}
|
||||
"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue