5594 - rename 'desugar' to 'sigils'
There's going to be multiple forms of syntax sugar going forward.
This commit is contained in:
parent
a21fb73d04
commit
e97b446ac3
|
@ -1,33 +1,34 @@
|
|||
# Experimental syntax sugar for SubX programs.
|
||||
# Experimental syntax sugar for addressing modes that expand into /rm32 and
|
||||
# other related arguments.
|
||||
#
|
||||
# To run:
|
||||
# $ ./subx translate 0*.subx apps/subx-common.subx apps/desugar.subx -o apps/desugar
|
||||
# $ ./subx translate 0*.subx apps/subx-common.subx apps/sigils.subx -o apps/sigils
|
||||
#
|
||||
# We're experimenting with the following expressions:
|
||||
# We currently support the following notations:
|
||||
#
|
||||
# 1.
|
||||
# $ echo "ab %eax" | ./subx run apps/desugar
|
||||
# ab 3/mod 0/rm32
|
||||
# $ echo '%eax' | ./subx run apps/sigils
|
||||
# 3/mod 0/rm32
|
||||
#
|
||||
# 2.
|
||||
# $ echo "ab *eax" | ./subx run apps/desugar
|
||||
# ab 0/mod 0/rm32
|
||||
# $ echo '*eax' | ./subx run apps/sigils
|
||||
# 0/mod 0/rm32
|
||||
#
|
||||
# 3.
|
||||
# $ echo "ab *(eax+4)" | ./subx run apps/desugar
|
||||
# ab 2/mod 0/rm32 4/disp32
|
||||
# $ echo '*(eax+4)' | ./subx run apps/sigils
|
||||
# 2/mod 0/rm32 4/disp32
|
||||
#
|
||||
# 4.
|
||||
# $ echo "ab *(eax+ecx)" | ./subx run apps/desugar
|
||||
# ab 0/mod 4/rm32 0/base 1/index 0/scale
|
||||
# $ echo '*(eax+ecx)' | ./subx run apps/sigils
|
||||
# 0/mod 4/rm32 0/base 1/index 0/scale
|
||||
#
|
||||
# 5.
|
||||
# $ echo "ab *(eax+ecx+4)" | ./subx run apps/desugar
|
||||
# ab 2/mod 4/rm32 0/base 1/index 0/scale 4/disp32
|
||||
# $ echo '*(eax+ecx+4)' | ./subx run apps/sigils
|
||||
# 2/mod 4/rm32 0/base 1/index 0/scale 4/disp32
|
||||
#
|
||||
# 6.
|
||||
# $ echo "ab *(eax+ecx<<2+4)" | ./subx run apps/desugar
|
||||
# ab 2/mod 4/rm32 0/base 1/index 2/scale 4/disp32
|
||||
# $ echo '*(eax+ecx<<2+4)' | ./subx run apps/sigils
|
||||
# 2/mod 4/rm32 0/base 1/index 2/scale 4/disp32
|
||||
#
|
||||
# Addition isn't commutative here. Template must always be (base+index<<scale+disp),
|
||||
# though some components are optional as described above.
|
2
build
2
build
|
@ -140,7 +140,7 @@ then
|
|||
done
|
||||
|
||||
# higher-level syntax
|
||||
for phase in desugar
|
||||
for phase in sigils
|
||||
do
|
||||
older_than apps/$phase apps/$phase.subx apps/subx-common.subx [0-9]*.subx && {
|
||||
./subx_bin translate [0-9]*.subx apps/subx-common.subx apps/$phase.subx -o apps/$phase
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -15,9 +15,9 @@ set -e
|
|||
|
||||
./build
|
||||
|
||||
cat $* |apps/desugar > a.desugar
|
||||
cat $* |apps/sigils > a.sigils
|
||||
|
||||
cat a.desugar |apps/tests > a.tests
|
||||
cat a.sigils |apps/tests > a.tests
|
||||
|
||||
cat a.tests |apps/dquotes > a.dquotes
|
||||
|
||||
|
|
65
relayout
65
relayout
|
@ -1,65 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Helper to change the numerical prefixes across the repo, say if you want to
|
||||
# create room between 023 and 024, and so on.
|
||||
#
|
||||
# Assumes there's only ever one file with any numeric prefix. If you move
|
||||
# 003trace.test.cc you might need to do some manual patch-up.
|
||||
|
||||
set -e
|
||||
|
||||
if [[ $# -eq 0 && `git diff HEAD |wc -l` -gt 0 ]]
|
||||
then
|
||||
echo "Uncommitted changes"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ $# -gt 0 ]] # dry run
|
||||
then
|
||||
git() {
|
||||
echo $*
|
||||
}
|
||||
fi
|
||||
|
||||
#
|
||||
|
||||
index=0
|
||||
ls [0-9]*.{cc,subx} |grep -v "trace.test" |sort -n |
|
||||
while read file
|
||||
do
|
||||
while [[ $file != `printf "%03d" $index`* ]]
|
||||
do
|
||||
echo
|
||||
index=$(($index+1))
|
||||
done
|
||||
echo $file
|
||||
index=$(($index+1))
|
||||
done > .layout
|
||||
|
||||
vim -c "set nu" .layout
|
||||
|
||||
#
|
||||
|
||||
root() {
|
||||
echo $1 |sed 's/^[0-9]*//'
|
||||
}
|
||||
|
||||
index=0
|
||||
cat .layout |
|
||||
while read file
|
||||
do
|
||||
if [ ! -z $file ]
|
||||
then
|
||||
newfile=`printf "%03d" $index``root $file`
|
||||
if [[ $newfile != $file ]]
|
||||
then
|
||||
echo git mv $file $newfile
|
||||
git mv $file $newfile
|
||||
fi
|
||||
fi
|
||||
index=$(($index+1))
|
||||
done
|
||||
|
||||
rm .layout
|
||||
|
||||
# Scenarios considered:
|
||||
# Don't redo the layout if Vim exits with error.
|
12
test_apps
12
test_apps
|
@ -297,13 +297,13 @@ test $NATIVE && {
|
|||
|
||||
# Higher-level syntax.
|
||||
|
||||
echo desugar
|
||||
./subx translate 0*.subx apps/subx-common.subx apps/desugar.subx -o apps/desugar
|
||||
[ "$1" != record ] && git diff --exit-code apps/desugar
|
||||
./subx run apps/desugar test
|
||||
echo sigils
|
||||
./subx translate 0*.subx apps/subx-common.subx apps/sigils.subx -o apps/sigils
|
||||
[ "$1" != record ] && git diff --exit-code apps/sigils
|
||||
./subx run apps/sigils test
|
||||
echo
|
||||
test `uname` = 'Linux' && {
|
||||
apps/desugar test
|
||||
apps/sigils test
|
||||
echo
|
||||
}
|
||||
|
||||
|
@ -333,7 +333,7 @@ done
|
|||
|
||||
# Phases of the self-hosted SubX translator.
|
||||
|
||||
for app in hex survey pack assort dquotes tests desugar
|
||||
for app in hex survey pack assort dquotes tests sigils
|
||||
do
|
||||
echo $app
|
||||
./ntranslate 0*.subx apps/subx-common.subx apps/$app.subx
|
||||
|
|
|
@ -15,11 +15,11 @@ set -e
|
|||
|
||||
./build
|
||||
|
||||
echo " desugar"
|
||||
cat $* |./subx_bin run apps/desugar > a.desugar
|
||||
echo " sigils"
|
||||
cat $* |./subx_bin run apps/sigils > a.sigils
|
||||
|
||||
echo " tests"
|
||||
cat a.desugar |./subx_bin run apps/tests > a.tests
|
||||
cat a.sigils |./subx_bin run apps/tests > a.tests
|
||||
|
||||
echo " dquotes"
|
||||
cat a.tests |./subx_bin run apps/dquotes > a.dquotes
|
||||
|
|
Loading…
Reference in New Issue