Skip to content

Package: DefinitionInitialState

DefinitionInitialState

nameinstructionbranchcomplexitylinemethod
DefinitionInitialState()
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, TempVariableDefinition, Buffer, DefinitionFileParser)
M: 43 C: 23
35%
M: 5 C: 3
38%
M: 3 C: 2
40%
M: 9 C: 6
40%
M: 0 C: 1
100%

Coverage

1: package parser.states.definitionstates;
2:
3: import model.RouterSoftware;
4: import parser.DefinitionFileParser;
5: import parser.ParserException;
6: import parser.tempparserobjects.TempVariableDefinition;
7: import symbols.AbstractSymbol;
8: import symbols.CommentSymbol;
9: import symbols.IdentifierSymbol;
10: import symbols.PlusSymbol;
11: import basic.Buffer;
12:
13: /**
14: *
15: * @author Muri
16: *
17: */
18: public class DefinitionInitialState extends AbstractDefinitionState {
19:         /**
20:          *
21:          * @param tVD
22:          * TempVariableDefinition
23:          * @param dFP
24:          * DefinitionFileParser
25:          * @param buffer
26:          * Buffer<Symbol>
27:          * @return
28:          * @throws InterruptedException
29:          * InterruptedException
30:          * @throws ParserException
31:          * ParserException
32:          */
33:         @Override
34:         public void parse(final RouterSoftware rs, final TempVariableDefinition tVD,
35:                         final Buffer<AbstractSymbol> buffer, final DefinitionFileParser dFP)
36:                         throws InterruptedException, ParserException {
37:                 final AbstractSymbol nextSymbol = buffer.peek();
38:•                if (nextSymbol instanceof CommentSymbol) {
39:                         dFP.setState(new DefinitionCommentState());
40:•                } else if (nextSymbol instanceof IdentifierSymbol) {
41:                         dFP.setState(new DefinitionIdentifierState());
42:•                } else if (nextSymbol instanceof PlusSymbol) {
43:                         tVD.setOptional(true);
44:                         buffer.remove();
45:•                        if (buffer.peek() instanceof PlusSymbol) {
46:                                 tVD.setReallyOptional(true);
47:                                 buffer.remove(); // simply removes the second PlusSymbol if existent.
48:                         }
49:                         dFP.setState(new DefinitionIdentifierState());
50:                 } else {
51:                         throw new ParserException("no valid symbol: "
52:                                         + buffer.peek().getClass().getCanonicalName());
53:                 }
54:         }
55:
56: }