diff --git a/doc/resources/CaseChangingCharStream.cs b/doc/resources/CaseChangingCharStream.cs index 060052727..9f73a0382 100644 --- a/doc/resources/CaseChangingCharStream.cs +++ b/doc/resources/CaseChangingCharStream.cs @@ -1,47 +1,105 @@ -using System; +/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. + * Use of this file is governed by the BSD 3-clause license that + * can be found in the LICENSE.txt file in the project root. + */ +using System; using Antlr4.Runtime.Misc; namespace Antlr4.Runtime { + /// + /// This class supports case-insensitive lexing by wrapping an existing + /// and forcing the lexer to see either upper or + /// lowercase characters. Grammar literals should then be either upper or + /// lower case such as 'BEGIN' or 'begin'. The text of the character + /// stream is unaffected. Example: input 'BeGiN' would match lexer rule + /// 'BEGIN' if constructor parameter upper=true but getText() would return + /// 'BeGiN'. + /// public class CaseChangingCharStream : ICharStream { private ICharStream stream; private bool upper; + /// + /// Constructs a new CaseChangingCharStream wrapping the given forcing + /// all characters to upper case or lower case. + /// + /// The stream to wrap. + /// If true force each symbol to upper case, otherwise force to lower. public CaseChangingCharStream(ICharStream stream, bool upper) { this.stream = stream; this.upper = upper; } - public int Index => stream.Index; + public int Index + { + get + { + return stream.Index; + } + } - public int Size => stream.Size; + public int Size + { + get + { + return stream.Size; + } + } - public string SourceName => stream.SourceName; + public string SourceName + { + get + { + return stream.SourceName; + } + } - public void Consume() => stream.Consume(); + public void Consume() + { + stream.Consume(); + } [return: NotNull] - public string GetText(Interval interval) => stream.GetText(interval); + public string GetText(Interval interval) + { + return stream.GetText(interval); + } public int LA(int i) { int c = stream.LA(i); - if (c <= 0) return c; + if (c <= 0) + { + return c; + } - var o = Convert.ToChar(c); + char o = (char)c; - if (upper) return Convert.ToInt32(char.ToUpper(o)); + if (upper) + { + return (int)char.ToUpperInvariant(o); + } - return Convert.ToInt32(char.ToLower(o)); + return (int)char.ToLowerInvariant(o); } - public int Mark() => stream.Mark(); + public int Mark() + { + return stream.Mark(); + } - public void Release(int marker) => stream.Release(marker); + public void Release(int marker) + { + stream.Release(marker); + } - public void Seek(int index) => stream.Seek(index); + public void Seek(int index) + { + stream.Seek(index); + } } }