summaryrefslogtreecommitdiff
path: root/tools/trace/tcreator/tcreator.py
blob: 45778acea0e25316fdb51a6c1545c57a6a6b1f23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import sys
from writer import *

try:
    from lib.parser import *
except:
    print "--> You should run yapps on lib/parser.g"

class TCreator:
    def __init__(self, infile):
        self.__infile = infile

    def create (self, outfile):
        infile = open (self.__infile, 'r')
        data = parse ('parser', infile.read())
        infile.close()
        w = Writer ()
        id_table = w.parse_event_identifiers (data)
        string_table = w.parse_event_string (data)
        string_table_nb = str (len (data))
        if outfile:
            w.write_file (id_table, string_table, string_table_nb)
        else:
            w.print_file (id_table, string_table, string_table_nb)