-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp2.php
More file actions
36 lines (29 loc) · 870 Bytes
/
p2.php
File metadata and controls
36 lines (29 loc) · 870 Bytes
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
<?php
use SyntaxAnalyzer\Analyzer;
require_once __DIR__ . '/testhelpers.php';
function test1()
{
testRule('/[a-zA-Z0-9]+/i', ['a', 'a22'], [',', ';']);
testRule('/[;,\(\)]+/i', [',', ';'], ['a', 'a22']);
testRule('/[^"]+/i', ['a1', "sazda2'"], ['"']);
testRule('/\s+/', [' \n'], ['"']);
}
$words = [
['type' => 'white', 'value' => ''],
['type' => 'key', 'value' => 'CREATE'],
['type' => 'white', 'value' => ''],
['type' => 'key', 'value' => 'CREATE']
];
$rule = [
'matches' => [
['type' => 'white', 'n' => [0, PHP_INT_MAX], 'name' => 'white1'],
['r' => '/CREATE/', 'type' => 'key', 'n' => [1, 1], 'name' => 'key_create'],
]];
$g = new Analyzer(null);
$g->setWords($words);
$i = 0;
$r = $g->matchOne($rule, $rs, $i);
var_dump('rs',$i, $r,$rs);
$r = $g->matchOne($rule, $rs, $i);
var_dump('rs',$i, $r,$rs);
//