3 * Copyright 2002-2004 The Ant-Contrib project
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package net
.sf
.antcontrib
.cpptasks
.borland
;
18 import java
.io
.IOException
;
19 import java
.io
.Reader
;
20 import java
.util
.Vector
;
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
;
27 * A parser that paths from a borland cfg file
31 public final class BorlandCfgParser
extends AbstractParser
{
32 private AbstractParserState newLineState
;
33 private final Vector path
= new Vector();
38 public BorlandCfgParser(char switchChar
) {
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
44 AbstractParserState quote
= new CfgFilenameState(this, new char[]{'"'});
46 // an unquoted path (-Ic:\borland\include)
47 // ends at the first space or new line
48 AbstractParserState unquote
= new CfgFilenameState(this, new char[]{
50 AbstractParserState quoteBranch
= new QuoteBranchState(this, quote
,
52 AbstractParserState toNextSwitch
= new ConsumeToSpaceOrNewLine(this);
53 AbstractParserState switchState
= new LetterState(this, switchChar
,
54 quoteBranch
, toNextSwitch
);
55 newLineState
= new WhitespaceOrLetterState(this, '-', switchState
);
57 public void addFilename(String include
) {
58 path
.addElement(include
);
60 public AbstractParserState
getNewLineState() {
63 public String
[] parsePath(Reader reader
) throws IOException
{
66 String
[] retval
= new String
[path
.size()];
67 path
.copyInto(retval
);