xref: /dokuwiki/inc/Parsing/ParserMode/ModeInterface.php (revision 71096e46fcbfaeaa808667aba794e77fe2780169)
1be906b56SAndreas Gohr<?php
2be906b56SAndreas Gohr
3be906b56SAndreas Gohrnamespace dokuwiki\Parsing\ParserMode;
4be906b56SAndreas Gohr
5*71096e46SAndreas Gohruse dokuwiki\Parsing\Handler;
6*71096e46SAndreas Gohr
7be906b56SAndreas Gohr/**
8be906b56SAndreas Gohr * Defines a mode (syntax component) in the Parser
9be906b56SAndreas Gohr */
10be906b56SAndreas Gohrinterface ModeInterface
11be906b56SAndreas Gohr{
12be906b56SAndreas Gohr    /**
13be906b56SAndreas Gohr     * returns a number used to determine in which order modes are added
14be906b56SAndreas Gohr     *
15be906b56SAndreas Gohr     * @return int;
16be906b56SAndreas Gohr     */
17be906b56SAndreas Gohr    public function getSort();
18be906b56SAndreas Gohr
19be906b56SAndreas Gohr    /**
20be906b56SAndreas Gohr     * Called before any calls to connectTo
21be906b56SAndreas Gohr     *
22be906b56SAndreas Gohr     * @return void
23be906b56SAndreas Gohr     */
24be906b56SAndreas Gohr    public function preConnect();
25be906b56SAndreas Gohr
26be906b56SAndreas Gohr    /**
27be906b56SAndreas Gohr     * Connects the mode
28be906b56SAndreas Gohr     *
29be906b56SAndreas Gohr     * @param string $mode
30be906b56SAndreas Gohr     * @return void
31be906b56SAndreas Gohr     */
32be906b56SAndreas Gohr    public function connectTo($mode);
33be906b56SAndreas Gohr
34be906b56SAndreas Gohr    /**
35be906b56SAndreas Gohr     * Called after all calls to connectTo
36be906b56SAndreas Gohr     *
37be906b56SAndreas Gohr     * @return void
38be906b56SAndreas Gohr     */
39be906b56SAndreas Gohr    public function postConnect();
40be906b56SAndreas Gohr
41be906b56SAndreas Gohr    /**
42be906b56SAndreas Gohr     * Check if given mode is accepted inside this mode
43be906b56SAndreas Gohr     *
44be906b56SAndreas Gohr     * @param string $mode
45be906b56SAndreas Gohr     * @return bool
46be906b56SAndreas Gohr     */
47be906b56SAndreas Gohr    public function accepts($mode);
48*71096e46SAndreas Gohr
49*71096e46SAndreas Gohr    /**
50*71096e46SAndreas Gohr     * Handle a matched token from the lexer.
51*71096e46SAndreas Gohr     *
52*71096e46SAndreas Gohr     * @param string $match The matched text
53*71096e46SAndreas Gohr     * @param int $state The lexer state (DOKU_LEXER_ENTER, _EXIT, _MATCHED, etc.)
54*71096e46SAndreas Gohr     * @param int $pos Byte position in the source
55*71096e46SAndreas Gohr     * @param Handler $handler The handler (for addCall, status, etc.)
56*71096e46SAndreas Gohr     * @return bool
57*71096e46SAndreas Gohr     */
58*71096e46SAndreas Gohr    public function handle($match, $state, $pos, Handler $handler);
59be906b56SAndreas Gohr}
60