diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 04:53:00 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 04:53:00 +0000 |
commit | 2103fa6311fc74d5656374dd7ce6864d5512827d (patch) | |
tree | 175590417700c14fe86aac39848f249e79c1c6ba /runtime/CSharp3/Sources/Antlr3.Runtime.JavaExtensions/StringTokenizer.cs | |
parent | fa0f7c0a4778de81e61057cf040f911e06e99fab (diff) | |
parent | 16467b971bd3e2009fad32dd79016f2c7e421deb (diff) | |
download | antlr-android14-mainline-extservices-release.tar.gz |
Snap for 10453563 from 16467b971bd3e2009fad32dd79016f2c7e421deb to mainline-extservices-releaseaml_ext_341716000aml_ext_341620040aml_ext_341518010aml_ext_341414010aml_ext_341317010aml_ext_341131030aml_ext_341027030android14-mainline-extservices-release
Change-Id: I244e0ffe87374b4c1468a6661be5f4610baa6ae0
Diffstat (limited to 'runtime/CSharp3/Sources/Antlr3.Runtime.JavaExtensions/StringTokenizer.cs')
-rw-r--r-- | runtime/CSharp3/Sources/Antlr3.Runtime.JavaExtensions/StringTokenizer.cs | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/runtime/CSharp3/Sources/Antlr3.Runtime.JavaExtensions/StringTokenizer.cs b/runtime/CSharp3/Sources/Antlr3.Runtime.JavaExtensions/StringTokenizer.cs deleted file mode 100644 index 0145df5..0000000 --- a/runtime/CSharp3/Sources/Antlr3.Runtime.JavaExtensions/StringTokenizer.cs +++ /dev/null @@ -1,87 +0,0 @@ -/* - * [The "BSD licence"] - * Copyright (c) 2005-2008 Terence Parr - * All rights reserved. - * - * Conversion to C#: - * Copyright (c) 2008 Sam Harwell, Pixel Mine, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Linq; - -namespace Antlr.Runtime.JavaExtensions -{ - public class StringTokenizer - { - string[] _tokens; - int _current; - - public StringTokenizer( string str, string separator ) - : this( str, separator, false ) - { - } - public StringTokenizer( string str, string separator, bool returnDelims ) - { - _tokens = str.Split( separator.ToCharArray(), StringSplitOptions.None ); - if ( returnDelims ) - { - char[] delims = separator.ToCharArray(); - _tokens = _tokens.SelectMany( ( token, i ) => - { - if ( i == _tokens.Length - 1 ) - { - if ( delims.Contains( str[str.Length - 1] ) ) - return new string[0]; - else - return new string[] { token }; - } - else if ( i == 0 ) - { - if ( delims.Contains( str[0] ) ) - return new string[] { str[0].ToString() }; - else - return new string[] { token }; - } - else - { - return new string[] { token, str[_tokens.Take( i + 1 ).Select( t => t.Length + 1 ).Sum() - 1].ToString() }; - } - } ).ToArray(); - } - } - - public bool hasMoreTokens() - { - return _current < _tokens.Length; - } - - public string nextToken() - { - return _tokens[_current++]; - } - } -} |