LispEngine.Lexing.Scanner.isOneOf C# (CSharp) Method

isOneOf() private method

private isOneOf ( string chars ) : bool
chars string
return bool
        private bool isOneOf(string chars)
        {
            return more() && chars.IndexOf(peek()) != -1;
        }

Usage Example

Example #1
0
        // This code is pretty hairy - the problem is
        // distinguishing between:
        // 1. a floating point number, which may be
        // in scientific notification, and might simply begin
        // with "."
        // 2. A symbol with a dot in it
        // 3. Just a lone "." used for separating lists

        // It's doubtful that it's entirely correct - but if you find a bug,
        // add it as a test to ScannerTest and amend this logic.
        private static TokenType?matchNumber(Scanner s)
        {
            if (s.peek() == '.')
            {
                return(leadingFloat(s));
            }

            if (s.isOneOf("+-"))
            {
                s.readChar();
                if (s.peek() == '.')
                {
                    return(leadingFloat(s));
                }
                var num = unsignedNumber(s);
                if (num != null)
                {
                    return(num);
                }

                matchSymbol(s);
                return(TokenType.Symbol);
            }
            return(unsignedNumber(s));
        }
All Usage Examples Of LispEngine.Lexing.Scanner::isOneOf