1 | <?php |
||
32 | class BaseParser extends Stateful |
||
33 | { |
||
34 | public const T_DOC_DEFINITION = 'T_DOC_DEFINITION'; |
||
35 | public const T_VARIABLE = 'T_VARIABLE'; |
||
36 | public const T_WORD = 'T_WORD'; |
||
37 | public const T_SUFFIX_ARRAY = 'T_SUFFIX_ARRAY'; |
||
38 | public const T_NAMESPACE = 'T_NAMESPACE'; |
||
39 | public const T_AND = 'T_AND'; |
||
40 | public const T_OR = 'T_OR'; |
||
41 | public const T_ANGLE_LEFT = 'T_ANGLE_LEFT'; |
||
42 | public const T_ANGLE_RIGHT = 'T_ANGLE_RIGHT'; |
||
43 | public const T_COMMA = 'T_COMMA'; |
||
44 | public const T_WHITESPACE = 'T_WHITESPACE'; |
||
45 | public const T_COMMENT = 'T_COMMENT'; |
||
46 | public const T_ANY = 'T_ANY'; |
||
47 | |||
48 | /** |
||
49 | * Lexical tokens list. |
||
50 | * |
||
51 | * @var string[] |
||
52 | */ |
||
53 | protected const LEXER_TOKENS = [ |
||
54 | self::T_DOC_DEFINITION => '@([\\w\\-]+)', |
||
55 | self::T_VARIABLE => '\\$([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)', |
||
56 | self::T_WORD => '[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*', |
||
57 | self::T_SUFFIX_ARRAY => '\\[\\]', |
||
58 | self::T_NAMESPACE => '\\\\', |
||
59 | self::T_AND => '&', |
||
60 | self::T_OR => '\\|', |
||
61 | self::T_ANGLE_LEFT => '<', |
||
62 | self::T_ANGLE_RIGHT => '>', |
||
63 | self::T_COMMA => ',', |
||
64 | self::T_WHITESPACE => '\\s+', |
||
65 | self::T_COMMENT => '\\*', |
||
66 | self::T_ANY => '\\S+?', |
||
67 | ]; |
||
68 | |||
69 | /** |
||
70 | * List of skipped tokens. |
||
71 | * |
||
72 | * @var string[] |
||
73 | */ |
||
74 | protected const LEXER_SKIPPED_TOKENS = [ |
||
75 | 'T_WHITESPACE', |
||
76 | 'T_COMMENT', |
||
77 | 'T_ANY', |
||
78 | ]; |
||
79 | |||
80 | /** |
||
81 | * @var int |
||
82 | */ |
||
83 | protected const LEXER_FLAGS = Factory::LOOKAHEAD; |
||
84 | |||
85 | /** |
||
86 | * List of rule delegates. |
||
87 | * |
||
88 | * @var string[] |
||
89 | */ |
||
90 | protected const PARSER_DELEGATES = [ |
||
91 | ]; |
||
92 | |||
93 | /** |
||
94 | * Parser root rule name. |
||
95 | * |
||
96 | * @var string |
||
97 | */ |
||
98 | protected const PARSER_ROOT_RULE = 'Document'; |
||
99 | |||
100 | /** |
||
101 | * @return ParserInterface |
||
102 | * @throws \InvalidArgumentException |
||
103 | * @throws \Railt\Lexer\Exception\BadLexemeException |
||
104 | */ |
||
105 | protected function boot(): ParserInterface |
||
109 | |||
110 | /** |
||
111 | * @return LexerInterface |
||
112 | * @throws \InvalidArgumentException |
||
113 | * @throws \Railt\Lexer\Exception\BadLexemeException |
||
114 | */ |
||
115 | protected function bootLexer(): LexerInterface |
||
119 | |||
120 | /** |
||
121 | * @return GrammarInterface |
||
122 | */ |
||
123 | protected function bootGrammar(): GrammarInterface |
||
180 | } |
||
181 |