Ejemplo n.º 1
0
            public void SetNextLexemTypeToTreater()
            {
                SetNextWordToTreater();
                switch (currentWord)
                {
                case "begin": currentLexemType = LexemsType.Begin; return;

                case "end": currentLexemType = LexemsType.End; return;

                case "if": currentLexemType = LexemsType.If; return;

                case "do": currentLexemType = LexemsType.Do; return;

                case "while": currentLexemType = LexemsType.While; return;

                default:
                    if (currentWord.Length > 1)
                    {
                        currentLexemType = LexemsType.SimpleWord;
                        return;
                    }
                    else
                    {
                        currentLexemType = LexemsType.SyntaxLexem;
                        return;
                    }
                }
            }
        public void SetNextLexemTypeToTreater()
        {
            SetNextWordToTreater();
            switch (currentWord)
            {
            case "begin": currentLexemType = LexemsType.Begin; break;

            case "end": currentLexemType = LexemsType.End; break;

            case "if": currentLexemType = LexemsType.If; break;

            case "do": currentLexemType = LexemsType.Do; break;

            case "while": currentLexemType = LexemsType.While; break;

            case "iden": currentLexemType = LexemsType.Iden; break;

            case "numb": currentLexemType = LexemsType.Number; break;

            default:
                if (IsWord(currentWord))
                {
                    currentLexemType = LexemsType.SimpleWord;
                    break;
                }
                else
                {
                    currentLexemType = LexemsType.SyntaxLexem;
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            string pathToResourceFile = "..\\..\\resources\\resource.db";
            string pathToResultFile   = "..\\..\\result.db";

            InstructionsTreatment treater = new InstructionsTreatment(pathToResourceFile);
            ResultsWriter         writer  = new ResultsWriter(pathToResultFile);

            while (true)
            {
                treater.SetNextLexemTypeToTreater();
                LexemsType type = treater.CurrentLexem;
                string     word = treater.CurrentWord;
                writer.WriteResultToFile(type, word);
                if (word.Trim() == "@")
                {
                    break;
                }
            }

            treater.Finish();
            writer.Finish();
        }
Ejemplo n.º 4
0
 public void WriteResultToFile(LexemsType type, string word)
 {
     fileWriter.WriteLine(type.ToString() + " - " + word);
 }
Ejemplo n.º 5
0
 private void SetNextLexem()
 {
     treater.SetNextLexemTypeToTreater();
     currentLexemType = treater.CurrentLexem;
     currentWord      = treater.CurrentWord;
 }