public class StructuralWhitespaceStripper extends DepthFirstAdapter
A structural command is any command that never emits any output. These come in three types:
This makes it much easier to write human readable templates in cases where the output format is whitespace sensitive.
Thus the input:
---------------- Value is: <?cs if:x>0 ?> positive <?cs elif:x<0 ?> negative <?cs else ?> zero <?cs /if ?>. ----------------is equivalent to:
---------------- Value is: <?cs if:x>0 ?> positive <?cs elif:x<0 ?> negative <?cs else ?> zero <?cs /if ?>. ----------------but is much easier to read.
Where data commands become empty they are replaced with Noop commands, which effectively removes them from the tree. These can be removed (if needed) by a later optimization step but shouldn't cause any issues.
Constructor and Description |
---|
StructuralWhitespaceStripper() |
Modifier and Type | Method and Description |
---|---|
void |
caseAAltCommand(AAltCommand node) |
void |
caseADataCommand(ADataCommand data) |
void |
caseADefCommand(ADefCommand node) |
void |
caseAEachCommand(AEachCommand node) |
void |
caseAEscapeCommand(AEscapeCommand node) |
void |
caseAIfCommand(AIfCommand node) |
void |
caseALoopCommand(ALoopCommand node) |
void |
caseALoopIncCommand(ALoopIncCommand node) |
void |
caseALoopToCommand(ALoopToCommand node) |
void |
caseAWithCommand(AWithCommand node) |
void |
caseStart(Start node) |
void |
enterComplexCommand() |
void |
exitComplexCommand() |
void |
inAAltCommand(AAltCommand node) |
void |
inACallCommand(ACallCommand node) |
void |
inAEvarCommand(AEvarCommand node) |
void |
inALvarCommand(ALvarCommand node) |
void |
inANameCommand(ANameCommand node) |
void |
inASetCommand(ASetCommand node) |
void |
inAUvarCommand(AUvarCommand node) |
void |
inAVarCommand(AVarCommand node) |
caseAAddExpression, caseAAndExpression, caseAAutoescapeCommand, caseACallCommand, caseACommaExpression, caseACommentCommand, caseAContentTypeCommand, caseACsOpenPosition, caseADecimalExpression, caseADecNumberVariable, caseADescendVariable, caseADivideExpression, caseAEqExpression, caseAEvarCommand, caseAExistsExpression, caseAExpandVariable, caseAFunctionExpression, caseAGteExpression, caseAGtExpression, caseAHardIncludeCommand, caseAHardLincludeCommand, caseAHexExpression, caseAHexNumberVariable, caseAIncludeCommand, caseAInlineCommand, caseALincludeCommand, caseALteExpression, caseALtExpression, caseALvarCommand, caseAModuloExpression, caseAMultipleCommand, caseAMultiplyExpression, caseANameCommand, caseANameVariable, caseANeExpression, caseANegativeExpression, caseANoopCommand, caseANoopExpression, caseANotExpression, caseANumericAddExpression, caseANumericEqExpression, caseANumericExpression, caseANumericNeExpression, caseAOrExpression, caseASequenceExpression, caseASetCommand, caseAStringExpression, caseASubtractExpression, caseAUvarCommand, caseAVarCommand, caseAVariableExpression, defaultIn, defaultOut, inAAddExpression, inAAndExpression, inAAutoescapeCommand, inACommaExpression, inACommentCommand, inAContentTypeCommand, inACsOpenPosition, inADataCommand, inADecimalExpression, inADecNumberVariable, inADefCommand, inADescendVariable, inADivideExpression, inAEachCommand, inAEqExpression, inAEscapeCommand, inAExistsExpression, inAExpandVariable, inAFunctionExpression, inAGteExpression, inAGtExpression, inAHardIncludeCommand, inAHardLincludeCommand, inAHexExpression, inAHexNumberVariable, inAIfCommand, inAIncludeCommand, inAInlineCommand, inALincludeCommand, inALoopCommand, inALoopIncCommand, inALoopToCommand, inALteExpression, inALtExpression, inAModuloExpression, inAMultipleCommand, inAMultiplyExpression, inANameVariable, inANeExpression, inANegativeExpression, inANoopCommand, inANoopExpression, inANotExpression, inANumericAddExpression, inANumericEqExpression, inANumericExpression, inANumericNeExpression, inAOrExpression, inASequenceExpression, inAStringExpression, inASubtractExpression, inAVariableExpression, inAWithCommand, inStart, outAAddExpression, outAAltCommand, outAAndExpression, outAAutoescapeCommand, outACallCommand, outACommaExpression, outACommentCommand, outAContentTypeCommand, outACsOpenPosition, outADataCommand, outADecimalExpression, outADecNumberVariable, outADefCommand, outADescendVariable, outADivideExpression, outAEachCommand, outAEqExpression, outAEscapeCommand, outAEvarCommand, outAExistsExpression, outAExpandVariable, outAFunctionExpression, outAGteExpression, outAGtExpression, outAHardIncludeCommand, outAHardLincludeCommand, outAHexExpression, outAHexNumberVariable, outAIfCommand, outAIncludeCommand, outAInlineCommand, outALincludeCommand, outALoopCommand, outALoopIncCommand, outALoopToCommand, outALteExpression, outALtExpression, outALvarCommand, outAModuloExpression, outAMultipleCommand, outAMultiplyExpression, outANameCommand, outANameVariable, outANeExpression, outANegativeExpression, outANoopCommand, outANoopExpression, outANotExpression, outANumericAddExpression, outANumericEqExpression, outANumericExpression, outANumericNeExpression, outAOrExpression, outASequenceExpression, outASetCommand, outAStringExpression, outASubtractExpression, outAUvarCommand, outAVarCommand, outAVariableExpression, outAWithCommand, outStart
caseEOF, caseTAlt, caseTAnd, caseTArgWhitespace, caseTAssignment, caseTAutoescape, caseTBang, caseTBracketClose, caseTBracketOpen, caseTCall, caseTComma, caseTCommandDelimiter, caseTComment, caseTCommentStart, caseTContentType, caseTCsClose, caseTCsOpen, caseTData, caseTDecNumber, caseTDef, caseTDollar, caseTDot, caseTEach, caseTElse, caseTElseIf, caseTEq, caseTEscape, caseTEvar, caseTGt, caseTGte, caseTHardDelimiter, caseTHash, caseTHexNumber, caseTIf, caseTInclude, caseTInline, caseTLinclude, caseTLoop, caseTLt, caseTLte, caseTLvar, caseTMinus, caseTName, caseTNe, caseTOr, caseTParenClose, caseTParenOpen, caseTPercent, caseTPlus, caseTQuestion, caseTSet, caseTSlash, caseTStar, caseTString, caseTUvar, caseTVar, caseTWith, caseTWord, defaultCase, getIn, getOut, setIn, setOut
public void caseStart(Start node)
caseStart
in interface Analysis
caseStart
in class DepthFirstAdapter
public void caseADataCommand(ADataCommand data)
caseADataCommand
in interface Analysis
caseADataCommand
in class DepthFirstAdapter
public void inAAltCommand(AAltCommand node)
inAAltCommand
in class DepthFirstAdapter
public void inACallCommand(ACallCommand node)
inACallCommand
in class DepthFirstAdapter
public void inAEvarCommand(AEvarCommand node)
inAEvarCommand
in class DepthFirstAdapter
public void inALvarCommand(ALvarCommand node)
inALvarCommand
in class DepthFirstAdapter
public void inANameCommand(ANameCommand node)
inANameCommand
in class DepthFirstAdapter
public void inASetCommand(ASetCommand node)
inASetCommand
in class DepthFirstAdapter
public void inAUvarCommand(AUvarCommand node)
inAUvarCommand
in class DepthFirstAdapter
public void inAVarCommand(AVarCommand node)
inAVarCommand
in class DepthFirstAdapter
public void enterComplexCommand()
public void exitComplexCommand()
public void caseAAltCommand(AAltCommand node)
caseAAltCommand
in interface Analysis
caseAAltCommand
in class DepthFirstAdapter
public void caseADefCommand(ADefCommand node)
caseADefCommand
in interface Analysis
caseADefCommand
in class DepthFirstAdapter
public void caseAEachCommand(AEachCommand node)
caseAEachCommand
in interface Analysis
caseAEachCommand
in class DepthFirstAdapter
public void caseAEscapeCommand(AEscapeCommand node)
caseAEscapeCommand
in interface Analysis
caseAEscapeCommand
in class DepthFirstAdapter
public void caseAIfCommand(AIfCommand node)
caseAIfCommand
in interface Analysis
caseAIfCommand
in class DepthFirstAdapter
public void caseALoopCommand(ALoopCommand node)
caseALoopCommand
in interface Analysis
caseALoopCommand
in class DepthFirstAdapter
public void caseALoopIncCommand(ALoopIncCommand node)
caseALoopIncCommand
in interface Analysis
caseALoopIncCommand
in class DepthFirstAdapter
public void caseALoopToCommand(ALoopToCommand node)
caseALoopToCommand
in interface Analysis
caseALoopToCommand
in class DepthFirstAdapter
public void caseAWithCommand(AWithCommand node)
caseAWithCommand
in interface Analysis
caseAWithCommand
in class DepthFirstAdapter
Copyright © 2010–2015 Google. All rights reserved.