+++ /dev/null
-/*\r
- *\r
- * Copyright 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
-\r
-/**\r
- * This parser state checks consumed characters against a specific character\r
- * (case insensitive).\r
- *\r
- * @author Curt Arnold\r
- */\r
-public final class CaseInsensitiveLetterState\r
- extends AbstractParserState {\r
- /**\r
- * Next state if a match is found.\r
- */\r
- private final AbstractParserState nextState;\r
-\r
- /**\r
- * Next state if not match is found.\r
- */\r
- private final AbstractParserState noMatchState;\r
-\r
- /**\r
- * Lower case version of character to match.\r
- */\r
- private final char lowerLetter;\r
-\r
- /**\r
- * Lower case version of character to match.\r
- */\r
- private final char upperLetter;\r
-\r
- /**\r
- * Constructor.\r
- *\r
- * @param parser\r
- * parser\r
- * @param matchLetter\r
- * letter to match\r
- * @param nextStateArg\r
- * next state if a match on the letter\r
- * @param noMatchStateArg\r
- * state if no match on letter\r
- */\r
- public CaseInsensitiveLetterState(final AbstractParser parser,\r
- final char matchLetter,\r
- final AbstractParserState nextStateArg,\r
- final AbstractParserState noMatchStateArg) {\r
- super(parser);\r
- this.lowerLetter = Character.toLowerCase(matchLetter);\r
- this.upperLetter = Character.toUpperCase(matchLetter);\r
- this.nextState = nextStateArg;\r
- this.noMatchState = noMatchStateArg;\r
- }\r
-\r
- /**\r
- * Consumes a character and returns the next state for the parser.\r
- *\r
- * @param ch\r
- * next character\r
- * @return the configured nextState if ch is the expected character or the\r
- * configure noMatchState otherwise.\r
- */\r
- public AbstractParserState consume(final char ch) {\r
- if (ch == lowerLetter || ch == upperLetter) {\r
- return nextState;\r
- }\r
- if (ch == '\n') {\r
- getParser().getNewLineState();\r
- }\r
- return noMatchState;\r
- }\r
-}\r