public void ShouldAllowAddingNewSingleCharacterDelimiter(char input)
        {
            var delimiters = new Delimiters(new List <Delimiter>());

            delimiters.Add(new Delimiter(input, false));
            Assert.AreEqual(delimiters.NumOfDelimiters(), 1);
        }
        public ImportViewModel(WizardViewModel wizardViewModel, List <string> lines)
        {
            Lines = lines;

            wizardViewModel.ContentWindow = this;
            wizardViewModel.WizardTitle   = "Импорт из файла";
            _wizardViewModel = wizardViewModel;

            ListItem semicolon = new ListItem("Точка с запятой ( ; )", ";");

            Delimiters.Add(semicolon);
            ListItem verticalBar = new ListItem("Вертикальная черта ( | )", "|");

            Delimiters.Add(verticalBar);
            ListItem tab = new ListItem("Табулятор ( t )", "\t");

            Delimiters.Add(tab);
            ListItem comma = new ListItem("Запятая ( , )", ",");

            Delimiters.Add(comma);
            ListItem colon = new ListItem("Двоеточие ( : )", ":");

            Delimiters.Add(colon);
            SelectedDelimiter = Delimiters[0];

            SetData();
        }
Exemple #3
0
 public HL7EasyParser() : base(false, "|")
 {
     FirstRowHasFieldNames = false;
     Delimiters.Add("|");
 }
Exemple #4
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        ///  Method: Load.
        /// </summary>
        /// <param name="buffer"> The buffer to read from.</param>
        /// <returns>
        ///  True if successful
        /// </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public bool Load(IBuffer buffer)
        {
            if (_scanner == null)
            {
                _scanner = new InfoScanner(buffer);
            }

            _scanner.Initialize(buffer, this);

            FilePath = buffer.Path;

            string type;

            while ((type = _scanner.ParseType()) != null)
            {
                switch (type)
                {
                case "KeyStart":
                    KeyStart = _scanner.ParseString(true);
                    break;

                case "KeyContinue":
                    KeyContinue = _scanner.ParseString(true);
                    break;

                case "Name":
                    Name = _scanner.ParseString(true);
                    break;

                case "Ext":
                    Extensions = _scanner.ParseArray();
                    break;

                case "Delimiter":
                {
                    if (Delimiters == null)
                    {
                        Delimiters = new List <Delimiter>();
                    }

                    var d = new Delimiter();
                    d.Name   = _scanner.ParseText();
                    d.Start  = _scanner.ParseString(true);
                    d.Escape = _scanner.ParseString(true);
                    d.End    = _scanner.ParseString(true);
                    if (string.IsNullOrEmpty(d.Escape))
                    {
                        d.Escape = "\0";
                    }
                    Delimiters.Add(d);
                }
                break;

                case "Operators":
                    Operators = _scanner.ParseString(true);
                    break;

                case "Punctuation":
                    Punctuation = _scanner.ParseString(true);
                    break;

                case "LineComment":
                    LineComment = _scanner.ParseString(true);
                    break;

                case "BlockComment":
                    BlockComment = _scanner.ParseArray();
                    break;

                case "Keyword":

                    KeyWords = _scanner.ParseMap();
                    break;

                case "Group":
                    Groups = _scanner.ParseArray();
                    break;

                default:
                    break;
                }
                _scanner.NextLine();
            }

            if (KeyWords != null)
            {
                KeyWords.Sort((x, y) => x.Text.CompareTo(y.Text));
            }

            return(true);
        }
Exemple #5
0
        public void AddLexemLog(Tuple <State, string> value)
        {
            int position = 0;

            switch (value.Item1)
            {
            case (State.Identifier):
            {
                position = Identifiers.IndexOf(value.Item2);
                if (position == -1)
                {
                    Identifiers.Add(value.Item2);
                    position = Identifiers.IndexOf(value.Item2);
                }
                break;
            }

            case (State.Keyword):
            {
                position = Keywords.IndexOf(value.Item2);
                if (position == -1)
                {
                    Keywords.Add(value.Item2);
                    position = Keywords.IndexOf(value.Item2);
                }
                break;
            }

            case (State.DecimalNumber):
            {
                position = DecimalNumbers.IndexOf(value.Item2);
                if (position == -1)
                {
                    DecimalNumbers.Add(value.Item2);
                    position = DecimalNumbers.IndexOf(value.Item2);
                }
                break;
            }

            case (State.Delimiter):
            {
                position = Delimiters.IndexOf(value.Item2);
                if (position == -1)
                {
                    Delimiters.Add(value.Item2);
                    position = Delimiters.IndexOf(value.Item2);
                }
                break;
            }

            case (State.DoubleDelimiter):
            {
                position = Delimiters.IndexOf(value.Item2);
                if (position == -1)
                {
                    Delimiters.Add(value.Item2);
                    position = Delimiters.IndexOf(value.Item2);
                }
                break;
            }

            case (State.String):
            {
                position = Strings.IndexOf(value.Item2);
                if (position == -1)
                {
                    Strings.Add(value.Item2);
                    position = Strings.IndexOf(value.Item2);
                }
                break;
            }

            default:
            {
                Console.WriteLine($"{value} Not found");
                break;
            }
            }
            var entry = new DecompositionTableEntry
            {
                Table    = value.Item1,
                Lexem    = value.Item2,
                Position = position
            };

            CommonSymbolTable.Add(entry);
        }
Exemple #6
0
 public void Add(T item)
 {
     Delimiters.Add(item);
 }