Zeta Components Manual :: Docs For Class ezcDocumentBBCodeParser
Document::ezcDocumentBBCodeParser
Class ezcDocumentBBCodeParser
Parser for bbcode documents.
Source for this file: /Document/src/document/bbcode/parser.php
ezcDocumentParser | --ezcDocumentBBCodeParser
Version: | //autogen// |
Member Variables
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 array |
$reductions
= array(
Array containing simplified reduce ruleset. We cannot express the BBCode 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 BBCode 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.bbcodepedia.org/bbcode/Pumping_lemma_for_context-free_languages |
Inherited Member Variables
From ezcDocumentParser | |
---|---|
protected |
ezcDocumentParser::$options
|
protected |
ezcDocumentParser::$properties
|
Method Summary
public ezcDocumentBBCodeDocumentNode |
parse(
$tokens
)
Parse token stream. |
protected void |
reduceDocument(
$node
)
Reduce prior sections, if a new section has been found. |
protected mixed |
reduceList(
$node
)
Reduce list. |
protected mixed |
reduceListItem(
$node
)
Reduce list items. |
protected mixed |
reduceParagraph(
$node
)
Reduce paragraph. |
protected mixed |
reduceTags(
$node
)
Reduce tags. |
protected mixed |
shiftClosingToken(
$token
, &$tokens
, $tokens
)
Shift tag clsoing token |
protected mixed |
shiftEndOfFileToken(
$token
, &$tokens
, $tokens
)
Shift EOF token. |
protected mixed |
shiftListItemToken(
$token
, &$tokens
, $tokens
)
Shift list item token |
protected mixed |
shiftLiteralBlockToken(
$token
, &$tokens
, $tokens
)
Shift literal block token |
protected mixed |
shiftNewLineToken(
$token
, &$tokens
, $tokens
)
Shift new line token. |
protected mixed |
shiftOpeningToken(
$token
, &$tokens
, $tokens
)
Shift tag opening token |
protected mixed |
shiftTextToken(
$token
, &$tokens
, $tokens
)
Shift text token. |
protected mixed |
shiftWhitespaceToken(
$token
, &$tokens
, $tokens
)
Shift whitespace token. |
Inherited Methods
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 |
Methods
parse
Parse token stream.
Parse an array of ezcDocumentBBCodeToken objects into a bbcode abstract syntax tree.
Parameters:
Name | Type | Description |
---|---|---|
$tokens |
array |
reduceDocument
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.
Parameters:
Name | Type | Description |
---|---|---|
$node |
ezcDocumentBBCodeDocumentNode |
reduceList
Reduce list.
Aggregates list items and puts them into a found list.
Parameters:
Name | Type | Description |
---|---|---|
$node |
ezcDocumentBBCodeParagraphNode |
reduceListItem
Reduce list items.
Aggregates list items and puts them into a found list.
Parameters:
Name | Type | Description |
---|---|---|
$node |
ezcDocumentBBCodeParagraphNode |
reduceParagraph
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.
Parameters:
Name | Type | Description |
---|---|---|
$node |
ezcDocumentBBCodeParagraphNode |
reduceTags
Reduce tags.
Locates the matching opening tag for a closing tag and reduces the contents found on the way back.
Parameters:
Name | Type | Description |
---|---|---|
$node |
ezcDocumentBBCodeClosingTagNode |
shiftClosingToken
Shift tag clsoing token
Closing tags mean that the preceeding contents will be aggregated, once a matching opening tag is found. Is just shifted to the document stack, and the appropriate reduce call will follow right away.
Parameters:
Name | Type | Description |
---|---|---|
$token |
ezcDocumentBBCodeToken | |
$tokens |
array | |
&$tokens |
array |
shiftEndOfFileToken
Shift EOF token.
Shift End-Of-File token. We reached the end of the document, and therefore shift a document node onto the stack.
Parameters:
Name | Type | Description |
---|---|---|
$token |
ezcDocumentBBCodeToken | |
$tokens |
array | |
&$tokens |
array |
shiftListItemToken
Shift list item token
List item tokens indicate a new list item. Just put them on the stack, they will be aggregated later.
Parameters:
Name | Type | Description |
---|---|---|
$token |
ezcDocumentBBCodeToken | |
$tokens |
array | |
&$tokens |
array |
shiftLiteralBlockToken
Shift literal block token
Literal blocks are just a chunk of code or similar, where the token can jsut be converted into an apropriate node.
Parameters:
Name | Type | Description |
---|---|---|
$token |
ezcDocumentBBCodeToken | |
$tokens |
array | |
&$tokens |
array |
shiftNewLineToken
Shift new line token.
Double new lines are considered as paragraphs. All other new lines are just shifted as single whitespace text nodes.
Parameters:
Name | Type | Description |
---|---|---|
$token |
ezcDocumentBBCodeToken | |
$tokens |
array | |
&$tokens |
array |
shiftOpeningToken
Shift tag opening token
Opening tags mean that the following contents will be aggregated, once a matching closing tag is found. Is just shifted to the document stack.
Parameters:
Name | Type | Description |
---|---|---|
$token |
ezcDocumentBBCodeToken | |
$tokens |
array | |
&$tokens |
array |
shiftTextToken
Shift text token.
Parameters:
Name | Type | Description |
---|---|---|
$token |
ezcDocumentBBCodeToken | |
$tokens |
array | |
&$tokens |
array |
shiftWhitespaceToken
Shift whitespace token.
Shift whitespace tokens. Whitespaces are only considered significant, if the prior token was not a block level element.
Parameters:
Name | Type | Description |
---|---|---|
$token |
ezcDocumentBBCodeToken | |
$tokens |
array | |
&$tokens |
array |