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_WHITESPACE = 'T_WHITESPACE'; |
||
42 | public const T_COMMENT = 'T_COMMENT'; |
||
43 | public const T_ANY = 'T_ANY'; |
||
44 | |||
45 | /** |
||
46 | * Lexical tokens list. |
||
47 | * |
||
48 | * @var string[] |
||
49 | */ |
||
50 | protected const LEXER_TOKENS = [ |
||
51 | self::T_DOC_DEFINITION => '@([\\w\\-]+)', |
||
52 | self::T_VARIABLE => '\\$([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)', |
||
53 | self::T_WORD => '[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*', |
||
54 | self::T_SUFFIX_ARRAY => '\\[\\]', |
||
55 | self::T_NAMESPACE => '\\\\', |
||
56 | self::T_AND => '&', |
||
57 | self::T_OR => '\\|', |
||
58 | self::T_WHITESPACE => '\\s+', |
||
59 | self::T_COMMENT => '\\*', |
||
60 | self::T_ANY => '\\S+?', |
||
61 | ]; |
||
62 | |||
63 | /** |
||
64 | * List of skipped tokens. |
||
65 | * |
||
66 | * @var string[] |
||
67 | */ |
||
68 | protected const LEXER_SKIPPED_TOKENS = [ |
||
69 | 'T_WHITESPACE', |
||
70 | 'T_COMMENT', |
||
71 | 'T_ANY', |
||
72 | ]; |
||
73 | |||
74 | /** |
||
75 | * @var int |
||
76 | */ |
||
77 | protected const LEXER_FLAGS = Factory::LOOKAHEAD; |
||
78 | |||
79 | /** |
||
80 | * List of rule delegates. |
||
81 | * |
||
82 | * @var string[] |
||
83 | */ |
||
84 | protected const PARSER_DELEGATES = [ |
||
85 | ]; |
||
86 | |||
87 | /** |
||
88 | * Parser root rule name. |
||
89 | * |
||
90 | * @var string |
||
91 | */ |
||
92 | protected const PARSER_ROOT_RULE = 'Document'; |
||
93 | |||
94 | /** |
||
95 | * @return ParserInterface |
||
96 | * @throws \InvalidArgumentException |
||
97 | * @throws \Railt\Lexer\Exception\BadLexemeException |
||
98 | */ |
||
99 | protected function boot(): ParserInterface |
||
103 | |||
104 | /** |
||
105 | * @return LexerInterface |
||
106 | * @throws \InvalidArgumentException |
||
107 | * @throws \Railt\Lexer\Exception\BadLexemeException |
||
108 | */ |
||
109 | protected function bootLexer(): LexerInterface |
||
113 | |||
114 | /** |
||
115 | * @return GrammarInterface |
||
116 | */ |
||
117 | protected function bootGrammar(): GrammarInterface |
||
161 | } |
||
162 |