Exemple #1
0
        private void ProccessLine(string CurrentLine, ref int LineNumber)
        {
            string[] LineStatements = CurrentLine.Trim().SplitAndKeepSeparators(new string[] { Delimiter.Id }).ToArray();

            foreach (string Statement in LineStatements)
            {
                if (string.IsNullOrEmpty(Statement?.Trim()) || Statement.Trim().StartsWith(SingleComment.Id))
                {
                    LineNumber++;
                    continue;
                }

                string[] Words = CurrentLine.Split(AdditionalWordSpliter.ToArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (string Word in Words)
                {
                    string CleanWord = SanitizeToken(Word);

                    Symbol ExistingToken = symbols.GetToken(CleanWord);

                    if (ExistingToken != null)
                    {
                        switch (ExistingToken.type)
                        {
                        case TokenType.primitive:
                            ProcessPrimitive(ExistingToken, Statement, LineNumber, Scope);
                            break;

                        case TokenType.conditional:
                        case TokenType.loop:
                            string CodeBlock = ExtractCodeBlock(Statement, ref LineNumber, ref FileToAnalize);
                            BlockStructure(ExistingToken, CodeBlock, ref LineNumber, ref Scope);
                            break;
                        }

                        break;
                    }
                    else
                    {
                        symbols.AddError(new Error
                        {
                            Analizer = AnalizerType.lexical,
                            Line     = LineNumber,
                            Message  = $"Unexpected Token {CleanWord}"
                        });
                    }
                }
            }
        }