Package com.scriptbasic.syntax
Class AbstractNestedStructureHouseKeeper
java.lang.Object
com.scriptbasic.syntax.AbstractNestedStructureHouseKeeper
- All Implemented Interfaces:
NestedStructureHouseKeeper
- Direct Known Subclasses:
GenericNestedStructureHouseKeeper
public abstract class AbstractNestedStructureHouseKeeper extends java.lang.Object implements NestedStructureHouseKeeper
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractNestedStructureHouseKeeper.StructureNested classes/interfaces inherited from interface com.scriptbasic.interfaces.NestedStructureHouseKeeper
NestedStructureHouseKeeper.EndOfStatementProcessor, NestedStructureHouseKeeper.EndOfStatementResult -
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractNestedStructureHouseKeeper(LexicalAnalyzer analyzer) -
Method Summary
Modifier and Type Method Description voidcheckFinalState()Check final state of nested structures.voidconsumeEndOfStatement()Checks that there are no extra characters when the line analyzer expects it has finished analyzing the statement.protected booleanisStackIsHealthy()<T extends NestedStructure>
Tpop(java.lang.Class<T> expectedClass)Pops one element from the stack.NestedStructureHouseKeeper.EndOfStatementProcessorpopEndOfStatementProcessor()voidpush(NestedStructure element)Push a nested structure object on the housekeeping stack.voidpush(java.lang.Class<?> klass, NestedStructure element)Push a nested structure object on the housekeeping stack.voidpushEndOfStatementProcessor(NestedStructureHouseKeeper.EndOfStatementProcessor endOfStatementProcessor)
-
Constructor Details
-
Method Details
-
push
Description copied from interface:NestedStructureHouseKeeperPush a nested structure object on the housekeeping stack. This version of push does push the object associated with the actual class of the object.- Specified by:
pushin interfaceNestedStructureHouseKeeper- Parameters:
element- to push on the stack.
-
isStackIsHealthy
protected boolean isStackIsHealthy() -
push
Description copied from interface:NestedStructureHouseKeeperPush a nested structure object on the housekeeping stack.- Specified by:
pushin interfaceNestedStructureHouseKeeper- Parameters:
klass- is the class that we will expect when we pop this element offelement- the element to be stored on the stack.
-
pop
public <T extends NestedStructure> T pop(java.lang.Class<T> expectedClass) throws AnalysisExceptionDescription copied from interface:NestedStructureHouseKeeperPops one element from the stack.Note that nested element have to be pushed on the stack nested. If we get an element off the stack that was not expected it means syntax error and therefore in this case exception is thrown.
When exception was thrown the functioning of the object is not defined by this interface. Some implementation may seek the appropriate element in the stack and throw off all top element until a proper type of element is found assuming that the user forgot to close some internal programming structured in the scripted language. Other implementations may follow more complex strategy to recover from such an error. In either case the sole reason of further syntax analysis is to discover as many syntax error as possible following the first one.
- Specified by:
popin interfaceNestedStructureHouseKeeper- Type Parameters:
T- expected type of the element- Parameters:
expectedClass- the expected class of the element- Returns:
- the top element
- Throws:
AnalysisException- when the top element of the stack is not the type that we expect
-
checkFinalState
Description copied from interface:NestedStructureHouseKeeperCheck final state of nested structures. Check if there are no opened nested structures or any other pending blocks.- Specified by:
checkFinalStatein interfaceNestedStructureHouseKeeper- Throws:
AnalysisException- when there are some elements on the stack
-
consumeEndOfStatement
Description copied from interface:NestedStructureHouseKeeperChecks that there are no extra characters when the line analyzer expects it has finished analyzing the statement. If there are some extra characters on the line then throws syntax error exception. Otherwise it simply steps the lexical analyzer iterator over the symbol.- Specified by:
consumeEndOfStatementin interfaceNestedStructureHouseKeeper- Throws:
AnalysisException- when there are extra character on the actual line
-
pushEndOfStatementProcessor
public void pushEndOfStatementProcessor(NestedStructureHouseKeeper.EndOfStatementProcessor endOfStatementProcessor)- Specified by:
pushEndOfStatementProcessorin interfaceNestedStructureHouseKeeper
-
popEndOfStatementProcessor
- Specified by:
popEndOfStatementProcessorin interfaceNestedStructureHouseKeeper
-