Exemple #1
0
        public Analyzer(List<Token> tokenlist)
        {
            traceAnalyze= true;
            traceParse = true;
            parse = new Parser(tokenlist);
            program = null;
            program = parse.BuildSyntaxTree();
            program = program.Child[0];
               // symbolTab.initial();   // because symbolTab and FunArgs is static member,
               // FunArgs.initial();     // so, before use , should reset/initial them

            //symFile = filename;
            //int pos = symFile.rfind('.');
            //symFile.erase(pos, symFile.length()-1);
            //symFile += ".tab";	// symbol table file

            is_good_ = true;
            location = 0;      //  intial memory location
            err = 0;           // there are static member, should initial before use
            warn = 0;
        }
Exemple #2
0
 private void SyntaxAnalysis(object sender, ExecutedRoutedEventArgs e)
 {
     LexicalAnalysis(sender, e);
     Parser parser = new Parser(tokenlist);
     root = parser.BuildSyntaxTree();
     if (ErrorManager.ErrorList.Count == 0)
     {
         error.Visibility = Visibility.Collapsed;
         SyntaxTree syntaxTree = new SyntaxTree();
         syntaxTree.CreatSyntaxTree(root);
         syntaxTree.Show();
     }
     else
     {
         error.Visibility = Visibility.Visible;
         dg.Visibility = Visibility.Collapsed;
         error.ItemsSource = null;
         error.ItemsSource = ErrorManager.ErrorList;
     }
 }