コード例 #1
0
ファイル: compile.cs プロジェクト: SKY142/crystal
 public compile(string input)
 {
     sample = new DFA();
     Semantic.MainSymbolTable = new globaldata();
     Semantic.ClassSymbolTable = new List<ClassT>();
     Semantic.errorlist = new List<string>();
     List<token> tokenSet = new List<token>();
     tokenSet = sample.LA(input);
     foreach (token s in tokenSet)
     {
         if (s.VP != " " && s.VP != "\n" && s.VP != "\t" && s.VP != "\r")
         {
             if (s.CP == s.VP)
             {
                 s.VP = "";
             }
             //Console.WriteLine("(" + s.CP + "," + s.VP + "," + s.line + ")");
             if (s.CP == "Lexical Error")
             {
                 lexErr += "(" + s.CP + "," + s.VP + "," + s.line + ")\n";
             }
             token temp = new token(s.line, s.VP, s.CP);
             this.token.Add(temp);
         }
     }
     cfg = new SyntaxAnalyzer(this.token);
     cfg.Analyze();
     if (lexErr != "")
     {
         Console.WriteLine(lexErr);
     }
     else
     {
         Console.WriteLine("Lexical Analyzer Success!!");
     }
     Console.WriteLine();
     string synErr = cfg.syntaxError();
     if(synErr != "")
     {
         Console.WriteLine(synErr);
     }
     else
     {
         Console.WriteLine("Syntax Analyzer Success!!");
     }
     Console.WriteLine();
     string SemErr = cfg.semanticError();
     if (SemErr != "")
     {
         Console.WriteLine("Semantic Errors :");
         Console.WriteLine(cfg.semanticError());
     }
     else
     {
         Console.WriteLine("Semantic Analyzer Success!!");
     }
     Console.WriteLine("\n\n\n\n###################### ICG Code ######################");
     Console.WriteLine(cfg.icgCode());
     checkmain();
 }
コード例 #2
0
ファイル: SyntaxAnalyzer.cs プロジェクト: SKY142/crystal
 public SyntaxAnalyzer(List<token> token)
 {
     this.syntaxtoken = token;
     token dollar = new token(-1,"$","$");
     syntaxtoken.Add(dollar);
 }