#!/bin/bash
#
# Script to run a pcom self compile
#
# First, change elide patterns to #ove prr file statements.
# The modified file goes in pcomm.pas (pcom modified).
#
sed -e 's/{elide}/{/g' -e 's/{noelide}/}/g' pcom.pas > pcomm.pas
#
# Compile pcom to intermediate code using its binary version.
#
echo Compiling pcom to intermediate code
./compile pcomm
cat pcomm.err
#
# Now run that code on the interpreter and have it compile itself
# to intermediate again.
#
echo Running pcom to compile itself
cp pcomm.pas pcomm.inp
./run pcomm
cat pcomm.lst
#
# Now we have the original intermediate from the binary version
# of pcom, and the intermediate generated by the interpreted
# pcom. Compare them for equality. Put the result in pcomm.dif.
#
echo Comparing the intermediate code for the runs
diffnole pcomm.p5 pcomm.out > pcomm.dif
#
# Show the file, so if the length is zero, it compared ok.
#
echo Resulting diff file length should be zero for pass
ls -l pcomm.dif
