File: TestParsers.cpp

package info (click to toggle)
vite 1.4-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,112 kB
  • sloc: cpp: 30,167; makefile: 467; sh: 233; python: 140; ansic: 67
file content (102 lines) | stat: -rw-r--r-- 2,613 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/**
 *
 * @file tests/trace/TestParsers.cpp
 *
 * @copyright 2008-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
 *                      Univ. Bordeaux. All rights reserved.
 *
 * @author Camille Ordronneau
 * @author Johnny Jazeix
 * @author Olivier Lagrasse
 * @author Mathieu Faverge
 *
 * @date 2024-07-17
 */

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <vector>
#include <list>
#include <map>

#include "trace/values/Values.hpp"
#include "trace/EntityValue.hpp"
#include "trace/EntityTypes.hpp"
#include "trace/Entitys.hpp"
#include "trace/Trace.hpp"
#include "parser/Parser.hpp"
#include "parser/ParserPaje.hpp"
#include "parser/ParserVite.hpp"


using namespace std;

int main(int argc, char **argv) {

    Parser          *parser = NULL;
    Trace           *trace = NULL;
    vector <string>  filenames;
    string           filename;
    unsigned int     idot; 

    if(argc < 2) {
        cerr << "Usage : " << argv[0]
             << " trace1 trace2 ..." << endl;
        return EXIT_FAILURE;
    }
    else {
        for (int i = 0 ; i < argc ; i ++) {
            filenames.push_back(argv[i]);
        }
    }

    for(int i = 1 ; i < argc ; i ++) {
	trace    = new Trace();
        filename = filenames[i];
        idot     = filename.find_last_of('.');

	std::cout << "Fichier : " << filename << std::endl; 

        if (idot != string::npos) {
            if(filename.substr(idot) == ".trace") {
		std::cout << "Parser  : Paje" << std::endl; 
                parser = new ParserPaje(filename);
            }
#ifdef WITH_OTF
            else if(filename.substr(idot) == ".otf") {
		std::cout << "Parser  : OTF" << std::endl; 
                parser = new ParserOTF(filename);
            }
#endif //WITH_OTF
#ifdef WITH_TAU
            else if(filename.substr(idot) == ".tau") {
		std::cout << "Parser  : TAU" << std::endl; 
                parser = new ParserTAU(filename);
            }
#endif //WITH_OTF
            else if(filename.substr(idot) == ".ept") {
		std::cout << "Parser  : ViTE" << std::endl; 
                parser = new ParserVite(filename);
            }
        }
        if(!parser) { // Default
            std::cout << "Parser  : Problem (Paje)" << std::endl; 
            parser = new ParserPaje(filename);
        }
        
        try {
            parser->parse(*trace);
        }
        catch (const std::string &error) {
            cout << error << "  " << filename << endl;
            parser->finish();
        }

        delete parser;
        parser = NULL;
        delete trace;
        trace = NULL;
    }
    return EXIT_SUCCESS;
}