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