Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 10396 invoked from network); 22 Nov 2005 20:42:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Nov 2005 20:42:20 -0000 Received: (qmail 57608 invoked by uid 500); 22 Nov 2005 20:42:03 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 57197 invoked by uid 500); 22 Nov 2005 20:42:00 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 57164 invoked by uid 500); 22 Nov 2005 20:42:00 -0000 Received: (qmail 57156 invoked by uid 99); 22 Nov 2005 20:42:00 -0000 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 22 Nov 2005 12:41:57 -0800 Received: (qmail 9865 invoked by uid 65534); 22 Nov 2005 20:41:36 -0000 Message-ID: <20051122204136.9862.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r348244 [2/3] - in /jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration: ./ plist/ Date: Tue, 22 Nov 2005 20:41:33 -0000 To: commons-cvs@jakarta.apache.org From: oheger@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.jj URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.jj?rev=348244&r1=348243&r2=348244&view=diff ============================================================================== --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.jj (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.jj Tue Nov 22 12:40:57 2005 @@ -1,255 +1,255 @@ -/* - * Copyright 2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License") - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -options { - STATIC = false; -} - - -PARSER_BEGIN(PropertyListParser) - -package org.apache.commons.configuration.plist; - -import java.util.List; -import java.util.ArrayList; - -import org.apache.commons.configuration.HierarchicalConfiguration; -import org.apache.commons.configuration.HierarchicalConfiguration.Node; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.codec.binary.Hex; - -/** - * JavaCC based parser for the PropertyList format. - * - * @author Emmanuel Bourg - * @version $Revision$, $Date$ - */ -class PropertyListParser { - - /** - * Remove the quotes at the beginning and at the end of the specified String. - */ - protected String removeQuotes(String s) - { - if (s == null) - { - return null; - } - - if (s.startsWith("\"") && s.endsWith("\"") && s.length() >= 2) - { - s = s.substring(1, s.length() - 1); - } - - return s; - } - - protected String unescapeQuotes(String s) - { - return StringUtils.replace(s, "\\\"", "\""); - } - - /** - * Remove the white spaces and the data delimiters from the specified - * string and parse it as a byte array. - */ - protected byte[] filterData(String s) throws ParseException - { - if (s == null) - { - return null; - } - - // remove the delimiters - if (s.startsWith("<") && s.endsWith(">") && s.length() >= 2) - { - s = s.substring(1, s.length() - 1); - } - - // remove the white spaces - s = StringUtils.replaceChars(s, " \t\n\r", ""); - - // add a leading 0 to ensure well formed bytes - if (s.length() % 2 != 0) - { - s = "0" + s; - } - - // parse and return the bytes - try - { - return Hex.decodeHex(s.toCharArray()); - } - catch (Exception e) - { - throw new ParseException(e.getMessage()); - } - } - -} - -PARSER_END(PropertyListParser) - -SKIP : { " " | "\t" | "\n" | "\r" } - -TOKEN : { } -TOKEN : { } -TOKEN : { } - -TOKEN : { } -TOKEN : { } -TOKEN : { } -TOKEN : { } -TOKEN : { " > } - -TOKEN : { < QUOTE : "\"" > } -TOKEN : { < #LETTER : ~[" ", "\t", "\n", "\r", "(", ")", ",", "{", "}", ";", "=", "\""] > } -TOKEN : { < #WHITE : " " | "\t" | "\n" | "\r" > } -TOKEN : { < #HEXA : ["0"-"9", "a"-"f", "A"-"F"] > } -TOKEN : { < DATA : ( | )* > } -TOKEN : { < STRING : ()+ > } -TOKEN : { < QUOTED_STRING : - - ( | | | - | | | - | | | )* > } -TOKEN : { < ESCAPED_QUOTE : "\\\"" > } - -PropertyListConfiguration parse() : -{ - PropertyListConfiguration configuration = null; -} -{ - configuration = Dictionary() - - { return configuration; } -} - -PropertyListConfiguration Dictionary() : -{ - PropertyListConfiguration configuration = new PropertyListConfiguration(); - List children = new ArrayList(); - Node child = null; -} -{ - - ( - child = Property() - { - if (child.getValue() instanceof HierarchicalConfiguration) - { - // prune & graft the nested configuration to the parent configuration - HierarchicalConfiguration conf = (HierarchicalConfiguration) child.getValue(); - Node root = conf.getRoot(); - root.setName(child.getName()); - children.add(root); - } - else - { - children.add(child); - } - } - )* - - { - for (int i = 0; i < children.size(); i++) - { - child = (Node) children.get(i); - configuration.getRoot().addChild(child); - } - - return configuration; - } -} - -Node Property() : -{ - String key = null; - Object value = null; - Node node = new Node(); -} -{ - key = String() - { node.setName(key); } - - value = Element() - { node.setValue(value); } - ()? - { return node; } -} - -Object Element() : -{ - Object value = null; -} -{ - value = Array() - { return value; } - | - value = Dictionary() - { return value; } - | - value = String() - { return value; } - | - value = Data() - { return value; } -} - -List Array() : -{ - List list = new ArrayList(); - Object element = null; -} -{ - - ( - element = Element() - { list.add(element); } - ( - - element = Element() - { list.add(element); } - )* - )? - - { return list; } -} - -String String() : -{ - Token token = null; - String value = null; -} -{ - token = - { return unescapeQuotes(removeQuotes(token.image)); } - | - token = - { return token.image; } -} - -byte[] Data() : -{ - Token token; -} -{ - token = - { return filterData(token.image); } -} +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +options { + STATIC = false; +} + + +PARSER_BEGIN(PropertyListParser) + +package org.apache.commons.configuration.plist; + +import java.util.List; +import java.util.ArrayList; + +import org.apache.commons.configuration.HierarchicalConfiguration; +import org.apache.commons.configuration.HierarchicalConfiguration.Node; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.codec.binary.Hex; + +/** + * JavaCC based parser for the PropertyList format. + * + * @author Emmanuel Bourg + * @version $Revision$, $Date$ + */ +class PropertyListParser { + + /** + * Remove the quotes at the beginning and at the end of the specified String. + */ + protected String removeQuotes(String s) + { + if (s == null) + { + return null; + } + + if (s.startsWith("\"") && s.endsWith("\"") && s.length() >= 2) + { + s = s.substring(1, s.length() - 1); + } + + return s; + } + + protected String unescapeQuotes(String s) + { + return StringUtils.replace(s, "\\\"", "\""); + } + + /** + * Remove the white spaces and the data delimiters from the specified + * string and parse it as a byte array. + */ + protected byte[] filterData(String s) throws ParseException + { + if (s == null) + { + return null; + } + + // remove the delimiters + if (s.startsWith("<") && s.endsWith(">") && s.length() >= 2) + { + s = s.substring(1, s.length() - 1); + } + + // remove the white spaces + s = StringUtils.replaceChars(s, " \t\n\r", ""); + + // add a leading 0 to ensure well formed bytes + if (s.length() % 2 != 0) + { + s = "0" + s; + } + + // parse and return the bytes + try + { + return Hex.decodeHex(s.toCharArray()); + } + catch (Exception e) + { + throw new ParseException(e.getMessage()); + } + } + +} + +PARSER_END(PropertyListParser) + +SKIP : { " " | "\t" | "\n" | "\r" } + +TOKEN : { } +TOKEN : { } +TOKEN : { } + +TOKEN : { } +TOKEN : { } +TOKEN : { } +TOKEN : { } +TOKEN : { " > } + +TOKEN : { < QUOTE : "\"" > } +TOKEN : { < #LETTER : ~[" ", "\t", "\n", "\r", "(", ")", ",", "{", "}", ";", "=", "\""] > } +TOKEN : { < #WHITE : " " | "\t" | "\n" | "\r" > } +TOKEN : { < #HEXA : ["0"-"9", "a"-"f", "A"-"F"] > } +TOKEN : { < DATA : ( | )* > } +TOKEN : { < STRING : ()+ > } +TOKEN : { < QUOTED_STRING : + + ( | | | + | | | + | | | )* > } +TOKEN : { < ESCAPED_QUOTE : "\\\"" > } + +PropertyListConfiguration parse() : +{ + PropertyListConfiguration configuration = null; +} +{ + configuration = Dictionary() + + { return configuration; } +} + +PropertyListConfiguration Dictionary() : +{ + PropertyListConfiguration configuration = new PropertyListConfiguration(); + List children = new ArrayList(); + Node child = null; +} +{ + + ( + child = Property() + { + if (child.getValue() instanceof HierarchicalConfiguration) + { + // prune & graft the nested configuration to the parent configuration + HierarchicalConfiguration conf = (HierarchicalConfiguration) child.getValue(); + Node root = conf.getRoot(); + root.setName(child.getName()); + children.add(root); + } + else + { + children.add(child); + } + } + )* + + { + for (int i = 0; i < children.size(); i++) + { + child = (Node) children.get(i); + configuration.getRoot().addChild(child); + } + + return configuration; + } +} + +Node Property() : +{ + String key = null; + Object value = null; + Node node = new Node(); +} +{ + key = String() + { node.setName(key); } + + value = Element() + { node.setValue(value); } + ()? + { return node; } +} + +Object Element() : +{ + Object value = null; +} +{ + value = Array() + { return value; } + | + value = Dictionary() + { return value; } + | + value = String() + { return value; } + | + value = Data() + { return value; } +} + +List Array() : +{ + List list = new ArrayList(); + Object element = null; +} +{ + + ( + element = Element() + { list.add(element); } + ( + + element = Element() + { list.add(element); } + )* + )? + + { return list; } +} + +String String() : +{ + Token token = null; + String value = null; +} +{ + token = + { return unescapeQuotes(removeQuotes(token.image)); } + | + token = + { return token.image; } +} + +byte[] Data() : +{ + Token token; +} +{ + token = + { return filterData(token.image); } +} Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.jj ------------------------------------------------------------------------------ svn:eol-style = native Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserConstants.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserConstants.java?rev=348244&r1=348243&r2=348244&view=diff ============================================================================== --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserConstants.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserConstants.java Tue Nov 22 12:40:57 2005 @@ -1,52 +1,52 @@ -/* Generated By:JavaCC: Do not edit this line. PropertyListParserConstants.java */ -package org.apache.commons.configuration.plist; - -interface PropertyListParserConstants -{ - int EOF = 0; - int ARRAY_BEGIN = 5; - int ARRAY_END = 6; - int ARRAY_SEPARATOR = 7; - int DICT_BEGIN = 8; - int DICT_END = 9; - int DICT_SEPARATOR = 10; - int EQUAL = 11; - int DATA_START = 12; - int DATA_END = 13; - int QUOTE = 14; - int LETTER = 15; - int WHITE = 16; - int HEXA = 17; - int DATA = 18; - int STRING = 19; - int QUOTED_STRING = 20; - int ESCAPED_QUOTE = 21; - - int DEFAULT = 0; - - String[] tokenImage = { - "", - "\" \"", - "\"\\t\"", - "\"\\n\"", - "\"\\r\"", - "\"(\"", - "\")\"", - "\",\"", - "\"{\"", - "\"}\"", - "\";\"", - "\"=\"", - "\"<\"", - "\">\"", - "\"\\\"\"", - "", - "", - "", - "", - "", - "", - "\"\\\\\\\"\"", - }; - -} +/* Generated By:JavaCC: Do not edit this line. PropertyListParserConstants.java */ +package org.apache.commons.configuration.plist; + +interface PropertyListParserConstants +{ + int EOF = 0; + int ARRAY_BEGIN = 5; + int ARRAY_END = 6; + int ARRAY_SEPARATOR = 7; + int DICT_BEGIN = 8; + int DICT_END = 9; + int DICT_SEPARATOR = 10; + int EQUAL = 11; + int DATA_START = 12; + int DATA_END = 13; + int QUOTE = 14; + int LETTER = 15; + int WHITE = 16; + int HEXA = 17; + int DATA = 18; + int STRING = 19; + int QUOTED_STRING = 20; + int ESCAPED_QUOTE = 21; + + int DEFAULT = 0; + + String[] tokenImage = { + "", + "\" \"", + "\"\\t\"", + "\"\\n\"", + "\"\\r\"", + "\"(\"", + "\")\"", + "\",\"", + "\"{\"", + "\"}\"", + "\";\"", + "\"=\"", + "\"<\"", + "\">\"", + "\"\\\"\"", + "", + "", + "", + "", + "", + "", + "\"\\\\\\\"\"", + }; + +} Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserConstants.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserConstants.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserTokenManager.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserTokenManager.java?rev=348244&r1=348243&r2=348244&view=diff ============================================================================== --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserTokenManager.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserTokenManager.java Tue Nov 22 12:40:57 2005 @@ -1,470 +1,470 @@ -/* Generated By:JavaCC: Do not edit this line. PropertyListParserTokenManager.java */ -package org.apache.commons.configuration.plist; - -import java.io.IOException; -import java.io.PrintStream; - -class PropertyListParserTokenManager implements PropertyListParserConstants -{ - public PrintStream debugStream = System.out; - - private final int jjStopStringLiteralDfa_0(int pos, long active0) - { - switch (pos) - { - case 0: - if ((active0 & 0x4000L) != 0L) - return 9; - if ((active0 & 0x1000L) != 0L) - return 10; - if ((active0 & 0x2000L) != 0L) - return 3; - if ((active0 & 0x200000L) != 0L) - { - jjmatchedKind = 19; - return 3; - } - return -1; - default : - return -1; - } - } - - private final int jjStartNfa_0(int pos, long active0) - { - return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); - } - - private final int jjStopAtPos(int pos, int kind) - { - jjmatchedKind = kind; - jjmatchedPos = pos; - return pos + 1; - } - - private final int jjStartNfaWithStates_0(int pos, int kind, int state) - { - jjmatchedKind = kind; - jjmatchedPos = pos; - try - { - curChar = input_stream.readChar(); - } - catch (IOException e) - { - return pos + 1; - } - return jjMoveNfa_0(state, pos + 1); - } - - private final int jjMoveStringLiteralDfa0_0() - { - switch (curChar) - { - case 34: - return jjStartNfaWithStates_0(0, 14, 9); - case 40: - return jjStopAtPos(0, 5); - case 41: - return jjStopAtPos(0, 6); - case 44: - return jjStopAtPos(0, 7); - case 59: - return jjStopAtPos(0, 10); - case 60: - return jjStartNfaWithStates_0(0, 12, 10); - case 61: - return jjStopAtPos(0, 11); - case 62: - return jjStartNfaWithStates_0(0, 13, 3); - case 92: - return jjMoveStringLiteralDfa1_0(0x200000L); - case 123: - return jjStopAtPos(0, 8); - case 125: - return jjStopAtPos(0, 9); - default : - return jjMoveNfa_0(0, 0); - } - } - - private final int jjMoveStringLiteralDfa1_0(long active0) - { - try - { - curChar = input_stream.readChar(); - } - catch (IOException e) - { - jjStopStringLiteralDfa_0(0, active0); - return 1; - } - switch (curChar) - { - case 34: - if ((active0 & 0x200000L) != 0L) - return jjStopAtPos(1, 21); - break; - default : - break; - } - return jjStartNfa_0(0, active0); - } - - private final void jjCheckNAdd(int state) - { - if (jjrounds[state] != jjround) - { - jjstateSet[jjnewStateCnt++] = state; - jjrounds[state] = jjround; - } - } - - private final void jjCheckNAddTwoStates(int state1, int state2) - { - jjCheckNAdd(state1); - jjCheckNAdd(state2); - } - - private final void jjCheckNAddStates(int start, int end) - { - do - { - jjCheckNAdd(jjnextStates[start]); - } - while (start++ != end); - } - - static final long[] jjbitVec0 = { - 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL - }; - - private final int jjMoveNfa_0(int startState, int curPos) - { - int startsAt = 0; - jjnewStateCnt = 9; - int i = 1; - jjstateSet[0] = startState; - int kind = 0x7fffffff; - for (; ;) - { - if (++jjround == 0x7fffffff) - ReInitRounds(); - if (curChar < 64) - { - long l = 1L << curChar; - MatchLoop: do - { - switch (jjstateSet[--i]) - { - case 9: - if ((0xfffffffbffffffffL & l) != 0L) - jjCheckNAddStates(0, 2); - else if (curChar == 34) - { - if (kind > 20) - kind = 20; - } - break; - case 10: - if ((0xd7ffecfaffffd9ffL & l) != 0L) - { - if (kind > 19) - kind = 19; - jjCheckNAdd(3); - } - if ((0x3ff000100002600L & l) != 0L) - jjCheckNAddTwoStates(1, 2); - else if (curChar == 62) - { - if (kind > 18) - kind = 18; - } - break; - case 0: - if ((0xd7ffecfaffffd9ffL & l) != 0L) - { - if (kind > 19) - kind = 19; - jjCheckNAdd(3); - } - else if (curChar == 34) - jjCheckNAddStates(0, 2); - if (curChar == 60) - jjCheckNAddTwoStates(1, 2); - break; - case 1: - if ((0x3ff000100002600L & l) != 0L) - jjCheckNAddTwoStates(1, 2); - break; - case 2: - if (curChar == 62 && kind > 18) - kind = 18; - break; - case 3: - if ((0xd7ffecfaffffd9ffL & l) == 0L) - break; - if (kind > 19) - kind = 19; - jjCheckNAdd(3); - break; - case 4: - case 6: - if (curChar == 34) - jjCheckNAddStates(0, 2); - break; - case 5: - if ((0xfffffffbffffffffL & l) != 0L) - jjCheckNAddStates(0, 2); - break; - case 8: - if (curChar == 34 && kind > 20) - kind = 20; - break; - default : - break; - } - } - while (i != startsAt); - } - else if (curChar < 128) - { - long l = 1L << (curChar & 077); - MatchLoop: do - { - switch (jjstateSet[--i]) - { - case 9: - jjCheckNAddStates(0, 2); - if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 6; - break; - case 10: - if ((0xd7ffffffffffffffL & l) != 0L) - { - if (kind > 19) - kind = 19; - jjCheckNAdd(3); - } - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddTwoStates(1, 2); - break; - case 0: - case 3: - if ((0xd7ffffffffffffffL & l) == 0L) - break; - if (kind > 19) - kind = 19; - jjCheckNAdd(3); - break; - case 1: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddTwoStates(1, 2); - break; - case 5: - jjCheckNAddStates(0, 2); - break; - case 7: - if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 6; - break; - default : - break; - } - } - while (i != startsAt); - } - else - { - int i2 = (curChar & 0xff) >> 6; - long l2 = 1L << (curChar & 077); - MatchLoop: do - { - switch (jjstateSet[--i]) - { - case 9: - case 5: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddStates(0, 2); - break; - case 10: - case 3: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 19) - kind = 19; - jjCheckNAdd(3); - break; - case 0: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 19) - kind = 19; - jjCheckNAdd(3); - break; - default : - break; - } - } - while (i != startsAt); - } - if (kind != 0x7fffffff) - { - jjmatchedKind = kind; - jjmatchedPos = curPos; - kind = 0x7fffffff; - } - ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 9 - (jjnewStateCnt = startsAt))) - return curPos; - try - { - curChar = input_stream.readChar(); - } - catch (IOException e) - { - return curPos; - } - } - } - - static final int[] jjnextStates = { - 5, 7, 8, - }; - public static final String[] jjstrLiteralImages = { - "", null, null, null, null, "\50", "\51", "\54", "\173", "\175", "\73", "\75", - "\74", "\76", "\42", null, null, null, null, null, null, "\134\42", }; - public static final String[] lexStateNames = { - "DEFAULT", - }; - static final long[] jjtoToken = { - 0x3c7fe1L, - }; - static final long[] jjtoSkip = { - 0x1eL, - }; - protected SimpleCharStream input_stream; - private final int[] jjrounds = new int[9]; - private final int[] jjstateSet = new int[18]; - protected char curChar; - - public PropertyListParserTokenManager(SimpleCharStream stream) - { - if (SimpleCharStream.staticFlag) - throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); - input_stream = stream; - } - - public void ReInit(SimpleCharStream stream) - { - jjmatchedPos = jjnewStateCnt = 0; - curLexState = defaultLexState; - input_stream = stream; - ReInitRounds(); - } - - private final void ReInitRounds() - { - int i; - jjround = 0x80000001; - for (i = 9; i-- > 0;) - jjrounds[i] = 0x80000000; - } - - protected Token jjFillToken() - { - Token t = Token.newToken(jjmatchedKind); - t.kind = jjmatchedKind; - String im = jjstrLiteralImages[jjmatchedKind]; - t.image = (im == null) ? input_stream.GetImage() : im; - t.beginLine = input_stream.getBeginLine(); - t.beginColumn = input_stream.getBeginColumn(); - t.endLine = input_stream.getEndLine(); - t.endColumn = input_stream.getEndColumn(); - return t; - } - - int curLexState = 0; - int defaultLexState = 0; - int jjnewStateCnt; - int jjround; - int jjmatchedPos; - int jjmatchedKind; - - public Token getNextToken() - { - Token matchedToken; - int curPos = 0; - - EOFLoop : - for (; ;) - { - try - { - curChar = input_stream.BeginToken(); - } - catch (IOException e) - { - jjmatchedKind = 0; - matchedToken = jjFillToken(); - return matchedToken; - } - - try - { - input_stream.backup(0); - while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L) - curChar = input_stream.BeginToken(); - } - catch (IOException e1) - { - continue EOFLoop; - } - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_0(); - if (jjmatchedKind != 0x7fffffff) - { - if (jjmatchedPos + 1 < curPos) - input_stream.backup(curPos - jjmatchedPos - 1); - if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) - { - matchedToken = jjFillToken(); - return matchedToken; - } - else - { - continue EOFLoop; - } - } - int error_line = input_stream.getEndLine(); - int error_column = input_stream.getEndColumn(); - String error_after = null; - boolean EOFSeen = false; - try - { - input_stream.readChar(); - input_stream.backup(1); - } - catch (IOException e1) - { - EOFSeen = true; - error_after = curPos <= 1 ? "" : input_stream.GetImage(); - if (curChar == '\n' || curChar == '\r') - { - error_line++; - error_column = 0; - } - else - error_column++; - } - if (!EOFSeen) - { - input_stream.backup(1); - error_after = curPos <= 1 ? "" : input_stream.GetImage(); - } - throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); - } - } - -} +/* Generated By:JavaCC: Do not edit this line. PropertyListParserTokenManager.java */ +package org.apache.commons.configuration.plist; + +import java.io.IOException; +import java.io.PrintStream; + +class PropertyListParserTokenManager implements PropertyListParserConstants +{ + public PrintStream debugStream = System.out; + + private final int jjStopStringLiteralDfa_0(int pos, long active0) + { + switch (pos) + { + case 0: + if ((active0 & 0x4000L) != 0L) + return 9; + if ((active0 & 0x1000L) != 0L) + return 10; + if ((active0 & 0x2000L) != 0L) + return 3; + if ((active0 & 0x200000L) != 0L) + { + jjmatchedKind = 19; + return 3; + } + return -1; + default : + return -1; + } + } + + private final int jjStartNfa_0(int pos, long active0) + { + return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); + } + + private final int jjStopAtPos(int pos, int kind) + { + jjmatchedKind = kind; + jjmatchedPos = pos; + return pos + 1; + } + + private final int jjStartNfaWithStates_0(int pos, int kind, int state) + { + jjmatchedKind = kind; + jjmatchedPos = pos; + try + { + curChar = input_stream.readChar(); + } + catch (IOException e) + { + return pos + 1; + } + return jjMoveNfa_0(state, pos + 1); + } + + private final int jjMoveStringLiteralDfa0_0() + { + switch (curChar) + { + case 34: + return jjStartNfaWithStates_0(0, 14, 9); + case 40: + return jjStopAtPos(0, 5); + case 41: + return jjStopAtPos(0, 6); + case 44: + return jjStopAtPos(0, 7); + case 59: + return jjStopAtPos(0, 10); + case 60: + return jjStartNfaWithStates_0(0, 12, 10); + case 61: + return jjStopAtPos(0, 11); + case 62: + return jjStartNfaWithStates_0(0, 13, 3); + case 92: + return jjMoveStringLiteralDfa1_0(0x200000L); + case 123: + return jjStopAtPos(0, 8); + case 125: + return jjStopAtPos(0, 9); + default : + return jjMoveNfa_0(0, 0); + } + } + + private final int jjMoveStringLiteralDfa1_0(long active0) + { + try + { + curChar = input_stream.readChar(); + } + catch (IOException e) + { + jjStopStringLiteralDfa_0(0, active0); + return 1; + } + switch (curChar) + { + case 34: + if ((active0 & 0x200000L) != 0L) + return jjStopAtPos(1, 21); + break; + default : + break; + } + return jjStartNfa_0(0, active0); + } + + private final void jjCheckNAdd(int state) + { + if (jjrounds[state] != jjround) + { + jjstateSet[jjnewStateCnt++] = state; + jjrounds[state] = jjround; + } + } + + private final void jjCheckNAddTwoStates(int state1, int state2) + { + jjCheckNAdd(state1); + jjCheckNAdd(state2); + } + + private final void jjCheckNAddStates(int start, int end) + { + do + { + jjCheckNAdd(jjnextStates[start]); + } + while (start++ != end); + } + + static final long[] jjbitVec0 = { + 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL + }; + + private final int jjMoveNfa_0(int startState, int curPos) + { + int startsAt = 0; + jjnewStateCnt = 9; + int i = 1; + jjstateSet[0] = startState; + int kind = 0x7fffffff; + for (; ;) + { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) + { + long l = 1L << curChar; + MatchLoop: do + { + switch (jjstateSet[--i]) + { + case 9: + if ((0xfffffffbffffffffL & l) != 0L) + jjCheckNAddStates(0, 2); + else if (curChar == 34) + { + if (kind > 20) + kind = 20; + } + break; + case 10: + if ((0xd7ffecfaffffd9ffL & l) != 0L) + { + if (kind > 19) + kind = 19; + jjCheckNAdd(3); + } + if ((0x3ff000100002600L & l) != 0L) + jjCheckNAddTwoStates(1, 2); + else if (curChar == 62) + { + if (kind > 18) + kind = 18; + } + break; + case 0: + if ((0xd7ffecfaffffd9ffL & l) != 0L) + { + if (kind > 19) + kind = 19; + jjCheckNAdd(3); + } + else if (curChar == 34) + jjCheckNAddStates(0, 2); + if (curChar == 60) + jjCheckNAddTwoStates(1, 2); + break; + case 1: + if ((0x3ff000100002600L & l) != 0L) + jjCheckNAddTwoStates(1, 2); + break; + case 2: + if (curChar == 62 && kind > 18) + kind = 18; + break; + case 3: + if ((0xd7ffecfaffffd9ffL & l) == 0L) + break; + if (kind > 19) + kind = 19; + jjCheckNAdd(3); + break; + case 4: + case 6: + if (curChar == 34) + jjCheckNAddStates(0, 2); + break; + case 5: + if ((0xfffffffbffffffffL & l) != 0L) + jjCheckNAddStates(0, 2); + break; + case 8: + if (curChar == 34 && kind > 20) + kind = 20; + break; + default : + break; + } + } + while (i != startsAt); + } + else if (curChar < 128) + { + long l = 1L << (curChar & 077); + MatchLoop: do + { + switch (jjstateSet[--i]) + { + case 9: + jjCheckNAddStates(0, 2); + if (curChar == 92) + jjstateSet[jjnewStateCnt++] = 6; + break; + case 10: + if ((0xd7ffffffffffffffL & l) != 0L) + { + if (kind > 19) + kind = 19; + jjCheckNAdd(3); + } + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddTwoStates(1, 2); + break; + case 0: + case 3: + if ((0xd7ffffffffffffffL & l) == 0L) + break; + if (kind > 19) + kind = 19; + jjCheckNAdd(3); + break; + case 1: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddTwoStates(1, 2); + break; + case 5: + jjCheckNAddStates(0, 2); + break; + case 7: + if (curChar == 92) + jjstateSet[jjnewStateCnt++] = 6; + break; + default : + break; + } + } + while (i != startsAt); + } + else + { + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + MatchLoop: do + { + switch (jjstateSet[--i]) + { + case 9: + case 5: + if ((jjbitVec0[i2] & l2) != 0L) + jjCheckNAddStates(0, 2); + break; + case 10: + case 3: + if ((jjbitVec0[i2] & l2) == 0L) + break; + if (kind > 19) + kind = 19; + jjCheckNAdd(3); + break; + case 0: + if ((jjbitVec0[i2] & l2) == 0L) + break; + if (kind > 19) + kind = 19; + jjCheckNAdd(3); + break; + default : + break; + } + } + while (i != startsAt); + } + if (kind != 0x7fffffff) + { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + if ((i = jjnewStateCnt) == (startsAt = 9 - (jjnewStateCnt = startsAt))) + return curPos; + try + { + curChar = input_stream.readChar(); + } + catch (IOException e) + { + return curPos; + } + } + } + + static final int[] jjnextStates = { + 5, 7, 8, + }; + public static final String[] jjstrLiteralImages = { + "", null, null, null, null, "\50", "\51", "\54", "\173", "\175", "\73", "\75", + "\74", "\76", "\42", null, null, null, null, null, null, "\134\42", }; + public static final String[] lexStateNames = { + "DEFAULT", + }; + static final long[] jjtoToken = { + 0x3c7fe1L, + }; + static final long[] jjtoSkip = { + 0x1eL, + }; + protected SimpleCharStream input_stream; + private final int[] jjrounds = new int[9]; + private final int[] jjstateSet = new int[18]; + protected char curChar; + + public PropertyListParserTokenManager(SimpleCharStream stream) + { + if (SimpleCharStream.staticFlag) + throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); + input_stream = stream; + } + + public void ReInit(SimpleCharStream stream) + { + jjmatchedPos = jjnewStateCnt = 0; + curLexState = defaultLexState; + input_stream = stream; + ReInitRounds(); + } + + private final void ReInitRounds() + { + int i; + jjround = 0x80000001; + for (i = 9; i-- > 0;) + jjrounds[i] = 0x80000000; + } + + protected Token jjFillToken() + { + Token t = Token.newToken(jjmatchedKind); + t.kind = jjmatchedKind; + String im = jjstrLiteralImages[jjmatchedKind]; + t.image = (im == null) ? input_stream.GetImage() : im; + t.beginLine = input_stream.getBeginLine(); + t.beginColumn = input_stream.getBeginColumn(); + t.endLine = input_stream.getEndLine(); + t.endColumn = input_stream.getEndColumn(); + return t; + } + + int curLexState = 0; + int defaultLexState = 0; + int jjnewStateCnt; + int jjround; + int jjmatchedPos; + int jjmatchedKind; + + public Token getNextToken() + { + Token matchedToken; + int curPos = 0; + + EOFLoop : + for (; ;) + { + try + { + curChar = input_stream.BeginToken(); + } + catch (IOException e) + { + jjmatchedKind = 0; + matchedToken = jjFillToken(); + return matchedToken; + } + + try + { + input_stream.backup(0); + while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L) + curChar = input_stream.BeginToken(); + } + catch (IOException e1) + { + continue EOFLoop; + } + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_0(); + if (jjmatchedKind != 0x7fffffff) + { + if (jjmatchedPos + 1 < curPos) + input_stream.backup(curPos - jjmatchedPos - 1); + if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) + { + matchedToken = jjFillToken(); + return matchedToken; + } + else + { + continue EOFLoop; + } + } + int error_line = input_stream.getEndLine(); + int error_column = input_stream.getEndColumn(); + String error_after = null; + boolean EOFSeen = false; + try + { + input_stream.readChar(); + input_stream.backup(1); + } + catch (IOException e1) + { + EOFSeen = true; + error_after = curPos <= 1 ? "" : input_stream.GetImage(); + if (curChar == '\n' || curChar == '\r') + { + error_line++; + error_column = 0; + } + else + error_column++; + } + if (!EOFSeen) + { + input_stream.backup(1); + error_after = curPos <= 1 ? "" : input_stream.GetImage(); + } + throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); + } + } + +} Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserTokenManager.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserTokenManager.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/SimpleCharStream.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/SimpleCharStream.java?rev=348244&r1=348243&r2=348244&view=diff ============================================================================== --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/SimpleCharStream.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/SimpleCharStream.java Tue Nov 22 12:40:57 2005 @@ -1,312 +1,312 @@ -/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 3.0 */ -package org.apache.commons.configuration.plist; - -/** - * An implementation of interface CharStream, where the stream is assumed to - * contain only ASCII characters (without unicode processing). - */ - -class SimpleCharStream -{ - public static final boolean staticFlag = false; - int bufsize; - int available; - int tokenBegin; - public int bufpos = -1; - protected int bufline[]; - protected int bufcolumn[]; - - protected int column = 0; - protected int line = 1; - - protected boolean prevCharIsCR = false; - protected boolean prevCharIsLF = false; - - protected java.io.Reader inputStream; - - protected char[] buffer; - protected int maxNextCharInd = 0; - protected int inBuf = 0; - - protected void ExpandBuff(boolean wrapAround) - { - char[] newbuffer = new char[bufsize + 2048]; - int newbufline[] = new int[bufsize + 2048]; - int newbufcolumn[] = new int[bufsize + 2048]; - - try - { - if (wrapAround) - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - System.arraycopy(buffer, 0, newbuffer, - bufsize - tokenBegin, bufpos); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos += (bufsize - tokenBegin)); - } - else - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos -= tokenBegin); - } - } - catch (Throwable t) - { - throw new Error(t.getMessage()); - } - - - bufsize += 2048; - available = bufsize; - tokenBegin = 0; - } - - protected void FillBuff() throws java.io.IOException - { - if (maxNextCharInd == available) - { - if (available == bufsize) - { - if (tokenBegin > 2048) - { - bufpos = maxNextCharInd = 0; - available = tokenBegin; - } - else if (tokenBegin < 0) - bufpos = maxNextCharInd = 0; - else - ExpandBuff(false); - } - else if (available > tokenBegin) - available = bufsize; - else if ((tokenBegin - available) < 2048) - ExpandBuff(true); - else - available = tokenBegin; - } - - int i; - try { - if ((i = inputStream.read(buffer, maxNextCharInd, - available - maxNextCharInd)) == -1) - { - inputStream.close(); - throw new java.io.IOException(); - } - else - maxNextCharInd += i; - return; - } - catch(java.io.IOException e) { - --bufpos; - backup(0); - if (tokenBegin == -1) - tokenBegin = bufpos; - throw e; - } - } - - public char BeginToken() throws java.io.IOException - { - tokenBegin = -1; - char c = readChar(); - tokenBegin = bufpos; - - return c; - } - - protected void UpdateLineColumn(char c) - { - column++; - - if (prevCharIsLF) - { - prevCharIsLF = false; - line += (column = 1); - } - else if (prevCharIsCR) - { - prevCharIsCR = false; - if (c == '\n') - { - prevCharIsLF = true; - } - else - line += (column = 1); - } - - switch (c) - { - case '\r' : - prevCharIsCR = true; - break; - case '\n' : - prevCharIsLF = true; - break; - case '\t' : - column--; - column += (8 - (column & 07)); - break; - default : - break; - } - - bufline[bufpos] = line; - bufcolumn[bufpos] = column; - } - - public char readChar() throws java.io.IOException - { - if (inBuf > 0) - { - --inBuf; - - if (++bufpos == bufsize) - bufpos = 0; - - return buffer[bufpos]; - } - - if (++bufpos >= maxNextCharInd) - FillBuff(); - - char c = buffer[bufpos]; - - UpdateLineColumn(c); - return (c); - } - - /** - * @deprecated - * @see #getEndColumn - */ - - public int getColumn() { - return bufcolumn[bufpos]; - } - - /** - * @deprecated - * @see #getEndLine - */ - - public int getLine() { - return bufline[bufpos]; - } - - public int getEndColumn() { - return bufcolumn[bufpos]; - } - - public int getEndLine() { - return bufline[bufpos]; - } - - public int getBeginColumn() { - return bufcolumn[tokenBegin]; - } - - public int getBeginLine() { - return bufline[tokenBegin]; - } - - public void backup(int amount) { - - inBuf += amount; - if ((bufpos -= amount) < 0) - bufpos += bufsize; - } - - public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) - { - inputStream = dstream; - line = startline; - column = startcolumn - 1; - - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - - public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn) - { - this(dstream, startline, startcolumn, 4096); - } - - public SimpleCharStream(java.io.Reader dstream) - { - this(dstream, 1, 1, 4096); - } - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) - { - inputStream = dstream; - line = startline; - column = startcolumn - 1; - - if (buffer == null || buffersize != buffer.length) - { - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - prevCharIsLF = prevCharIsCR = false; - tokenBegin = inBuf = maxNextCharInd = 0; - bufpos = -1; - } - - public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) - { - this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); - } - - public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn) - { - this(dstream, startline, startcolumn, 4096); - } - - public SimpleCharStream(java.io.InputStream dstream) - { - this(dstream, 1, 1, 4096); - } - - public String GetImage() - { - if (bufpos >= tokenBegin) - return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); - else - return new String(buffer, tokenBegin, bufsize - tokenBegin) + - new String(buffer, 0, bufpos + 1); - } - - public void Done() - { - buffer = null; - bufline = null; - bufcolumn = null; - } - -} +/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 3.0 */ +package org.apache.commons.configuration.plist; + +/** + * An implementation of interface CharStream, where the stream is assumed to + * contain only ASCII characters (without unicode processing). + */ + +class SimpleCharStream +{ + public static final boolean staticFlag = false; + int bufsize; + int available; + int tokenBegin; + public int bufpos = -1; + protected int bufline[]; + protected int bufcolumn[]; + + protected int column = 0; + protected int line = 1; + + protected boolean prevCharIsCR = false; + protected boolean prevCharIsLF = false; + + protected java.io.Reader inputStream; + + protected char[] buffer; + protected int maxNextCharInd = 0; + protected int inBuf = 0; + + protected void ExpandBuff(boolean wrapAround) + { + char[] newbuffer = new char[bufsize + 2048]; + int newbufline[] = new int[bufsize + 2048]; + int newbufcolumn[] = new int[bufsize + 2048]; + + try + { + if (wrapAround) + { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + System.arraycopy(buffer, 0, newbuffer, + bufsize - tokenBegin, bufpos); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); + bufcolumn = newbufcolumn; + + maxNextCharInd = (bufpos += (bufsize - tokenBegin)); + } + else + { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + bufcolumn = newbufcolumn; + + maxNextCharInd = (bufpos -= tokenBegin); + } + } + catch (Throwable t) + { + throw new Error(t.getMessage()); + } + + + bufsize += 2048; + available = bufsize; + tokenBegin = 0; + } + + protected void FillBuff() throws java.io.IOException + { + if (maxNextCharInd == available) + { + if (available == bufsize) + { + if (tokenBegin > 2048) + { + bufpos = maxNextCharInd = 0; + available = tokenBegin; + } + else if (tokenBegin < 0) + bufpos = maxNextCharInd = 0; + else + ExpandBuff(false); + } + else if (available > tokenBegin) + available = bufsize; + else if ((tokenBegin - available) < 2048) + ExpandBuff(true); + else + available = tokenBegin; + } + + int i; + try { + if ((i = inputStream.read(buffer, maxNextCharInd, + available - maxNextCharInd)) == -1) + { + inputStream.close(); + throw new java.io.IOException(); + } + else + maxNextCharInd += i; + return; + } + catch(java.io.IOException e) { + --bufpos; + backup(0); + if (tokenBegin == -1) + tokenBegin = bufpos; + throw e; + } + } + + public char BeginToken() throws java.io.IOException + { + tokenBegin = -1; + char c = readChar(); + tokenBegin = bufpos; + + return c; + } + + protected void UpdateLineColumn(char c) + { + column++; + + if (prevCharIsLF) + { + prevCharIsLF = false; + line += (column = 1); + } + else if (prevCharIsCR) + { + prevCharIsCR = false; + if (c == '\n') + { + prevCharIsLF = true; + } + else + line += (column = 1); + } + + switch (c) + { + case '\r' : + prevCharIsCR = true; + break; + case '\n' : + prevCharIsLF = true; + break; + case '\t' : + column--; + column += (8 - (column & 07)); + break; + default : + break; + } + + bufline[bufpos] = line; + bufcolumn[bufpos] = column; + } + + public char readChar() throws java.io.IOException + { + if (inBuf > 0) + { + --inBuf; + + if (++bufpos == bufsize) + bufpos = 0; + + return buffer[bufpos]; + } + + if (++bufpos >= maxNextCharInd) + FillBuff(); + + char c = buffer[bufpos]; + + UpdateLineColumn(c); + return (c); + } + + /** + * @deprecated + * @see #getEndColumn + */ + + public int getColumn() { + return bufcolumn[bufpos]; + } + + /** + * @deprecated + * @see #getEndLine + */ + + public int getLine() { + return bufline[bufpos]; + } + + public int getEndColumn() { + return bufcolumn[bufpos]; + } + + public int getEndLine() { + return bufline[bufpos]; + } + + public int getBeginColumn() { + return bufcolumn[tokenBegin]; + } + + public int getBeginLine() { + return bufline[tokenBegin]; + } + + public void backup(int amount) { + + inBuf += amount; + if ((bufpos -= amount) < 0) + bufpos += bufsize; + } + + public SimpleCharStream(java.io.Reader dstream, int startline, + int startcolumn, int buffersize) + { + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + } + + public SimpleCharStream(java.io.Reader dstream, int startline, + int startcolumn) + { + this(dstream, startline, startcolumn, 4096); + } + + public SimpleCharStream(java.io.Reader dstream) + { + this(dstream, 1, 1, 4096); + } + public void ReInit(java.io.Reader dstream, int startline, + int startcolumn, int buffersize) + { + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + if (buffer == null || buffersize != buffer.length) + { + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + } + prevCharIsLF = prevCharIsCR = false; + tokenBegin = inBuf = maxNextCharInd = 0; + bufpos = -1; + } + + public SimpleCharStream(java.io.InputStream dstream, int startline, + int startcolumn, int buffersize) + { + this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); + } + + public SimpleCharStream(java.io.InputStream dstream, int startline, + int startcolumn) + { + this(dstream, startline, startcolumn, 4096); + } + + public SimpleCharStream(java.io.InputStream dstream) + { + this(dstream, 1, 1, 4096); + } + + public String GetImage() + { + if (bufpos >= tokenBegin) + return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); + else + return new String(buffer, tokenBegin, bufsize - tokenBegin) + + new String(buffer, 0, bufpos + 1); + } + + public void Done() + { + buffer = null; + bufline = null; + bufcolumn = null; + } + +} Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/SimpleCharStream.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/SimpleCharStream.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/Token.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/Token.java?rev=348244&r1=348243&r2=348244&view=diff ============================================================================== --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/Token.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/Token.java Tue Nov 22 12:40:57 2005 @@ -1,81 +1,81 @@ -/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */ -package org.apache.commons.configuration.plist; - -/** - * Describes the input token stream. - */ - -class Token { - - /** - * An integer that describes the kind of this token. This numbering - * system is determined by JavaCCParser, and a table of these numbers is - * stored in the file ...Constants.java. - */ - public int kind; - - /** - * beginLine and beginColumn describe the position of the first character - * of this token; endLine and endColumn describe the position of the - * last character of this token. - */ - public int beginLine, beginColumn, endLine, endColumn; - - /** - * The string image of the token. - */ - public String image; - - /** - * A reference to the next regular (non-special) token from the input - * stream. If this is the last token from the input stream, or if the - * token manager has not read tokens beyond this one, this field is - * set to null. This is true only if this token is also a regular - * token. Otherwise, see below for a description of the contents of - * this field. - */ - public Token next; - - /** - * This field is used to access special tokens that occur prior to this - * token, but after the immediately preceding regular (non-special) token. - * If there are no such special tokens, this field is set to null. - * When there are more than one such special token, this field refers - * to the last of these special tokens, which in turn refers to the next - * previous special token through its specialToken field, and so on - * until the first special token (whose specialToken field is null). - * The next fields of special tokens refer to other special tokens that - * immediately follow it (without an intervening regular token). If there - * is no such token, this field is null. - */ - public Token specialToken; - - /** - * Returns the image. - */ - public String toString() - { - return image; - } - - /** - * Returns a new Token object, by default. However, if you want, you - * can create and return subclass objects based on the value of ofKind. - * Simply add the cases to the switch for all those special cases. - * For example, if you have a subclass of Token called IDToken that - * you want to create if ofKind is ID, simlpy add something like : - * - * case MyParserConstants.ID : return new IDToken(); - * - * to the following switch statement. Then you can cast matchedToken - * variable to the appropriate type and use it in your lexical actions. - */ - public static final Token newToken(int ofKind) - { - switch(ofKind) - { - default : return new Token(); - } - } - -} +/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */ +package org.apache.commons.configuration.plist; + +/** + * Describes the input token stream. + */ + +class Token { + + /** + * An integer that describes the kind of this token. This numbering + * system is determined by JavaCCParser, and a table of these numbers is + * stored in the file ...Constants.java. + */ + public int kind; + + /** + * beginLine and beginColumn describe the position of the first character + * of this token; endLine and endColumn describe the position of the + * last character of this token. + */ + public int beginLine, beginColumn, endLine, endColumn; + + /** + * The string image of the token. + */ + public String image; + + /** + * A reference to the next regular (non-special) token from the input + * stream. If this is the last token from the input stream, or if the + * token manager has not read tokens beyond this one, this field is + * set to null. This is true only if this token is also a regular + * token. Otherwise, see below for a description of the contents of + * this field. + */ + public Token next; + + /** + * This field is used to access special tokens that occur prior to this + * token, but after the immediately preceding regular (non-special) token. + * If there are no such special tokens, this field is set to null. + * When there are more than one such special token, this field refers + * to the last of these special tokens, which in turn refers to the next + * previous special token through its specialToken field, and so on + * until the first special token (whose specialToken field is null). + * The next fields of special tokens refer to other special tokens that + * immediately follow it (without an intervening regular token). If there + * is no such token, this field is null. + */ + public Token specialToken; + + /** + * Returns the image. + */ + public String toString() + { + return image; + } + + /** + * Returns a new Token object, by default. However, if you want, you + * can create and return subclass objects based on the value of ofKind. + * Simply add the cases to the switch for all those special cases. + * For example, if you have a subclass of Token called IDToken that + * you want to create if ofKind is ID, simlpy add something like : + * + * case MyParserConstants.ID : return new IDToken(); + * + * to the following switch statement. Then you can cast matchedToken + * variable to the appropriate type and use it in your lexical actions. + */ + public static final Token newToken(int ofKind) + { + switch(ofKind) + { + default : return new Token(); + } + } + +} Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/Token.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/Token.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/TokenMgrError.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/TokenMgrError.java?rev=348244&r1=348243&r2=348244&view=diff ============================================================================== --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/TokenMgrError.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/TokenMgrError.java Tue Nov 22 12:40:57 2005 @@ -1,133 +1,133 @@ -/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */ -package org.apache.commons.configuration.plist; - -class TokenMgrError extends Error -{ - /* - * Ordinals for various reasons why an Error of this type can be thrown. - */ - - /** - * Lexical error occured. - */ - static final int LEXICAL_ERROR = 0; - - /** - * An attempt wass made to create a second instance of a static token manager. - */ - static final int STATIC_LEXER_ERROR = 1; - - /** - * Tried to change to an invalid lexical state. - */ - static final int INVALID_LEXICAL_STATE = 2; - - /** - * Detected (and bailed out of) an infinite loop in the token manager. - */ - static final int LOOP_DETECTED = 3; - - /** - * Indicates the reason why the exception is thrown. It will have - * one of the above 4 values. - */ - int errorCode; - - /** - * Replaces unprintable characters by their espaced (or unicode escaped) - * equivalents in the given string - */ - protected static final String addEscapes(String str) { - StringBuffer retval = new StringBuffer(); - char ch; - for (int i = 0; i < str.length(); i++) { - switch (str.charAt(i)) - { - case 0 : - continue; - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); - } else { - retval.append(ch); - } - continue; - } - } - return retval.toString(); - } - - /** - * Returns a detailed message for the Error when it is thrown by the - * token manager to indicate a lexical error. - * Parameters : - * EOFSeen : indicates if EOF caused the lexicl error - * curLexState : lexical state in which this error occured - * errorLine : line number when the error occured - * errorColumn : column number when the error occured - * errorAfter : prefix that was seen before this error occured - * curchar : the offending character - * Note: You can customize the lexical error message by modifying this method. - */ - protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { - return("Lexical error at line " + - errorLine + ", column " + - errorColumn + ". Encountered: " + - (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + - "after : \"" + addEscapes(errorAfter) + "\""); - } - - /** - * You can also modify the body of this method to customize your error messages. - * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not - * of end-users concern, so you can return something like : - * - * "Internal Error : Please file a bug report .... " - * - * from this method for such cases in the release version of your parser. - */ - public String getMessage() { - return super.getMessage(); - } - - /* - * Constructors of various flavors follow. - */ - - public TokenMgrError() { - } - - public TokenMgrError(String message, int reason) { - super(message); - errorCode = reason; - } - - public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { - this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); - } -} +/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */ +package org.apache.commons.configuration.plist; + +class TokenMgrError extends Error +{ + /* + * Ordinals for various reasons why an Error of this type can be thrown. + */ + + /** + * Lexical error occured. + */ + static final int LEXICAL_ERROR = 0; + + /** + * An attempt wass made to create a second instance of a static token manager. + */ + static final int STATIC_LEXER_ERROR = 1; + + /** + * Tried to change to an invalid lexical state. + */ + static final int INVALID_LEXICAL_STATE = 2; + + /** + * Detected (and bailed out of) an infinite loop in the token manager. + */ + static final int LOOP_DETECTED = 3; + + /** + * Indicates the reason why the exception is thrown. It will have + * one of the above 4 values. + */ + int errorCode; + + /** + * Replaces unprintable characters by their espaced (or unicode escaped) + * equivalents in the given string + */ + protected static final String addEscapes(String str) { + StringBuffer retval = new StringBuffer(); + char ch; + for (int i = 0; i < str.length(); i++) { + switch (str.charAt(i)) + { + case 0 : + continue; + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u" + s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + continue; + } + } + return retval.toString(); + } + + /** + * Returns a detailed message for the Error when it is thrown by the + * token manager to indicate a lexical error. + * Parameters : + * EOFSeen : indicates if EOF caused the lexicl error + * curLexState : lexical state in which this error occured + * errorLine : line number when the error occured + * errorColumn : column number when the error occured + * errorAfter : prefix that was seen before this error occured + * curchar : the offending character + * Note: You can customize the lexical error message by modifying this method. + */ + protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { + return("Lexical error at line " + + errorLine + ", column " + + errorColumn + ". Encountered: " + + (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + + "after : \"" + addEscapes(errorAfter) + "\""); + } + + /** + * You can also modify the body of this method to customize your error messages. + * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not + * of end-users concern, so you can return something like : + * + * "Internal Error : Please file a bug report .... " + * + * from this method for such cases in the release version of your parser. + */ + public String getMessage() { + return super.getMessage(); + } + + /* + * Constructors of various flavors follow. + */ + + public TokenMgrError() { + } + + public TokenMgrError(String message, int reason) { + super(message); + errorCode = reason; + } + + public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { + this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); + } +} Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/TokenMgrError.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/TokenMgrError.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org