1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.github.maven_nar.cpptasks.parser;
21
22 import java.io.IOException;
23 import java.io.Reader;
24 import java.util.Vector;
25
26
27
28
29
30
31 public final class FortranParser extends AbstractParser implements Parser {
32
33
34
35 private final Vector<String> includes = new Vector<>();
36
37
38
39
40 private final AbstractParserState newLineState;
41
42
43
44
45
46 public FortranParser() {
47 final AbstractParserState filename = new FilenameState(this, new char[] {
48 '\'', '/'
49 });
50 final AbstractParserState apos = new WhitespaceOrLetterState(this, '\'', filename);
51 final AbstractParserState blank = new LetterState(this, ' ', apos, null);
52 final AbstractParserState e = new CaseInsensitiveLetterState(this, 'E', blank, null);
53 final AbstractParserState d = new CaseInsensitiveLetterState(this, 'D', e, null);
54 final AbstractParserState u = new CaseInsensitiveLetterState(this, 'U', d, null);
55 final AbstractParserState l = new CaseInsensitiveLetterState(this, 'L', u, null);
56 final AbstractParserState c = new CaseInsensitiveLetterState(this, 'C', l, null);
57 final AbstractParserState n = new CaseInsensitiveLetterState(this, 'N', c, null);
58 this.newLineState = new WhitespaceOrCaseInsensitiveLetterState(this, 'I', n);
59 }
60
61
62
63
64
65
66
67 @Override
68 public void addFilename(final String include) {
69 this.includes.addElement(include);
70 }
71
72
73
74
75
76
77 @Override
78 public String[] getIncludes() {
79 final String[] retval = new String[this.includes.size()];
80 this.includes.copyInto(retval);
81 return retval;
82 }
83
84
85
86
87
88
89 @Override
90 public AbstractParserState getNewLineState() {
91 return this.newLineState;
92 }
93
94
95
96
97
98
99
100
101
102 @Override
103 public void parse(final Reader reader) throws IOException {
104 this.includes.setSize(0);
105 super.parse(reader);
106 }
107 }