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