コード例 #1
0
        private void Build_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var text = File.ReadAllText(@"..\..\..\..\ArduinoLanguageTest\TestCodeSample\Analog read serial.ino");

            rtbDisplay.Text  = text;
            rtbDisplay.Text += "\n\n-----------------------\n\n\n";
            LexemeAnalisis      analisis = new LexemeAnalisis(text);
            IEnumerable <Error> errors   = analisis.Analyse();

            rtbDisplay.Text = text + "\n\n-----------------------\n";
            foreach (Lexeme lexem in analisis.LexemeList)
            {
                rtbDisplay.Text += lexem.LexemValue + "\n";
            }
        }
コード例 #2
0
ファイル: LexemAnalisisTest.cs プロジェクト: Akeloya/Arduino
        public void Test_LexemeAnalisis_FromTestCodeSample()
        {
            string directoryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestCodeSample");

            foreach (string filePath in Directory.EnumerateFiles(directoryPath, "*.ino", SearchOption.TopDirectoryOnly))
            {
                string              code     = File.ReadAllText(filePath);
                LexemeAnalisis      analisis = new LexemeAnalisis(code);
                IEnumerable <Error> errors   = analisis.Analyse();
                Assert.Empty(errors);
                foreach (Lexeme lexem in analisis.LexemeList)
                {
                    Debug.WriteLine(lexem.LexemValue);
                    Assert.NotNull(lexem.LexemValue);
                    Assert.NotEqual(ArduinoLanguage.Enums.LexemeTypes.Underfined, lexem.Type);
                    Assert.NotEqual(0, lexem.Line);
                }
            }
        }