-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp4.php
40 lines (32 loc) · 913 Bytes
/
p4.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
use SyntaxAnalyzer\Analyzer;
require_once __DIR__ . '/testhelpers.php';
//create create
$words = [
['type' => 'white', 'value' => ''],
['type' => 'key', 'value' => 'CREATE'],
['type' => 'white', 'value' => ''],
['type' => 'key', 'value' => 'CREATE']
];
$rules = [
'create' => [
'matches' => [
['r' => 'create_content', 'type' => 'call', 'n' => [1, PHP_INT_MAX], 'name' => 'key_create'],
],
'n' => [1, PHP_INT_MAX],
],
'create_content' => [
'matches' => [
['type' => 'white', 'n' => [0, PHP_INT_MAX], 'name' => 'white1'],
['r' => '/CREATE/', 'type' => 'key', 'n' => [1, 1], 'name' => 'key_create'],
],
'n' => [1, PHP_INT_MAX],
]
];
$g = new Analyzer( $rules);
$g->setWords($words);
$i = 0;
$r = $g->matchOne($rules['create'], $rs, $i);
var_dump('rs', $i, $r, $rs);
//$g->showLog();
//