packages/System.Linq.Dynamic.Core.1.0.7.13/src/System.Linq.Dynamic.Core/Tokenizer/TextParser.cs

(开头部分) 13KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System.Collections.Generic;
using System.Globalization;
using System.Linq.Dynamic.Core.Exceptions;

namespace System.Linq.Dynamic.Core.Tokenizer
{
    internal class TextParser
    {
        private static char NumberDecimalSeparator = '.';

        // These aliases are supposed to simply the where clause and make it more human readable
        // As an addition it is compatible with the OData.Filter specification
        private static readonly Dictionary<string, TokenId> _predefinedAliases = new Dictionary<string, TokenId>
        {
            {"eq", TokenId.Equal},
            {"ne", TokenId.ExclamationEqual},
            {"neq", TokenId.ExclamationEqual},
            {"lt", TokenId.LessThan},
            {"le", TokenId.LessThanEqual},
            {"gt", TokenId.GreaterThan},
            {"ge", TokenId.GreaterThanEqual},
            {"and", TokenId.DoubleAmphersand},
            {"or", TokenId.DoubleBar},
            {"not", TokenId.Exclamation},
            {"mod", TokenId.Percent}
        };

        private readonly string _text;
        private readonly int _textLen;

        private int _textPos;
        private char _ch;
        public Token CurrentToken;

        public TextParser(string text)
        {
            _text = text;
            _textLen = _text.Length;
            SetTextPos(0);
            NextToken();
        }

        private void SetTextPos(int pos)
        {
            _textPos = pos;
            _ch = _textPos < _textLen ? _text[_textPos] : '\0';
        }

        private void NextChar()
        {
            if (_textPos < _textLen) _textPos++;
            _ch = _textPos < _textLen ? _text[_textPos] : '\0';
        }

        public void NextToken()
        {
            while (char.IsWhiteSpace(_ch))
                NextChar();

            TokenId tokenId = TokenId.Unknown;
后面还有 370 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。