2 # -*- coding: utf-8 -*-
4 =======================================
5 module_name: vut_front_end
6 ---------------------------------------
7 Author: Rodrigo Peixoto
9 ---------------------------------------
11 - This module runs all the gerenation
13 =======================================
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 =======================================================================
32 from vut_checker
import *
33 from vut_generator
import *
34 from vut_parser
import *
37 ARGS_CAN_BE
= ['skeleton','makefile']
39 def verify_parameters(params
):
41 executable_name
= params
[0]
46 aux
= param
.split('=')
47 ret
[aux
[0]]= aux
[1].split(',')
52 class InvalidArgumentException(Exception):
55 def run_vut_generator(args
=[]):
58 flags
= verify_parameters(args
)
64 file_name
= flags
['vut_file'][0]
66 raise InvalidArgumentException()
69 gen_param
= flags
['gen']
70 assert set(gen_param
).issubset(set(ARGS_CAN_BE
)), "Error, the gen's values are wrong!"
72 if lflags
== 2: raise InvalidArgumentException()
75 # if args[1] in ARGS_CAN_BE:
79 # raise InvalidArgumentException()
81 # elif (len(args) == 2):
84 # raise InvalidArgumentException()
86 print "#################"
87 print "# @VUTGenerator #"
88 print "#################"
89 print "Phases: Check -> Parse -> Code Generation"
90 print "\nPHASE 1 [Check] --------------------------------------------\n"
91 VUTChercker(file_name
).check_all()
92 print "\nPHASE 2 [Parse] --------------------------------------------\n"
93 vm
= VUTParser(file_name
).parse_all()
94 print "\nPHASE 3 [Code Generation] --------------------------------------------\n"
95 VUTGenerator(vm
,gen_param
).gen()
96 #VUTGenerator(vm).gen()
97 print u
"\n\nGeneration complete @VUTGenerator."
99 except InvalidArgumentException
:
100 print "The arguments are not valid. Please, check it out."
101 print "Usage: ./vutg gen=<item1>,<item2> vut_file=<file_name.vut>"
103 except KeyboardInterrupt:
104 print u
"\n\nGeneration interrupted! @VUTGenerator."
106 if __name__
=="__main__":
107 run_vut_generator("vutg gen=skeleton,makefile vu_file=example5.vut")