Ejemplo n.º 1
0
        private void interpretateAsLWIQA(object sender, EventArgs e)
        {
            if (textBox.Text == "")
            {
                return;
            }
            Translator inter = new Translator(textBox.Text);

            InterpreterPlugin.OutputTable outputTable = new InterpreterPlugin.OutputTable(ref form, inter.LexemTable, "Lexem table", new Pair <string, string>("Lexem", "Discription"));
            outputTable.Show();
            if (inter.LexemTable[0].val2.Contains("Error"))
            {
                return;
            }
            if (inter.SyntaxErrorTable.Count != 0)
            {
                outputTable = new InterpreterPlugin.OutputTable(ref form, inter.SyntaxErrorTable, "Syntax errors", new Pair <string, string>("Token", "Message"));
                outputTable.Show();
                return;
            }
            InterpreterPlugin.TreeForm treeForm = new InterpreterPlugin.TreeForm(inter.BeginNode, form);
            treeForm.Show();
            if (inter.SemanticErrorTable.Count != 0)
            {
                outputTable = new InterpreterPlugin.OutputTable(ref form, inter.SemanticErrorTable, "Semantic errors", new Pair <string, string>("Construction", "Message"));
                outputTable.Show();
                return;
            }
            textBox.Text = inter.OutputCode;
        }
Ejemplo n.º 2
0
        private void getLexTable(object sender, EventArgs e)
        {
            if (!_textChanged)
            {
                return;
            }
            Lexer lex = new Lexer();

            _table       = lex.lex(textBox.Text);
            _tokenInLine = lex.tokenInLine;
            InterpreterPlugin.OutputTable ff = new InterpreterPlugin.OutputTable(ref form, _table, "Lexem table", new Pair <string, string>("Lexem", "Discription"));
            ff.Show();
            _textChanged = false;
        }
Ejemplo n.º 3
0
        private void getSemErrors(object sender, EventArgs e)
        {
            if (_textChanged)
            {
                getSyntaxErrors(sender, e);
            }
            Semantic sem = new Semantic(_beginNode);

            sem.analysis();
            if (sem.errorsTable.Count != 0)
            {
                InterpreterPlugin.OutputTable semErr = new InterpreterPlugin.OutputTable(ref form, sem.errorsTable, "Semantic errors", new Pair <string, string>("Construction", "Message"));
                semErr.Show();
            }
        }
Ejemplo n.º 4
0
        private void getSyntaxErrors(object sender, EventArgs e)
        {
            if (_textChanged)
            {
                getLexTable(sender, e);
            }
            SyntaxTree st = new SyntaxTree(_table, _tokenInLine);

            st.parse();
            InterpreterPlugin.TreeForm treeForm = new InterpreterPlugin.TreeForm(st.beginNode, form);
            treeForm.Show();
            _beginNode = st.beginNode;
            if (st.errorsTable.Count != 0)
            {
                InterpreterPlugin.OutputTable syntErr = new InterpreterPlugin.OutputTable(ref form, st.errorsTable, "Syntax errors", new Pair <string, string>("Token", "Message"));
                syntErr.Show();
            }
        }