File mttroot/mtt/bin/trans/mtt_p2c artifact 23aaefc197 part of check-in f36162a6f1


#! /bin/sh


     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: mtt_p2c
# Pascal to c converter for MTT
# Uses the wonderful GNU p2c by  Dave Gillespie, daveg@csvax.cs.caltech.edu.    
# P.J.Gawthrop July 1998
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  1998/07/29 13:56:34  peterg
## Replces p2c include by local include.
##
## Revision 1.3  1998/07/27 20:32:51  peterg
## Now gives immediate warnings
##
## Revision 1.2  1998/07/25 16:35:43  peterg
## Sorted out log files etc
##
## Revision 1.1  1998/07/25 16:28:38  peterg
## Initial revision
##
###############################################################


# Options
info=''
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-I )
                info=info;
                ;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

# Inform user
echo Creating $1_$2.c

# Use p2c to do the translation 
p2c -V  $1_$2.p  | grep Warning # > mtt_p2c.log 2>> mtt_p2c.log
cat $1_$2.log >> mtt_p2c.log

# zap the PASCAL_MAIN which we don't want and change p2c.h include.
mv $1_$2.c mtt_junk1
grep -v 'PASCAL_MAIN'  < mtt_junk1 | grep -v 'p2c/p2c.h'> mtt_junk2

# pretty heading
DATE=`date`

cat <<EOF  >$1_$2.c
/* C program  $1_$2.c */
/* Generated by MTT on $DATE */

/* Compile with cc -lm $1_$2.c */

/* The following is the header file included here for completeness */
EOF

cat $MTTPATH/trans/c/p2c.h >> $1_$2.c

cat <<EOF >> $1_$2.c
/* End of the header file. */


EOF

cat mtt_junk2 >> $1_$2.c

if [ -n "$info" ]; then
    cat mtt_p2c.log
fi


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]