-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
52 lines (41 loc) · 1.04 KB
/
index.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
41
42
43
44
45
46
47
48
49
50
51
52
<?php
require 'vendor/autoload.php';
use Tyson\Parser;
use Tyson\Tokens;
use Tyson\Tokenizer;
$rules = [
Tokens::T_NUMBER => '\d+',
Tokens::T_WHITESPACE => '\s+',
Tokens::T_CLASS => 'class',
Tokens::T_NAMESPACE => 'namespace',
Tokens::T_PRIVATE => 'private',
Tokens::T_PROTECTED => 'protected',
Tokens::T_PUBLIC => 'public',
Tokens::T_FUNCTION => 'function',
Tokens::T_TRUE => 'true',
Tokens::T_FALSE => 'false',
Tokens::T_NULL => 'null',
Tokens::T_IDENTIFIER => "[\_a-zA-Z][\_a-zA-Z0-9]*",
Tokens::T_SEMICOLON => ";",
Tokens::T_LBRACKET => "{",
Tokens::T_RBRACKET => "}",
Tokens::T_EQUALS => "=",
Tokens::T_LPAREN => '\(',
Tokens::T_RPAREN => '\)',
Tokens::T_ADD => '\+',
Tokens::T_SUBTRACT => '\-',
];
$program = "
namespace X;
class Y
{
public R;
private X = 100;
private X;
public function __construct()
{
-3 + (3);
}
}
";
(new Parser(new Tokenizer($rules, $program)))->parse();