Example #1
0
        public void Start()
        {
            Scanner scanner = new Scanner();
            Parser  parser  = new Parser(scanner);

            while (!disposing)
            {
                System.Threading.Thread.Sleep(250);
                if (!textchanged)
                {
                    continue;
                }

                textchanged = false;

                scanner.Init(text);
                SyntaxTree = parser.Parse(text, "", new GrammarTree());
                if (SyntaxTree.Errors.Count > 0)
                {
                    SyntaxTree.Errors.Clear();
                }

                try
                {
                    if (Grammar == null)
                    {
                        Grammar = (Grammar)SyntaxTree.Eval();
                    }
                    else
                    {
                        lock (Grammar)
                        {
                            Grammar = (Grammar)SyntaxTree.Eval();
                        }
                    }
                }
                catch (Exception)
                {
                }

                if (textchanged)
                {
                    continue;
                }

                lock (marker)
                {
                    marker.Clear();
                    foreach (ParseError err in SyntaxTree.Errors)
                    {
                        marker.AddWord(err.Position, err.Length, System.Drawing.Color.Red, err.Message);
                    }
                }

                if (UpdateSyntax != null)
                {
                    UpdateSyntax.Invoke(this, new EventArgs());
                }
            }
        }
Example #2
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    _syntax.Dispose();
                    _syntax = null;
                }

                disposedValue = true;
            }
        }