Exemple #1
0
        public TextHighlighter(RichTextBox textbox, Scanner scanner, Parser parser)
        {
            Textbox = textbox;
            Scanner = scanner;
            Parser = parser;

            ClearUndo();

            //Tree = Parser.Parse(Textbox.Text);
            Textbox.TextChanged += new EventHandler(Textbox_TextChanged);
            textbox.KeyDown += new KeyEventHandler(textbox_KeyDown);
            Textbox.SelectionChanged += new EventHandler(Textbox_SelectionChanged);
            Textbox.Disposed += new EventHandler(Textbox_Disposed);

            SwitchContext = null;
            currentContext = Tree;

            threadAutoHighlight = new Thread(AutoHighlightStart);
            threadAutoHighlight.Start();
        }
Exemple #2
0
 public Parser(Scanner scanner)
 {
     this.scanner = scanner;
 }
Exemple #3
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            headerEvaluator.Activate(textInput);
            headerEvaluator.CloseClick += new EventHandler(headerEvaluator_CloseClick);
            headerOutput.Activate(tabOutput);
            headerOutput.CloseClick += new EventHandler(headerOutput_CloseClick);

            DockExtender = new DockExtender(this);
            inputFloaty  = DockExtender.Attach(panelInput, headerEvaluator, splitterBottom);
            outputFloaty = DockExtender.Attach(panelOutput, headerOutput, splitterRight);

            inputFloaty.Docking  += new EventHandler(inputFloaty_Docking);
            outputFloaty.Docking += new EventHandler(inputFloaty_Docking);
            inputFloaty.Hide();
            outputFloaty.Hide();

            textOutput.Text  = AssemblyInfo.ProductName + " v" + Application.ProductVersion + "\r\n";
            textOutput.Text += AssemblyInfo.CopyRightsDetail + "\r\n\r\n";


            marker  = new TextMarker(textEditor);
            checker = new SyntaxChecker(marker); // run the syntax checker on seperate thread

            // create the syntax update checker event handler and remember its reference
            syntaxUpdateChecker   = new EventHandler(checker_UpdateSyntax);
            checker.UpdateSyntax += syntaxUpdateChecker; // listen for events
            System.Threading.Thread thread = new System.Threading.Thread(checker.Start);
            thread.Start();

            TextChangedTimer       = new Timer();
            TextChangedTimer.Tick += new EventHandler(TextChangedTimer_Tick);

            // assign the auto completion function to this editor
            // autocomplete form will take care of the rest
            codecomplete              = new AutoComplete(textEditor);
            codecomplete.Enabled      = false;
            directivecomplete         = new AutoComplete(textEditor);
            directivecomplete.Enabled = false;
            directivecomplete.WordList.Items.Add("@ParseTree");
            directivecomplete.WordList.Items.Add("@Parser");
            directivecomplete.WordList.Items.Add("@Scanner");
            directivecomplete.WordList.Items.Add("@TextHighlighter");
            directivecomplete.WordList.Items.Add("@TinyPG");
            directivecomplete.WordList.Items.Add("Generate");
            directivecomplete.WordList.Items.Add("Language");
            directivecomplete.WordList.Items.Add("Namespace");
            directivecomplete.WordList.Items.Add("OutputPath");
            directivecomplete.WordList.Items.Add("TemplatePath");

            // setup the text highlighter (= text coloring)
            highlighterScanner             = new TinyPG.Highlighter.Scanner();
            textHighlighter                = new TinyPG.Highlighter.TextHighlighter(textEditor, highlighterScanner, new TinyPG.Highlighter.Parser(highlighterScanner));
            textHighlighter.SwitchContext += new TinyPG.Highlighter.ContextSwitchEventHandler(TextHighlighter_SwitchContext);

            LoadConfig();

            if (GrammarFile == null)
            {
                NewGrammar();
            }
        }
Exemple #4
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            headerEvaluator.Activate(textInput);
            headerEvaluator.CloseClick += new EventHandler(headerEvaluator_CloseClick);
            headerOutput.Activate(tabOutput);
            headerOutput.CloseClick += new EventHandler(headerOutput_CloseClick);

            DockExtender = new DockExtender(this);
            inputFloaty = DockExtender.Attach(panelInput, headerEvaluator, splitterBottom);
            outputFloaty = DockExtender.Attach(panelOutput, headerOutput, splitterRight);

            inputFloaty.Docking += new EventHandler(inputFloaty_Docking);
            outputFloaty.Docking += new EventHandler(inputFloaty_Docking);
            inputFloaty.Hide();
            outputFloaty.Hide();

            textOutput.Text = AssemblyInfo.ProductName + " v" + Application.ProductVersion + "\r\n";
            textOutput.Text += AssemblyInfo.CopyRightsDetail + "\r\n\r\n";

            marker = new TextMarker(textEditor);
            checker = new SyntaxChecker(marker); // run the syntax checker on seperate thread

            // create the syntax update checker event handler and remember its reference
            syntaxUpdateChecker = new EventHandler(checker_UpdateSyntax);
            checker.UpdateSyntax += syntaxUpdateChecker; // listen for events
            System.Threading.Thread thread = new System.Threading.Thread(checker.Start);
            thread.Start();

            TextChangedTimer = new Timer();
            TextChangedTimer.Tick += new EventHandler(TextChangedTimer_Tick);

            // assign the auto completion function to this editor
            // autocomplete form will take care of the rest
            codecomplete = new AutoComplete(textEditor);
            codecomplete.Enabled = false;
            directivecomplete = new AutoComplete(textEditor);
            directivecomplete.Enabled = false;
            directivecomplete.WordList.Items.Add("@ParseTree");
            directivecomplete.WordList.Items.Add("@Parser");
            directivecomplete.WordList.Items.Add("@Scanner");
            directivecomplete.WordList.Items.Add("@TextHighlighter");
            directivecomplete.WordList.Items.Add("@TinyPG");
            directivecomplete.WordList.Items.Add("Generate");
            directivecomplete.WordList.Items.Add("Language");
            directivecomplete.WordList.Items.Add("Namespace");
            directivecomplete.WordList.Items.Add("OutputPath");
            directivecomplete.WordList.Items.Add("TemplatePath");

            // setup the text highlighter (= text coloring)
            highlighterScanner = new TinyPG.Highlighter.Scanner();
            textHighlighter = new TinyPG.Highlighter.TextHighlighter(textEditor, highlighterScanner, new TinyPG.Highlighter.Parser(highlighterScanner));
            textHighlighter.SwitchContext += new TinyPG.Highlighter.ContextSwitchEventHandler(TextHighlighter_SwitchContext);

            LoadConfig();

            if (GrammarFile == null)
                NewGrammar();
        }