Extractor class
Lg template extracter.
- Extends
-
AbstractParseTreeVisitor<Map<string, string[]>>
Constructors
Extractor(Template[]) | Creates a new instance of the Extractor class. |
Properties
template |
|
templates |
Methods
extract() | Extracts the templates and returns a map with their names and bodies. |
visit |
Visit a parse tree produced by the ifElseBody labeled alternative in LGTemplateParser.body. |
visit |
Visit a parse tree produced by LGTemplateParser.normalTemplateBody. |
visit |
Visit a parse tree produced by the structuredBody labeled alternative in LGTemplateParser.body. |
visit |
Visit a parse tree produced by the switchCaseBody labeled alternative in LGTemplateParser.body. |
Inherited Methods
visit(Parse |
{@inheritDoc} The default implementation calls <xref:ParseTree%23accept> on the specified tree. |
visit |
{@inheritDoc}
The default implementation initializes the aggregate result to
defaultResult(). Before visiting each child, it
calls shouldVisitNextChild; if the result
is The default implementation is not safe for use in visitors that modify the tree structure. Visitors that modify the tree should override this method to behave properly in respect to the specific algorithm in use. |
visit |
{@inheritDoc} The default implementation returns the result of defaultResult. |
visit |
{@inheritDoc} The default implementation returns the result of defaultResult. |
Constructor Details
Extractor(Template[])
Creates a new instance of the Extractor class.
new Extractor(templates: Template[])
Parameters
- templates
-
Template[]
Template list.
Property Details
templateMap
templates
Method Details
extract()
Extracts the templates and returns a map with their names and bodies.
function extract(): Map<string, string[] | Map<string, string[]>>[]
Returns
Map<string, string[] | Map<string, string[]>>[]
Map object with template names and bodies.
visitIfElseBody(IfElseBodyContext)
Visit a parse tree produced by the ifElseBody labeled alternative in LGTemplateParser.body.
function visitIfElseBody(context: IfElseBodyContext): Map<string, string[]>
Parameters
- context
- IfElseBodyContext
The parse tree.
Returns
Map<string, string[]>
The result of visiting the if else body.
visitNormalTemplateBody(NormalTemplateBodyContext)
Visit a parse tree produced by LGTemplateParser.normalTemplateBody.
function visitNormalTemplateBody(context: NormalTemplateBodyContext): Map<string, string[]>
Parameters
- context
- NormalTemplateBodyContext
The parse tree.
Returns
Map<string, string[]>
The result of visiting the normal template body.
visitStructuredBody(StructuredBodyContext)
Visit a parse tree produced by the structuredBody labeled alternative in LGTemplateParser.body.
function visitStructuredBody(context: StructuredBodyContext): Map<string, string[]>
Parameters
- context
- StructuredBodyContext
The parse tree.
Returns
Map<string, string[]>
The result of visiting the structured body.
visitSwitchCaseBody(SwitchCaseBodyContext)
Visit a parse tree produced by the switchCaseBody labeled alternative in LGTemplateParser.body.
function visitSwitchCaseBody(context: SwitchCaseBodyContext): Map<string, string[]>
Parameters
- context
- SwitchCaseBodyContext
The parse tree.
Returns
Map<string, string[]>
The result of visiting the switch case body.
Inherited Method Details
visit(ParseTree)
{@inheritDoc} The default implementation calls <xref:ParseTree%23accept> on the specified tree.
function visit(tree: ParseTree): Map<string, string[]>
Parameters
- tree
-
ParseTree
Returns
Map<string, string[]>
Inherited From AbstractParseTreeVisitor.visit
visitChildren(RuleNode)
{@inheritDoc}
The default implementation initializes the aggregate result to
defaultResult(). Before visiting each child, it
calls shouldVisitNextChild; if the result
is false
no more children are visited and the current aggregate
result is returned. After visiting a child, the aggregate result is
updated by calling aggregateResult with the
previous aggregate result and the result of visiting the child.
The default implementation is not safe for use in visitors that modify the tree structure. Visitors that modify the tree should override this method to behave properly in respect to the specific algorithm in use.
function visitChildren(node: RuleNode): Map<string, string[]>
Parameters
- node
-
RuleNode
Returns
Map<string, string[]>
Inherited From AbstractParseTreeVisitor.visitChildren
visitErrorNode(ErrorNode)
{@inheritDoc} The default implementation returns the result of defaultResult.
function visitErrorNode(node: ErrorNode): Map<string, string[]>
Parameters
- node
-
ErrorNode
Returns
Map<string, string[]>
Inherited From AbstractParseTreeVisitor.visitErrorNode
visitTerminal(TerminalNode)
{@inheritDoc} The default implementation returns the result of defaultResult.
function visitTerminal(node: TerminalNode): Map<string, string[]>
Parameters
- node
-
TerminalNode
Returns
Map<string, string[]>
Inherited From AbstractParseTreeVisitor.visitTerminal