コード例 #1
0
ファイル: VHDL_Lexter.cs プロジェクト: cuijialang/HDL_ANTLR4
        public override void Update(string text)
        {
            if ((Compiler != null) && (Compiler is VHDLCompiler))
            {
                VHDLCompiler compiler = Compiler as VHDLCompiler;
                ErrorList.Clear();

                codeFile = compiler.GetFileByPath(extendedTextEditor.FilePath) as VHDL_CodeFile;
                if (codeFile == null)
                {
                    codeFile = compiler.AddCodeFile(extendedTextEditor.FilePath) as VHDL_CodeFile;
                }
                if (codeFile != null)
                {
                    codeFile.Text = text;
                    compiler.ProcessCodeFile(codeFile);
                    file = codeFile.File;

                    tokenStream = codeFile.TokenStream;
                    tree        = codeFile.Tree;

                    if (codeFile.ParseSyntaxException != null)
                    {
                        //foreach (RecognitionException err in codeFile.SyntaxErrors.Errors)
                        //{
                        int offset = codeFile.ParseSyntaxException.OffendingSymbol.StartIndex;
                        int length = codeFile.ParseSyntaxException.OffendingSymbol.StopIndex - offset + 1;
                        Exception_Information inf = new Exception_Information(offset, length, codeFile.ParseSyntaxException.Message);
                        ErrorList.Add(inf);
                        //}
                    }
                    if (codeFile.ParseSemanticException != null)
                    {
                        //foreach (ParseError err in codeFile.SemanticErrors.Errors)
                        //{
                        int offset = codeFile.ParseSemanticException.Context.Start.StartIndex;
                        int length = codeFile.ParseSemanticException.Context.Start.StopIndex - offset + 1;
                        Exception_Information inf = new Exception_Information(offset, length, codeFile.ParseSemanticException.Message);
                        ErrorList.Add(inf);
                        //}
                    }
                }
            }
        }
コード例 #2
0
 public VHDL_CodeFile(string filePath, string libraryName, VHDLCompiler compiler)
     : base(filePath, libraryName, ModelingLanguage.VHDL)
 {
     this.compiler   = compiler;
     libraryFileInfo = LibraryFileInfo.AnalyseText(text, filePath, LibraryName);
 }