Class: ParsingResult

mmir.parser. ParsingResult

new mmir.parser.ParsingResult(thetokens)

ParsingResult represents an element that was detected during parsing.

The detected element is referenced by the properties start and end that refer to the start-index and end-index within the parsed text.

The ParsingResult has a type property which refers to the kind of element that was detected (see constants in mmir.parser.Element).

In addition, the ParsingResult may have several properties that depend of its type. In general, these properties refer to detected parts of the element (e.g. for a invocation-statement, these may refer to its arguments).

Properties for INCLUDE_SCRIPT type:

  • scriptPath: the path / URL to the resource
  • scriptPathType: the type of the scriptPath field: one of StringLiteral, Identifier, IdentifierNameAmpersatStart

Properties for INCLUDE_STYLE type:

  • stylePath:
  • stylePathType: the type of the stylePath field: one of StringLiteral, Identifier, IdentifierNameAmpersatStart

Properties for LOCALIZE type:

  • name: the name/identifier for the localized String
  • nameType: the type of the name field: one of StringLiteral, Identifier, IdentifierNameAmpersatStart

Properties for YIELD_DECLARATION type:

  • name: the name/identifier for the yield section
  • nameType: the type of the name field: one of StringLiteral, Identifier, IdentifierNameAmpersatStart
Properties for BLOCK type:
  • scriptContent {String}: OPTIONALLY the script code as a String
  • scriptEval {Function}: the compiled script code in form of a function. The function takes one argument: the current data-object.

Properties for STATEMENT type:

  • scriptContent {String}: OPTIONALLY the script code as a String
  • scriptEval {Function}: the compiled script code in form of a function. The function takes one argument: the current data-object.

Properties for HELPER type:

  • helper: the name of the helper function
  • helperType: the type of the helper field: one of StringLiteral, Identifier, IdentifierNameAmpersatStart
  • argsEval {Function}: OPTIONALLY compiled getter Function for retrieving the current ARGS (optional argument) of the helper expression. The function takes one argument: the current data-object.

Properties for IF type:

  • ifEval {Function}: the condition statement, that was compiled into a Function. The function takes one argument: the current data-object.
  • content {ContentElement}: the HTML / template content that should be render, in case the if-expression evaluates to true.
  • elseContent mmir.parser.ParsingResult: OPTIONALLY a ParsingResult representing an else-expression, see mmir.parser.Element.ELSE.

Properties for ELSE type:

  • content {ContentElement}: the HTML / template content that should be render, in case the if-expression (to which the else-expression belongs) evaluates to false.

Properties for FOR type:

  • forControlType {String}: the type of for-loop, either FORITER or FORSTEP
  • forInitEval {Function}: the initialization statement of the for-expression, compiled into a Function. The function takes one argument: the current data-object.
  • FORITER: @for(PROP in OBJ){ ... }@
    • forIterator {Object}: an iterator object with functions hasNext() : Boolean and next() : String (which returns the name of the property currently iterated).
    • forPropName {String}: the variable name for the property which is currently iterated over.
  • FORSTEP: @for(INIT; CONDITION; INCREMENT){ ... }@
    • forConditionEval {Function}: the condition statement of the for-expression, compiled into a Function. The function takes one argument: the current data-object.
    • forIncrementEval {Function}: the increment statement of the for-expression, compiled into a Function. The function takes one argument: the current data-object.
  • content {ContentElement}: the HTML / template content that should be rendered during each iteration of the for-loop.

Properties for RENDER type:

  • partial: the name of the partial view
  • partialType: the type of the partial field: one of StringLiteral, Identifier, IdentifierNameAmpersatStart
  • controller: the name of the controller, to which the partial view definition belongs
  • controllerType: the type of the controller field: one of StringLiteral, Identifier, IdentifierNameAmpersatStart
  • argsEval {Function}: OPTIONALLY compiled getter Function for retrieving the current ARGS (optional argument) of the render expression. The function takes one argument: the current data-object.

Properties for ESCAPE_ENTER type:

  • text {String}: the text that will be rendered (i.e. without the escape-character(s) itself).

