]> git.proxmox.com Git - mirror_edk2.git/blobdiff - 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
diff --git a/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandCfgParser.java b/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandCfgParser.java
new file mode 100644 (file)
index 0000000..19daedd
--- /dev/null
@@ -0,0 +1,70 @@
+/*\r
+ * \r
+ * Copyright 2002-2004 The Ant-Contrib project\r
+ *\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ */\r
+package net.sf.antcontrib.cpptasks.borland;\r
+import java.io.IOException;\r
+import java.io.Reader;\r
+import java.util.Vector;\r
+\r
+import net.sf.antcontrib.cpptasks.parser.AbstractParser;\r
+import net.sf.antcontrib.cpptasks.parser.AbstractParserState;\r
+import net.sf.antcontrib.cpptasks.parser.LetterState;\r
+import net.sf.antcontrib.cpptasks.parser.WhitespaceOrLetterState;\r
+/**\r
+ * A parser that paths from a borland cfg file\r
+ * \r
+ * @author Curt Arnold\r
+ */\r
+public final class BorlandCfgParser extends AbstractParser {\r
+    private AbstractParserState newLineState;\r
+    private final Vector path = new Vector();\r
+    /**\r
+     * \r
+     *  \r
+     */\r
+    public BorlandCfgParser(char switchChar) {\r
+        //\r
+        //   a quoted path (-I"some path")\r
+        //      doesn't end till a close quote and will be abandoned\r
+        //      if a new line is encountered first\r
+        //\r
+        AbstractParserState quote = new CfgFilenameState(this, new char[]{'"'});\r
+        //\r
+        //    an unquoted path (-Ic:\borland\include)\r
+        //      ends at the first space or new line\r
+        AbstractParserState unquote = new CfgFilenameState(this, new char[]{\r
+                ' ', '\n', '\r'});\r
+        AbstractParserState quoteBranch = new QuoteBranchState(this, quote,\r
+                unquote);\r
+        AbstractParserState toNextSwitch = new ConsumeToSpaceOrNewLine(this);\r
+        AbstractParserState switchState = new LetterState(this, switchChar,\r
+                quoteBranch, toNextSwitch);\r
+        newLineState = new WhitespaceOrLetterState(this, '-', switchState);\r
+    }\r
+    public void addFilename(String include) {\r
+        path.addElement(include);\r
+    }\r
+    public AbstractParserState getNewLineState() {\r
+        return newLineState;\r
+    }\r
+    public String[] parsePath(Reader reader) throws IOException {\r
+        path.setSize(0);\r
+        super.parse(reader);\r
+        String[] retval = new String[path.size()];\r
+        path.copyInto(retval);\r
+        return retval;\r
+    }\r
+}\r