Generation code optmization.
[vutg.git] / src / vut_front_end.py
blob0a339c5e9c9fad0b11c5028d76ab5809dbd1e4ab
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 """
4 =======================================
5 module_name: vut_front_end
6 ---------------------------------------
7 Author: Rodrigo Peixoto
8 Data: 10/02/2008
9 ---------------------------------------
10 Description:
11 - This module runs all the gerenation
12 process.
13 =======================================
14 License: GPL
15 ======================================================================
17 This program is free software: you can redistribute it and/or modify
18 it under the terms of the GNU General Public License as published by
19 the Free Software Foundation, either version 3 of the License, or
20 (at your option) any later version.
22 This program is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 GNU General Public License for more details.
27 You should have received a copy of the GNU General Public License
28 along with this program. If not, see <http://www.gnu.org/licenses/>.
30 =======================================================================
31 """
32 from vut_checker import *
33 from vut_generator import *
34 from vut_parser import *
35 import sys
36 ARGS_CAN_BE = ['skel']
38 class InvalidArgumentException(Exception):
39 pass
41 def run_vut_generator(args=[]):
42 #arg = "example5.vut"
43 #args = sys.argv
44 gen_param = []
45 try:
47 if len(args) == 3:
48 if args[1] in ARGS_CAN_BE:
49 gen_param = args[1]
50 file_name = args[2]
51 else:
52 raise InvalidArgumentException()
54 elif (len(args) == 2):
55 file_name = args[1]
56 else:
57 raise InvalidArgumentException()
59 print "#################"
60 print "# @VUTGenerator #"
61 print "#################"
62 print "Phases: Check -> Parse -> Code Generation"
63 print "\nPHASE 1 [Check] --------------------------------------------\n"
64 VUTChercker(file_name).check_all()
65 print "\nPHASE 2 [Parse] --------------------------------------------\n"
66 vm = VUTParser(file_name).parse_all()
67 print "\nPHASE 3 [Code Generation] --------------------------------------------\n"
68 VUTGenerator(vm,gen_param).gen()
69 #VUTGenerator(vm).gen()
70 print u"\n\nGeneration complete @VUTGenerator."
72 except InvalidArgumentException:
73 print "The arguments are not valid. Please, check it out."
75 except KeyboardInterrupt:
76 print u"\n\nGeneration interrupted! @VUTGenerator."
78 if __name__=="__main__":
79 run_vut_generator(None,"skel","example5.vut")