Skip to content

Package: TypeIdentifierState

TypeIdentifierState

nameinstructionbranchcomplexitylinemethod
TypeIdentifierState()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
parse(RouterSoftware, TempVariableType, Buffer, TypeFileParser)
M: 34 C: 33
49%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 4 C: 9
69%
M: 0 C: 1
100%

Coverage

1: package parser.states.typestates;
2:
3: import basic.Buffer;
4: import model.RouterSoftware;
5: import parser.ParserException;
6: import parser.TypeFileParser;
7: import parser.tempparserobjects.TempVariableType;
8: import symbols.AbstractSymbol;
9: import symbols.EqualSignSymbol;
10: import symbols.IdentifierSymbol;
11:
12: /**
13: *
14: * @author Muri
15: *
16: */
17: public class TypeIdentifierState extends AbstractTypeState {
18:
19:         /**
20:          *
21:          * @param tVT
22:          * tempVariableType
23:          * @param buffer
24:          * buffer
25:          * @param tFP
26:          * typeFileParser
27:          * @throws InterruptedException
28:          * InterruptedException
29:          * @throws ParserException
30:          * ParserException
31:          */
32:         @Override
33:         public void parse(final RouterSoftware rs, final TempVariableType tVT,
34:                         final Buffer<AbstractSymbol> buffer, final TypeFileParser tFP)
35:                         throws InterruptedException, ParserException {
36:                 final AbstractSymbol nextSymbol = buffer.peek();
37:•                if (nextSymbol instanceof IdentifierSymbol) {
38:                         tVT.setName(((IdentifierSymbol) nextSymbol).getText());
39:                         tVT.setPosition(nextSymbol.getPosition());
40:                         buffer.remove();
41:•                        if (buffer.peek() instanceof EqualSignSymbol) {
42:                                 tFP.setState(new TypeExpressionState());
43:                                 buffer.remove();
44:                         } else {
45:                                 throw new ParserException(
46:                                                 "no expected symbol: " + buffer.peek().getClass().getCanonicalName()
47:                                                                 + " expected EqualSignSymbol");
48:                         }
49:                 } else {
50:                         throw new ParserException(
51:                                         "no valid symbol: " + buffer.peek().getClass().getCanonicalName());
52:                 }
53:         }
54:
55: }