#! /usr/bin/env bash
##
## british_flavour.bash
## by lenorm_f
##
DEFINES=(
'announce echo'
'breathlessly -n'
'behaviour function'
'behave '
'perchance if'
'proceed then'
'otherwise else'
'equals -eq'
'how_about case'
'in_the_following in'
'splendid ;;'
'on_the_off_chance *)'
'thanks esac'
)
test $# -lt 1 && echo "Usage: $0 <file>" >&2 && exit 1
{
for i in "${DEFINES[@]}"; do
echo "#define ${i}"
done
grep -v '^#' "$1" \
| sed 's/£/\$/g' \
| sed -r 's/perhaps ([^\?]+)\??/\1\)/g'
} \
| cpp \
| egrep -v '^(#.*)?$'
################################## Example file ###################################
#! /usr/bin/env bash
behaviour main {
NAME='Cassie'
announce "Good morrow, fellow subjects of the Crown. My name is £{NAME}, nice to meet you."
GUESTS_NUMBER=£RANDOM
announce breathlessly "£GUESTS_NUMBER people ? "
perchance [ £((£GUESTS_NUMBER % 2)) equals 0 ]
proceed
announce "Looks like we have an even number of guests tonight"
otherwise
announce "I'm a bit supersticious, I don't really like having an odd number of guests at my table"
fi
how_about tea in_the_following
perhaps *tea* ?
announce "I would be thrilled to have a cup of tea"
splendid
on_the_off_chance
announce "Maybe later"
thanks
}
behave main