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