Ejemplo n.º 1
0
        private void LexIdentifier()
        {
            var start = _pos;

            do
            {
                _pos++;
            }while (IsIdentifier(_charsToProcess[_pos]));
            var subarray = Subarray(start, _pos);

            // Check if this is the alternative (textual) representation of an operator (see
            // alternativeOperatorNames)
            if ((_pos - start) == 2 || (_pos - start) == 3)
            {
                var asString = new string(subarray).ToUpper();
                var idx      = Array.BinarySearch(ALTERNATIVE_OPERATOR_NAMES, asString);
                if (idx >= 0)
                {
                    PushOneCharOrTwoCharToken(TokenKind.ValueOf(asString), start, subarray);
                    return;
                }
            }

            _tokens.Add(new Token(TokenKind.IDENTIFIER, subarray, start, _pos));
        }