Parser
class Parser implements ParserInterface (View source)
The Fusion Parser
Constants
SCAN_PATTERN_COMMENT |
|
SCAN_PATTERN_OPENINGCONFINEMENT |
|
SCAN_PATTERN_CLOSINGCONFINEMENT |
|
SCAN_PATTERN_DECLARATION |
|
SCAN_PATTERN_OBJECTDEFINITION |
|
SCAN_PATTERN_OBJECTPATH |
|
SPLIT_PATTERN_OBJECTPATH |
Split an object path like "foo.bar.baz.quux", "foo.'bar.baz.quux'" or "foo.prototype(Neos.Fusion:Something).bar.baz"
at the dots (but not the dots inside the prototype definition prototype(...) or dots inside quotes) |
SCAN_PATTERN_OBJECTPATHSEGMENT_IS_PROTOTYPE |
Analyze an object path segment like "foo" or "prototype(Neos.Fusion:Something)"
and detect the latter |
SPLIT_PATTERN_COMMENTTYPE |
|
SPLIT_PATTERN_DECLARATION |
|
SPLIT_PATTERN_NAMESPACEDECLARATION |
|
SPLIT_PATTERN_OBJECTDEFINITION |
|
SPLIT_PATTERN_VALUENUMBER |
|
SPLIT_PATTERN_VALUEFLOATNUMBER |
|
SPLIT_PATTERN_VALUELITERAL |
|
SPLIT_PATTERN_VALUEMULTILINELITERAL |
|
SPLIT_PATTERN_VALUEBOOLEAN |
|
SPLIT_PATTERN_VALUENULL |
|
SCAN_PATTERN_VALUEOBJECTTYPE |
|
SCAN_PATTERN_DSL_EXPRESSION_START |
|
SPLIT_PATTERN_DSL_EXPRESSION |
|
Properties
static array | $reservedParseTreeKeys | Reserved parse tree keys for internal usage. |
|
protected ObjectManagerInterface | $objectManager | ||
protected DslFactory | $dslFactory | ||
protected array | $objectTree | The Fusion object tree, created by this parser. |
|
protected int | $currentLineNumber | The line number which is currently processed |
|
protected array | $currentSourceCodeLines | An array of strings of the source code which has |
|
protected array | $currentObjectPathStack | The current object path context as defined by confinements. |
|
protected bool | $currentBlockCommentState | Determines if a block comment is currently active or not. |
|
protected string | $contextPathAndFilename | An optional context path which is used as a prefix for inclusion of further Fusion files |
|
protected array deprecated | $objectTypeNamespaces | Namespaces used for resolution of Fusion object names. These namespaces are a mapping from a user defined key (alias) to a package key (the namespace). |
Methods
Parses the given Fusion source code and returns an object tree as the result.
Sets the given alias to the specified namespace.
Initializes the Fusion parser
Get the next, unparsed line of Fusion from this->currentSourceCodeLines and increase the pointer
Parses one line of Fusion
Parses a line with comments or a line while parsing is in block comment mode.
Parses a line which opens or closes a confinement
Parses a parser declaration of the form "declarationtype: declaration".
Parses an object definition.
Parses a value operation of the type "assignment".
Unsets the object, property or variable specified by the object path.
Copies the object or value specified by sourcObjectPath and assigns it to targetObjectPath.
Parses a namespace declaration and stores the result in the namespace registry.
Parse an include file. Currently, we start a new parser object; but we could as well re-use the given one.
Parse an object path specified as a string and returns an array.
Parses the given value (which may be a literal, variable or object type) and returns the evaluated result, including variables replaced by their actual value.
No description
Assigns a value to a node or a property in the object tree, specified by the object path array.
Retrieves a value from a node in the object tree, specified by the object path array.
Returns the first part of an object path from the current object path stack which can be used to prefix a relative object path.
Precalculate merged configuration for inherited prototypes.
Removes escapings from a given argument string and trims the outermost quotes.
Render a hint about the currently rendered file and líne that is to be used in Exception Messages to show where parser errors originate from
Details
array
parse(string $sourceCode, string $contextPathAndFilename = null, array $objectTreeUntilNow = [], bool $buildPrototypeHierarchy = true)
Parses the given Fusion source code and returns an object tree as the result.
void
setObjectTypeNamespace(string $alias, string $namespace)
deprecated
deprecated
Sets the given alias to the specified namespace.
The namespaces defined through this setter or through a "namespace" declaration in one of the Fusions are used to resolve a fully qualified Fusion object name while parsing Fusion code.
The alias is the handle by wich the namespace can be referred to. The namespace is, by convention, a package key which must correspond to a namespace used in the prototype definitions for Fusion object types.
The special alias "default" is used as a fallback for resolution of unqualified Fusion object types.
protected void
initialize()
Initializes the Fusion parser
protected string
getNextFusionLine()
Get the next, unparsed line of Fusion from this->currentSourceCodeLines and increase the pointer
protected void
parseFusionLine(string $fusionLine)
Parses one line of Fusion
protected void
parseComment(string $fusionLine)
Parses a line with comments or a line while parsing is in block comment mode.
protected void
parseConfinementBlock(string $fusionLine, bool $isOpeningConfinement)
Parses a line which opens or closes a confinement
protected void
parseDeclaration(string $fusionLine)
Parses a parser declaration of the form "declarationtype: declaration".
protected void
parseObjectDefinition(string $fusionLine)
Parses an object definition.
protected void
parseValueAssignment(string $objectPath, string $value)
Parses a value operation of the type "assignment".
protected void
parseValueUnAssignment(string $objectPath)
Unsets the object, property or variable specified by the object path.
protected void
parseValueCopy(string $sourceObjectPath, string $targetObjectPath)
Copies the object or value specified by sourcObjectPath and assigns it to targetObjectPath.
protected void
parseNamespaceDeclaration(string $namespaceDeclaration)
Parses a namespace declaration and stores the result in the namespace registry.
protected void
parseInclude(string $include)
Parse an include file. Currently, we start a new parser object; but we could as well re-use the given one.
protected array
getParsedObjectPath(string $objectPath)
Parse an object path specified as a string and returns an array.
protected mixed
getProcessedValue(string $unparsedValue)
Parses the given value (which may be a literal, variable or object type) and returns the evaluated result, including variables replaced by their actual value.
protected mixed
invokeAndParseDsl(string $identifier, $code)
No description
protected array
setValueInObjectTree(array $objectPathArray, mixed $value, array $objectTree = null)
Assigns a value to a node or a property in the object tree, specified by the object path array.
protected mixed
getValueFromObjectTree(array $objectPathArray, array $objectTree = null)
Retrieves a value from a node in the object tree, specified by the object path array.
protected string
getCurrentObjectPathPrefix()
Returns the first part of an object path from the current object path stack which can be used to prefix a relative object path.
protected void
buildPrototypeHierarchy()
Precalculate merged configuration for inherited prototypes.
protected string
unquoteString(string $quotedValue)
Removes escapings from a given argument string and trims the outermost quotes.
This method is meant as a helper for regular expression results.
protected string
renderCurrentFileAndLineInformation()
Render a hint about the currently rendered file and líne that is to be used in Exception Messages to show where parser errors originate from