summaryrefslogtreecommitdiff
path: root/inc/parser/parser.php
diff options
context:
space:
mode:
authorghi <dokuwiki@imz.re>2015-02-17 11:08:15 +0100
committerghi <dokuwiki@imz.re>2015-02-17 11:08:15 +0100
commit7d0b7e5ed7aa0f9c56def8f6c9866aa4fc8315b8 (patch)
tree08330b0a548a402caeb02ee7a185e745386ad45d /inc/parser/parser.php
parentd6dc28be40fb3202a3df69458db164e20999ac2b (diff)
parentf8803275a58a05b29e4029cc539a6f8c60ad2ea5 (diff)
downloadrpg-7d0b7e5ed7aa0f9c56def8f6c9866aa4fc8315b8.tar.gz
rpg-7d0b7e5ed7aa0f9c56def8f6c9866aa4fc8315b8.tar.bz2
Merge https://github.com/splitbrain/dokuwiki into html_showrev_output
Diffstat (limited to 'inc/parser/parser.php')
-rw-r--r--inc/parser/parser.php94
1 files changed, 78 insertions, 16 deletions
diff --git a/inc/parser/parser.php b/inc/parser/parser.php
index 1f14b98a3..5f86cf5c4 100644
--- a/inc/parser/parser.php
+++ b/inc/parser/parser.php
@@ -61,6 +61,9 @@ class Doku_Parser {
var $connected = false;
+ /**
+ * @param Doku_Parser_Mode_base $BaseMode
+ */
function addBaseMode(& $BaseMode) {
$this->modes['base'] =& $BaseMode;
if ( !$this->Lexer ) {
@@ -125,43 +128,99 @@ class Doku_Parser {
}
//-------------------------------------------------------------------
+
/**
- * This class and all the subclasses below are
- * used to reduce the effort required to register
- * modes with the Lexer. For performance these
- * could all be eliminated later perhaps, or
- * the Parser could be serialized to a file once
- * all modes are registered
+ * Class Doku_Parser_Mode_Interface
*
- * @author Harry Fuecks <hfuecks@gmail.com>
+ * Defines a mode (syntax component) in the Parser
*/
-class Doku_Parser_Mode {
+interface Doku_Parser_Mode_Interface {
+ /**
+ * returns a number used to determine in which order modes are added
+ */
+ public function getSort();
+
+ /**
+ * Called before any calls to connectTo
+ * @return void
+ */
+ function preConnect();
+
+ /**
+ * Connects the mode
+ *
+ * @param string $mode
+ * @return void
+ */
+ function connectTo($mode);
+
+ /**
+ * Called after all calls to connectTo
+ * @return void
+ */
+ function postConnect();
/**
+ * Check if given mode is accepted inside this mode
+ *
+ * @param string $mode
+ * @return bool
+ */
+ function accepts($mode);
+}
+
+/**
+ * This class and all the subclasses below are used to reduce the effort required to register
+ * modes with the Lexer.
+ *
+ * @author Harry Fuecks <hfuecks@gmail.com>
+ */
+class Doku_Parser_Mode implements Doku_Parser_Mode_Interface {
+ /**
* @var Doku_Lexer $Lexer
*/
var $Lexer;
-
var $allowedModes = array();
- // returns a number used to determine in which order modes are added
function getSort() {
trigger_error('getSort() not implemented in '.get_class($this), E_USER_WARNING);
}
- // Called before any calls to connectTo
function preConnect() {}
-
- // Connects the mode
function connectTo($mode) {}
-
- // Called after all calls to connectTo
function postConnect() {}
-
function accepts($mode) {
return in_array($mode, (array) $this->allowedModes );
}
+}
+/**
+ * Basically the same as Doku_Parser_Mode but extends from DokuWiki_Plugin
+ *
+ * Adds additional functions to syntax plugins
+ */
+class Doku_Parser_Mode_Plugin extends DokuWiki_Plugin implements Doku_Parser_Mode_Interface {
+ /**
+ * @var Doku_Lexer $Lexer
+ */
+ var $Lexer;
+ var $allowedModes = array();
+
+ /**
+ * Sort for applying this mode
+ *
+ * @return int
+ */
+ function getSort() {
+ trigger_error('getSort() not implemented in '.get_class($this), E_USER_WARNING);
+ }
+
+ function preConnect() {}
+ function connectTo($mode) {}
+ function postConnect() {}
+ function accepts($mode) {
+ return in_array($mode, (array) $this->allowedModes );
+ }
}
//-------------------------------------------------------------------
@@ -354,6 +413,9 @@ class Doku_Parser_Mode_formatting extends Doku_Parser_Mode {
),
);
+ /**
+ * @param string $type
+ */
function Doku_Parser_Mode_formatting($type) {
global $PARSER_MODES;