Parser for wiki documents.
Source for this file: /Document/src/document/wiki/parser.php
ezcDocumentParser | --ezcDocumentWikiParser
Version: | //autogen// |
protected array |
$conversionsArray
= array(
Array with token node conversions. Token to node conversions are used for tokens, which do not require any additional checking of the tokens context. This is especially useful, because the wiki tokenizer already implement a lot of this logic. |
protected array |
$documentStack
= array()
Contains a list of detected syntax elements. At the end of a successfull parsing process this should only contain one document syntax element. During the process it may contain a list of elements, which are up to reduction. Each element in the stack has to be an object extending from ezcDocumentRstNode, which may again contain any amount such objects. This way an abstract syntax tree is constructed. |
protected bool |
$insideLineToken
= false
Flag if we are inside a line level node |
protected array |
$reductions
= array(
Array containing simplified reduce ruleset. We cannot express the Wiki syntax as a usual grammar using a BNF. This structure implements a pseudo grammar by assigning a number of callbacks for internal methods implementing reduction rules for a detected syntax element.
|
protected array |
$shifts
= array(
Array containing simplified shift ruleset. We cannot express the Wiki syntax as a usual grammar using a BNF. With the pumping lemma for context free grammars [1] you can easily prove, that the word a^n b c^n d e^n is not a context free grammar, and this is what the title definitions are. This structure contains an array with callbacks implementing the shift rules for all tokens. There may be multiple rules for one single token. The callbacks itself create syntax elements and push them to the document stack. After each push the reduction callbacks will be called for the pushed elements. The array should look like:
[1] http://en.wikipedia.org/wiki/Pumping_lemma_for_context-free_languages |
From ezcDocumentParser | |
---|---|
protected |
ezcDocumentParser::$options
|
protected |
ezcDocumentParser::$properties
|
protected ezcDocumentWikiListNode |
mergeListRecursively(
$lists
)
Merge lists recusively. |
public ezcDocumentWikiDocumentNode |
parse(
$tokens
)
Parse token stream. |
protected mixed |
reduceBlockquoteNode(
$node
)
Reduce multiline blockquote nodes. |
protected mixed |
reduceBulletListItem(
$node
)
Reduce bullet list items to list. |
protected mixed |
reduceEnumeratedListItem(
$node
)
Reduce enumerated list items to list. |
protected mixed |
reduceFootnoteNodes(
$node
)
Reduce wiki footnotes. |
protected mixed |
reduceImageNodes(
$node
)
Reduce wiki image references. |
protected mixed |
reduceLineNode(
$node
)
Reduce line node. |
protected mixed |
reduceLinkNodes(
$node
)
Reduce wiki links. |
protected mixed |
reduceLists(
$node
)
Reduce lists. |
protected mixed |
reduceMatchingInlineMarkup(
$node
)
Reduce matching inline markup. |
protected mixed |
reduceParagraph(
$node
)
Reduce paragraph. |
protected void |
reduceSection(
$node
)
Reduce prior sections, if a new section has been found. |
protected mixed |
reduceTableRow(
$node
)
Reduce table rows. |
protected mixed |
reduceText(
$node
)
Reduce text nodes. |
protected void |
reduceTitleToSection(
$node
)
Reduce all elements to one document node. |
protected mixed |
shiftEscapeToken(
$token
, &$tokens
, $tokens
)
Shift escape token. |
protected mixed |
shiftNewLineToken(
$token
, &$tokens
, $tokens
)
Shift new line token. |
protected mixed |
shiftTitleToken(
$token
, &$tokens
, $tokens
)
Shift title token. |
protected mixed |
shiftWithTokenConversion(
$token
, &$tokens
, $tokens
)
Shift with token conversion. |
From ezcDocumentParser | |
---|---|
public ezcDocumentParser |
ezcDocumentParser::__construct()
Construct new document |
public array |
ezcDocumentParser::getErrors()
Return list of errors occured during visiting the document. |
public void |
ezcDocumentParser::triggerError()
Trigger parser error |
Merge lists recusively.
Merge lists recusively
Name | Type | Description |
---|---|---|
$lists |
array |
Parse token stream.
Parse an array of ezcDocumentWikiToken objects into a wiki abstract syntax tree.
Name | Type | Description |
---|---|---|
$tokens |
array |
Reduce multiline blockquote nodes.
Reduce multline block quote nodes, which are not already closed by line endings.
Name | Type | Description |
---|---|---|
$node |
ezcDocumentWikiBlockquoteNode |
Reduce bullet list items to list.
Reduce list items to lists, and create new wrapping list nodes.
Name | Type | Description |
---|---|---|
$node |
ezcDocumentWikiBlockLevelNode |
Reduce enumerated list items to list.
Reduce list items to lists, and create new wrapping list nodes.
Name | Type | Description |
---|---|---|
$node |
ezcDocumentWikiBlockLevelNode |
Reduce wiki footnotes.
Reduce inline footnotes
Name | Type | Description |
---|---|---|
$node |
ezcDocumentWikiFootnoteEndNode |
Reduce wiki image references.
Reduce image references with all of their aggregated parameters.
Name | Type | Description |
---|---|---|
$node |
ezcDocumentWikiImageEndNode |
Reduce line node.
Line nodes are closed at the end of their respective line. The end is marked by an ezcDocumentWikiInvisibleBreakNode.
Name | Type | Description |
---|---|---|
$node |
ezcDocumentWikiInvisibleBreakNode |
Reduce wiki links.
Reduce links with all of their aggregated parameters.
Name | Type | Description |
---|---|---|
$node |
ezcDocumentWikiLinkEndNode |
Reduce lists.
Stack lists with higher indentation into each other and merge multiple lists of same type and indentation.
Name | Type | Description |
---|---|---|
$node |
ezcDocumentWikiBlockLevelNode |
Reduce matching inline markup.
Reduction rule for inline markup which is intended to have a matching counterpart in the same block level element.
Name | Type | Description |
---|---|---|
$node |
ezcDocumentWikiMatchingInlineNode |
Reduce paragraph.
Paragraphs are reduce with all inline tokens, which have been added to the document stack before. If there are no inline nodes, the paragraph will be ommitted.
Name | Type | Description |
---|---|---|
$node |
ezcDocumentWikiParagraphNode |
Reduce prior sections, if a new section has been found.
If a new section has been found all sections with a higher depth level can be closed, and all items fitting into sections may be aggregated by the respective sections as well.
Name | Type | Description |
---|---|---|
$node |
ezcDocumentWikiSectionNode |
Reduce table rows.
Reduce the nodes aagregated for one table row into table cells, and merge the table rows into table nodes.
Name | Type | Description |
---|---|---|
$node |
ezcDocumentWikiTableRowNode |
Reduce text nodes.
Reduce texts into single nodes, if the prior node is also a text node. This reduces the number of AST nodes required to represent texts drastically.
Name | Type | Description |
---|---|---|
$node |
ezcDocumentWikiTextNode |
Reduce all elements to one document node.
Name | Type | Description |
---|---|---|
$node |
ezcDocumentWikiTitleNode |
Shift escape token.
Escape tokens will cause that the following token is ignored in his common meaning. The following token is converted to plain text, while the escape token will be removed.
Name | Type | Description |
---|---|---|
$token |
ezcDocumentWikiToken | |
$tokens |
array | |
&$tokens |
array |
Shift new line token.
Paragraphs are always indicated by multiple new line tokens. When detected we just shift a paragraph node, which the will be reduced with prior inline nodes.
Name | Type | Description |
---|---|---|
$token |
ezcDocumentWikiToken | |
$tokens |
array | |
&$tokens |
array |
Shift title token.
Some wiki markup languages use a second title token at the end of the line instead of just a line break. In the case we are already inside a line token, just shift an invisible line break.
Name | Type | Description |
---|---|---|
$token |
ezcDocumentWikiToken | |
$tokens |
array | |
&$tokens |
array |
Shift with token conversion.
Token to node conversions are used for tokens, which do not require any additional checking of the tokens context. This is especially useful, because the wiki tokenizer already implement a lot of this logic.
The actual conversions are specified in the class property $conversionsArray.
Name | Type | Description |
---|---|---|
$token |
ezcDocumentWikiToken | |
$tokens |
array | |
&$tokens |
array |