+++ /dev/null
-/*\r
- * \r
- * Copyright 2001-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.parser;\r
-import java.io.IOException;\r
-import java.io.Reader;\r
-/**\r
- * An abstract base class for simple parsers\r
- * \r
- * @author Curt Arnold\r
- */\r
-public abstract class AbstractParser {\r
- /**\r
- * \r
- * \r
- */\r
- protected AbstractParser() {\r
- }\r
- protected abstract void addFilename(String filename);\r
- public abstract AbstractParserState getNewLineState();\r
- protected void parse(Reader reader) throws IOException {\r
- char[] buf = new char[4096];\r
- AbstractParserState newLineState = getNewLineState();\r
- AbstractParserState state = newLineState;\r
- int charsRead = -1;\r
- do {\r
- charsRead = reader.read(buf, 0, buf.length);\r
- if (state == null) {\r
- for (int i = 0; i < charsRead; i++) {\r
- if (buf[i] == '\n') {\r
- state = newLineState;\r
- break;\r
- }\r
- }\r
- }\r
- if (state != null) {\r
- for (int i = 0; i < charsRead; i++) {\r
- state = state.consume(buf[i]);\r
- //\r
- // didn't match a production, skip to a new line\r
- //\r
- if (state == null) {\r
- for (; i < charsRead; i++) {\r
- if (buf[i] == '\n') {\r
- state = newLineState;\r
- break;\r
- }\r
- }\r
- }\r
- }\r
- }\r
- } while (charsRead >= 0);\r
- }\r
-}\r