Properties for ESCAPE_EXIT type:

  • text {String}: the text that will be rendered (i.e. without the escape-character(s) itself).

Properties for VAR_DECLARATION type:

  • name: the name for the variable (without the leading @ of template variables)
  • nameType: the type of the name field: StringLiteral

Name Type Description
thetokens org.antlr.runtime.CommonTokenStream | org.antlr.runtime.Token optional OPTIONAL if org.antlr.runtime.CommonTokenStream: the TokenStream that corresponds to this parsed element; when provided, the TokenStream is used to set the start- and end- property of the new instance.
if org.antlr.runtime.Token: if the parameter is a single Token object, then the start- and end- property for the new instance is set by this token object

Methods

staticmmir.parser.ParsingResult.ParsingResult#getCallDataEnd()

staticmmir.parser.ParsingResult.ParsingResult#getCallDataStart()

staticmmir.parser.ParsingResult.ParsingResult#getCallDataType()

staticmmir.parser.ParsingResult.ParsingResult#getEnd()

staticmmir.parser.ParsingResult.ParsingResult#getStart()

staticmmir.parser.ParsingResult.ParsingResult#getType(){mmir.parser.Element}

Get the type of this parsed element, i.e. as which type this element was parsed. The type corresponds to one of the type defined in {mmir.parser.Element}.
Returns:
Type Description
mmir.parser.Element the type for this ParsingResult

staticmmir.parser.ParsingResult.ParsingResult#getTypeName(){String}

WARNING: do use sparingly -- an invocation triggers a list evaluation.
Returns:
Type Description
String a String representation (name) for this ParsingResult's type

staticmmir.parser.ParsingResult.ParsingResult#getValue()

helper function for converting properties to the correct value. By default, the ParsingResult only contains "raw" property values. Which properties are available, depends on the type of the ParsingResult (see templateProcessor.js)

staticmmir.parser.ParsingResult.ParsingResult#hasCallData()

staticmmir.parser.ParsingResult.ParsingResult#hasElse()

staticmmir.parser.ParsingResult.ParsingResult#hasVarReferences()

staticmmir.parser.ParsingResult.ParsingResult#isElse()

staticmmir.parser.ParsingResult.ParsingResult#isEscape()

staticmmir.parser.ParsingResult.ParsingResult#isEscapeEnter()

staticmmir.parser.ParsingResult.ParsingResult#isEscapeExit()

staticmmir.parser.ParsingResult.ParsingResult#isFor()

staticmmir.parser.ParsingResult.ParsingResult#isHelper()

staticmmir.parser.ParsingResult.ParsingResult#isIf()

staticmmir.parser.ParsingResult.ParsingResult#isLocalize()

staticmmir.parser.ParsingResult.ParsingResult#isRender()

staticmmir.parser.ParsingResult.ParsingResult#isScriptBlock()

staticmmir.parser.ParsingResult.ParsingResult#isScriptStatement()

staticmmir.parser.ParsingResult.ParsingResult#isScriptTag()

staticmmir.parser.ParsingResult.ParsingResult#isStyleTag()

staticmmir.parser.ParsingResult.ParsingResult#isYield()

staticmmir.parser.ParsingResult.ParsingResult#isYieldContent()

staticmmir.parser.ParsingResult.ParsingResult#setEndFrom(thetokens)

Set the end position (index) for this parsed element with regard to the TokenStream of the complete input.
Name Type Description
thetokens org.antlr.runtime.CommonTokenStream (optional) the TokenStream that corresponds to this parsed element; when provided, the TokenStream is used to set the end-property of this object.

staticmmir.parser.ParsingResult.ParsingResult#setStartFrom(thetokens)

Set the start position (index) for this parsed element with regard to the TokenStream of the complete input.
Name Type Description
thetokens org.antlr.runtime.CommonTokenStream (optional) the TokenStream that corresponds to this parsed element; when provided, the TokenStream is used to set the start-property of this object.

staticmmir.parser.ParsingResult.ParsingResult#stringify()