public Form2() { InitializeComponent(); SyntaxAnalyser SA = new SyntaxAnalyser(); Node root = SA.Parse(TINY_Compiler.tiny_Scanner.Tokens); treeView1.Nodes.Add(SyntaxAnalyser.PrintParseTree(root)); for (int i = 0; i < SA.Errors.Count; i++) { MessageBox.Show(SA.Errors[i]); richTextBox2.Text += (i + 1) + "- " + SA.Errors[i] + "\n"; } }
// Übergebenen Sourcecode übersetzen. public bool Compile(string source, bool optionExplicit = true, bool allowExternal = true) { ErrorObject = new InterpreterError(); StringInputStream sourceStream = new StringInputStream(); // den Inputstream syntaktisch prüfen und Code erzeugen var parser = new SyntaxAnalyser(ErrorObject); code = new Collection <object>(); parser.Parse(sourceStream.Connect(source), this, optionExplicit, allowExternal); if (ErrorObject.Number == 0) { return(true); } return(false); }
//test every tokens to get the match one public void Find_Match_Token(string Lex) { TINY_Token_Class TC; List <string> rev = new List <string>(); List <string> operatorsl = new List <string>(); int counter = 0; string lex_con = ""; size = Lex.Length; if (!isreversed_keyword(Lex)) { for (int i = 0; i < ReservedWords.Count; i++) { if (Lex == ReservedWords.ElementAt(i).Key) { TINY_Token Tok = new TINY_Token(); Tok.lex = Lex; Tok.token_type = ReservedWords.ElementAt(i).Value; Tokens.Add(Tok); break; } } } else if (!isoperator(Lex)) { for (int i = 0; i < Operators.Count; i++) { if (Lex == Operators.ElementAt(i).Key) { TINY_Token Tok = new TINY_Token(); Tok.lex = Lex; Tok.token_type = Operators.ElementAt(i).Value; Tokens.Add(Tok); break; } } SyntaxAnalyser SA = new SyntaxAnalyser(); SA.Parse(Tokens); } else if (isIdentifier(Lex)) { TINY_Token Tok = new TINY_Token(); Tok.lex = Lex; Tok.token_type = TINY_Token_Class.Identifier; Tokens.Add(Tok); } else if (Lex == ";") { TINY_Token Tok = new TINY_Token(); Tok.lex = Lex; Tok.token_type = TINY_Token_Class.Semicolon; Tokens.Add(Tok); } else if (isstring(Lex)) { TINY_Token Tok = new TINY_Token(); Tok.lex = Lex; Tok.token_type = TINY_Token_Class.Stringstat; Tokens.Add(Tok); } else if (iscomment(Lex)) { TINY_Token Tok = new TINY_Token(); Tok.lex = Lex; Tok.token_type = TINY_Token_Class.Comment; Tokens.Add(Tok); } else if (isnumber(Lex)) { TINY_Token Tok = new TINY_Token(); Tok.lex = Lex; Tok.token_type = TINY_Token_Class.Number; Tokens.Add(Tok); } else { TINY_Token Tok = new TINY_Token(); Tok.lex = Lex; Errors.Error_List.Add(Tok.lex); } }