#!/usr/bin/python
# -*- coding: iso-8859-15 -*-

# Contractor, a contract validation tool
#    Copyright (C) 2008  Guido de Caso, Víctor Braberman, Diego Garbervetsky, Sebastián Uchitel
#    {gdecaso, vbraber, diegog, suchitel}@dc.uba.ar
#    LaFHIS - Departamento de Computación - Facultad de Ciencias Exactas y Naturales - Universidad de Buenos Aires
#    Pabellón I - Ciudad Universitaria - (C1428EGA) - Buenos Aires - Argentina
#    Tel: +54-11-4576-3390 eext. 704
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys
from options_parser import options
from contract_parser import *
from fsm import *
from state_builder import *
from transition_builder import *
from writer import *

contract = parse_contract(options)
if options.verbose:
	sys.stderr.write("CONTRACT:\n---------\n" + str(contract) + "\n")

fsm = FSM()
build_states(fsm, contract, options)
build_transitions(fsm, fsm.states, contract, options)
build_initial_state(fsm, contract, options)

if options.verbose:
	sys.stderr.write("FSM:\n----\n" + str(fsm) + "\n")

write_fsm(fsm, contract, options)
