]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandCfgParser.java
Restructuring for better separation of Tool packages.
[mirror_edk2.git] / Tools / Java / Source / Cpptasks / net / sf / antcontrib / cpptasks / borland / BorlandCfgParser.java
1 /*
2 *
3 * Copyright 2002-2004 The Ant-Contrib project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package net.sf.antcontrib.cpptasks.borland;
18 import java.io.IOException;
19 import java.io.Reader;
20 import java.util.Vector;
21
22 import net.sf.antcontrib.cpptasks.parser.AbstractParser;
23 import net.sf.antcontrib.cpptasks.parser.AbstractParserState;
24 import net.sf.antcontrib.cpptasks.parser.LetterState;
25 import net.sf.antcontrib.cpptasks.parser.WhitespaceOrLetterState;
26 /**
27 * A parser that paths from a borland cfg file
28 *
29 * @author Curt Arnold
30 */
31 public final class BorlandCfgParser extends AbstractParser {
32 private AbstractParserState newLineState;
33 private final Vector path = new Vector();
34 /**
35 *
36 *
37 */
38 public BorlandCfgParser(char switchChar) {
39 //
40 // a quoted path (-I"some path")
41 // doesn't end till a close quote and will be abandoned
42 // if a new line is encountered first
43 //
44 AbstractParserState quote = new CfgFilenameState(this, new char[]{'"'});
45 //
46 // an unquoted path (-Ic:\borland\include)
47 // ends at the first space or new line
48 AbstractParserState unquote = new CfgFilenameState(this, new char[]{
49 ' ', '\n', '\r'});
50 AbstractParserState quoteBranch = new QuoteBranchState(this, quote,
51 unquote);
52 AbstractParserState toNextSwitch = new ConsumeToSpaceOrNewLine(this);
53 AbstractParserState switchState = new LetterState(this, switchChar,
54 quoteBranch, toNextSwitch);
55 newLineState = new WhitespaceOrLetterState(this, '-', switchState);
56 }
57 public void addFilename(String include) {
58 path.addElement(include);
59 }
60 public AbstractParserState getNewLineState() {
61 return newLineState;
62 }
63 public String[] parsePath(Reader reader) throws IOException {
64 path.setSize(0);
65 super.parse(reader);
66 String[] retval = new String[path.size()];
67 path.copyInto(retval);
68 return retval;
69 }
70 }