Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compare_compilers.sh script improvements #258

Merged
merged 9 commits into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
- uses: actions/checkout@v3
- run: sudo apt install -y llvm-13-dev clang-13 make valgrind
- run: LLVM_CONFIG=llvm-config-13 make
- run: ./tokenizers.sh
- run: ./compare_compilers.sh
4 changes: 2 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ jobs:
with:
name: windows-zip
- run: unzip jou.zip
- run: mv tokenizers.sh self_hosted jou
- run: mv compare_compilers.sh self_hosted jou
shell: bash
- run: (cd jou && ./tokenizers.sh)
- run: (cd jou && ./compare_compilers.sh)
shell: bash
36 changes: 28 additions & 8 deletions tokenizers.sh → compare_compilers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
# They should be able to tokenize each Jou file in exactly the same way.
# If tokenizing a Jou file fails, both tokenizers should fail with the same error message.

if [ $# = 0 ]; then
fix=no
elif [ $# = 1 ] && [ "$1" = --fix ]; then
fix=yes
else
echo "Usage: $0 [--fix]" >&2
exit 2
fi

if [[ "$OS" =~ Windows ]]; then
dotexe=.exe
else
Expand All @@ -26,21 +35,32 @@ for file in $(find examples tests -name '*.jou' | sort); do
if grep -qxF $file self_hosted/tokenizes_wrong.txt; then
# The file is skipped, so the two compilers should behave differently
if diff tmp/tokenizers/compiler_written_in_c.txt tmp/tokenizers/self_hosted.txt >/dev/null; then
echo " Error: Tokenizers behave the same even though the file is listed in self_hosted/tokenizes_wrong.txt."
echo " To fix this error, delete the \"$file\" line from self_hosted/tokenizes_wrong.txt."
#grep -vxF $file self_hosted/tokenizes_wrong.txt > /tmp/x; mv /tmp/x self_hosted/tokenizes_wrong.txt
exit 1
if [ $fix = yes ]; then
echo " Deleting $file from self_hosted/tokenizes_wrong.txt"
grep -vxF $file self_hosted/tokenizes_wrong.txt > tmp/tokenizers/newlist.txt
mv tmp/tokenizers/newlist.txt self_hosted/tokenizes_wrong.txt
else
echo " Error: Tokenizers behave the same even though the file is listed in self_hosted/tokenizes_wrong.txt."
echo " To fix this error, delete the \"$file\" line from self_hosted/tokenizes_wrong.txt (or run again with --fix)."
exit 1
fi
else
echo " Tokenizers behave differently as expected (listed in self_hosted/tokenizes_wrong.txt)"
fi
else
if diff -u --color=always tmp/tokenizers/compiler_written_in_c.txt tmp/tokenizers/self_hosted.txt; then
echo " Tokenizers behave the same as expected"
else
echo " Error: Tokenizers behave differently when given \"$file\"."
echo " You can silence this error by adding \"$file\" to self_hosted/tokenizes_wrong.txt."
echo " Ideally the tokenizers would behave in the same way for all files, but we aren't there yet."
exit 1
if [ $fix = yes ]; then
echo " Adding $file to self_hosted/tokenizes_wrong.txt"
echo $file >> self_hosted/tokenizes_wrong.txt
else
echo " Error: Tokenizers behave differently when given \"$file\"."
echo " Ideally the tokenizers would behave in the same way for all files, but we aren't there yet."
echo ""
Akuli marked this conversation as resolved.
Show resolved Hide resolved
echo " To silence this error, add \"$file\" to self_hosted/tokenizes_wrong.txt (or run again with --fix)."
exit 1
fi
fi
fi
done
Expand Down
52 changes: 26 additions & 26 deletions self_hosted/tokenizes_wrong.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
# This is a list of files that are not yet supported by the tokenizer of the self-hosted compiler.
examples/x11_window.jou
tests/syntax_error/hex.jou
tests/syntax_error/double_with_letters_after.jou
tests/syntax_error/dot_after_e.jou
tests/syntax_error/unnecessary_zero.jou
tests/syntax_error/bin.jou
tests/syntax_error/triple_equals.jou
tests/syntax_error/2bad.jou
tests/syntax_error/multidot_float.jou
tests/404/import_symbol_multiline.jou
tests/should_succeed/add_sub_mul_div_mod.jou
tests/should_succeed/array.jou
tests/should_succeed/as.jou
tests/should_succeed/expfloat.jou
tests/should_succeed/file.jou
tests/should_succeed/implicit_conversions.jou
tests/should_succeed/mathlibtest.jou
tests/should_succeed/octalnuber.jou
tests/should_succeed/printf.jou
tests/should_succeed/unused_import.jou
tests/syntax_error/0b2.jou
tests/syntax_error/ee.jou
tests/syntax_error/2bad.jou
tests/syntax_error/bad_byte.jou
tests/syntax_error/too_many_closing_parens.jou
tests/syntax_error/bin.jou
tests/syntax_error/dot_after_e.jou
tests/syntax_error/double_with_letters_after.jou
tests/syntax_error/ee.jou
tests/syntax_error/float.jou
tests/syntax_error/hex.jou
tests/syntax_error/mismatched_close_brace.jou
tests/syntax_error/missing_number_after_eminus.jou
tests/syntax_error/missing_number_after_e.jou
tests/syntax_error/float.jou
tests/syntax_error/missing_number_after_eminus.jou
tests/syntax_error/multidot_float.jou
tests/syntax_error/too_many_closing_parens.jou
tests/syntax_error/too_many_opening_parens.jou
tests/wrong_type/float_and_double.jou
tests/should_succeed/octalnuber.jou
tests/should_succeed/add_sub_mul_div_mod.jou
tests/should_succeed/printf.jou
tests/should_succeed/mathlibtest.jou
tests/should_succeed/file.jou
tests/should_succeed/expfloat.jou
tests/should_succeed/implicit_conversions.jou
tests/should_succeed/as.jou
tests/should_succeed/unused_import.jou
tests/should_succeed/array.jou
tests/404/import_symbol_multiline.jou
tests/syntax_error/triple_equals.jou
tests/syntax_error/unnecessary_zero.jou
tests/too_long/int.jou
tests/too_long/long.jou
tests/too_long/nested_parentheses.jou
tests/too_long/name.jou
tests/too_long/int.jou
tests/too_long/nested_parentheses.jou
tests/wrong_type/float_and_double.jou