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