Skip to content

Package: AdditionalTypeExpressionState2

AdditionalTypeExpressionState2

nameinstructionbranchcomplexitylinemethod
AdditionalTypeExpressionState2(TempTypeExtension)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
parse(RouterSoftware, TempVariableType, Buffer, TypeFileParser)
M: 75 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 15 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.states.GlobalFunctions;
11: import parser.tempparserobjects.TempTypeExtension;
12: import parser.tempparserobjects.TempVariableType;
13: import symbols.AbstractSymbol;
14: import symbols.ColonSignSymbol;
15: import symbols.StringSymbol;
16:
17: /**
18: * @author Hendrik
19: *
20: */
21: public class AdditionalTypeExpressionState2 extends AbstractTypeState {
22:         /**
23:          * TempTypExtension.
24:          */
25:         private final TempTypeExtension tempExt;
26:
27:         /**
28:          * String für "no valid symbol: ".
29:          */
30:         private static final String NO_VALID_SYMBOL_STRING = "no valid symbol: ";
31:
32:         /**
33:          * constructor no Side effects.
34:          *
35:          * @param tempExt
36:          * TepExt.
37:          */
38:         public AdditionalTypeExpressionState2(final TempTypeExtension tempExt) {
39:                 super();
40:                 this.tempExt = tempExt;
41:         }
42:
43:         /*
44:          * (non-Javadoc)
45:          *
46:          * @see
47:          * parser.states.typestates.AbstractTypeState#parse(parser.tempparserobjects.TempVariableType,
48:          * basic.Buffer, parser.TypeFileParser)
49:          */
50:         @Override
51:         public void parse(final RouterSoftware rs, final TempVariableType tVT,
52:                         final Buffer<AbstractSymbol> buffer, final TypeFileParser tFP)
53:                         throws InterruptedException, ParserException {
54:                 AbstractSymbol nextSymbol = buffer.remove();
55:•                if (nextSymbol instanceof StringSymbol) {
56:                         String expression = ((StringSymbol) nextSymbol).getText();
57:                         expression = GlobalFunctions.posixCharacterReplacement(expression);
58:                         this.tempExt.setRegEx(GlobalFunctions.generateRegEx(expression));
59:                         nextSymbol = buffer.peek();
60:•                        if (nextSymbol instanceof ColonSignSymbol) {
61:                                 tFP.setState(new AdditionalErrorMsgState(this.tempExt));
62:                                 buffer.remove();
63:                         } else {
64:                                 throw new ParserException(
65:                                                 NO_VALID_SYMBOL_STRING + buffer.peek().getClass().getCanonicalName()
66:                                                                 + " expected ColonSignSymbol");
67:                         }
68:                 } else {
69:                         throw new ParserException(NO_VALID_SYMBOL_STRING
70:                                         + buffer.peek().getClass().getCanonicalName() + " expected StringSymbol");
71:                 }
72:
73:         }
74:
75: }