⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parsercommon.cs

📁 csv解析类
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;

namespace QiHe.CodeLib.Csv
{
    public partial class Parser
    {
        int position;
        ParserInput<Char> Input;

        public List<string> Errors = new List<string>();

        public Parser() { }

        private void SetInput(ParserInput<Char> input)
        {
            Input = input;
            position = 0;
        }

        private char MatchTerminal(char ch, out bool success)
        {
            success = false;
            if (Input.HasInput(position))
            {
                Char symbol = Input.GetInputSymbol(position);
                if (ch == symbol)
                {
                    position++;
                    success = true;
                }
                return symbol;
            }
            return default(Char);
        }

        private char MatchTerminalRange(char start, char end, out bool success)
        {
            success = false;
            if (Input.HasInput(position))
            {
                Char symbol = Input.GetInputSymbol(position);
                if (start <= symbol && symbol <= end)
                {
                    position++;
                    success = true;
                }
                return symbol;
            }
            return default(Char);
        }

        private char MatchTerminalSet(string terminalSet, bool isComplement, out bool success)
        {
            success = false;
            if (Input.HasInput(position))
            {
                Char symbol = Input.GetInputSymbol(position);
                bool match = isComplement ? terminalSet.IndexOf(symbol) == -1 : terminalSet.IndexOf(symbol) > -1;
                if (match)
                {
                    position++;
                    success = true;
                }
                return symbol;
            }
            return default(Char);
        }

        private bool MatchTerminal(char ch)
        {
            if (Input.HasInput(position))
            {
                Char symbol = Input.GetInputSymbol(position);
                if (ch == symbol)
                {
                    position++;
                    return true;
                }
            }
            return false;
        }

        private string MatchTerminalString(string terminalString, out bool success)
        {
            int currrent_position = position;
            foreach (char ch in terminalString)
            {
                if (!MatchTerminal(ch))
                {
                    position = currrent_position;
                    success = false;
                    return null;
                }
            }
            success = true;
            return terminalString;
        }

        private void Error(string message)
        {
            Errors.Add(Input.LocateError(position, message));
        }

        private void ClearError()
        {
            Errors.Clear();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -