+++ /dev/null
-/*\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.parser;\r
-public class BranchState extends AbstractParserState {\r
- private char[] branchChars;\r
- private AbstractParserState[] branchStates;\r
- private AbstractParserState noMatchState;\r
- public BranchState(AbstractParser parser, char[] branchChars,\r
- AbstractParserState[] branchStates, AbstractParserState noMatchState) {\r
- super(parser);\r
- this.branchChars = (char[]) branchChars.clone();\r
- this.branchStates = (AbstractParserState[]) branchStates.clone();\r
- this.noMatchState = noMatchState;\r
- }\r
- public AbstractParserState consume(char ch) {\r
- AbstractParserState state;\r
- for (int i = 0; i < branchChars.length; i++) {\r
- if (ch == branchChars[i]) {\r
- state = branchStates[i];\r
- return state.consume(ch);\r
- }\r
- }\r
- state = getNoMatchState();\r
- if (state != null) {\r
- return state.consume(ch);\r
- }\r
- return state;\r
- }\r
- protected AbstractParserState getNoMatchState() {\r
- return noMatchState;\r
- }\r
-}\r