Skip to content

Package: AdditionalIdentifierState

AdditionalIdentifierState

nameinstructionbranchcomplexitylinemethod
AdditionalIdentifierState()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
parse(RouterSoftware, TempVariableType, Buffer, TypeFileParser)
M: 82 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 18 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /**
2: *
3: */
4: package parser.states.typestates;
5:
6: import basic.Buffer;
7: import model.RouterSoftware;
8: import parser.ParserException;
9: import parser.TypeFileParser;
10: import parser.tempparserobjects.TempTypeExtension;
11: import parser.tempparserobjects.TempTypeExtensionWithCondition;
12: import parser.tempparserobjects.TempTypeExtensionWithoutCondition;
13: import parser.tempparserobjects.TempVariableType;
14: import symbols.AbstractSymbol;
15: import symbols.BracketOpenSymbol;
16: import symbols.EqualSignSymbol;
17: import symbols.IdentifierSymbol;
18:
19: /**
20: * @author Hendrik
21: *
22: */
23: public class AdditionalIdentifierState extends AbstractTypeState {
24:
25:         /**
26:          *
27:          */
28:         protected AdditionalIdentifierState() {
29:                 super();
30:         }
31:
32:         /*
33:          * (non-Javadoc)
34:          *
35:          * @see
36:          * parser.states.typestates.AbstractTypeState#parse(parser.tempparserobjects.TempVariableType,
37:          * basic.Buffer, parser.TypeFileParser)
38:          */
39:         @Override
40:         public void parse(final RouterSoftware rs, final TempVariableType tVT,
41:                         final Buffer<AbstractSymbol> buffer, final TypeFileParser tFP)
42:                         throws InterruptedException, ParserException {
43:                 AbstractSymbol nextSymbol = buffer.peek();
44:                 final IdentifierSymbol identifierSymbol = (IdentifierSymbol) nextSymbol;
45:                 final TempTypeExtension tempExt;
46:                 buffer.remove();
47:
48:                 nextSymbol = buffer.peek();
49:•                if (nextSymbol instanceof BracketOpenSymbol) {
50:                         tempExt = new TempTypeExtensionWithCondition();
51:                         tempExt.setName(identifierSymbol.getText());
52:                         tempExt.setPosition(nextSymbol.getPosition());
53:                         tFP.setState(new TypeVariableState(nextSymbol, (TempTypeExtensionWithCondition) tempExt));
54:                         buffer.remove();
55:•                } else if (nextSymbol instanceof EqualSignSymbol) {
56:                         tempExt = new TempTypeExtensionWithoutCondition();
57:                         tempExt.setName(identifierSymbol.getText());
58:                         tempExt.setPosition(nextSymbol.getPosition());
59:                         tFP.setState(new AdditionalTypeExpressionState(tempExt));
60:                 } else {
61:                         throw new ParserException(
62:                                         "no valid symbol: " + buffer.peek().getClass().getCanonicalName()
63:                                                         + " expected AdditionalIdentifierSymbol");
64:                 }
65:
66:         }
67: }