Use more verbose syntax error messages

Fixes #385
This commit is contained in:
Rangi
2021-01-10 14:48:48 -05:00
committed by Eldred Habert
parent 57b734a7df
commit eb4952c188
15 changed files with 232 additions and 130 deletions

View File

@@ -3,5 +3,5 @@ ERROR: anon-label-bad.asm(2):
ERROR: anon-label-bad.asm(6):
Reference to anonymous label 2 before, when only 1 has been created so far
ERROR: anon-label-bad.asm(18):
syntax error
syntax error, unexpected ':'
error: Assembly aborted (3 errors)!

View File

@@ -0,0 +1,7 @@
ERROR: anon-label-bad.asm(2):
Label "!0" created outside of a SECTION
ERROR: anon-label-bad.asm(6):
Reference to anonymous label 2 before, when only 1 has been created so far
ERROR: anon-label-bad.asm(18):
syntax error
error: Assembly aborted (3 errors)!

View File

@@ -1,5 +1,5 @@
ERROR: block-comment-termination-error.asm(1):
Unterminated block comment
ERROR: block-comment-termination-error.asm(1):
syntax error
syntax error, unexpected newline
error: Assembly aborted (2 errors)!

View File

@@ -0,0 +1,5 @@
ERROR: block-comment-termination-error.asm(1):
Unterminated block comment
ERROR: block-comment-termination-error.asm(1):
syntax error
error: Assembly aborted (2 errors)!

View File

@@ -1,7 +1,4 @@
ERROR: label-macro-arg.asm(38) -> label-macro-arg.asm::test_char(25):
Local label 'sizeof_.something' in main scope
syntax error, unexpected '='
while expanding symbol "VAR_DEF"
ERROR: label-macro-arg.asm(38) -> label-macro-arg.asm::test_char(25):
syntax error
while expanding symbol "VAR_DEF"
error: Assembly aborted (2 errors)!
error: Assembly aborted (1 errors)!

View File

@@ -0,0 +1,7 @@
ERROR: label-macro-arg.asm(38) -> label-macro-arg.asm::test_char(25):
Local label 'sizeof_.something' in main scope
while expanding symbol "VAR_DEF"
ERROR: label-macro-arg.asm(38) -> label-macro-arg.asm::test_char(25):
syntax error
while expanding symbol "VAR_DEF"
error: Assembly aborted (2 errors)!

View File

@@ -0,0 +1,2 @@
; The reported error here depends on Bison's parse.error flag.
print a

View File

@@ -0,0 +1,3 @@
ERROR: syntax-error.asm(2):
syntax error, unexpected 'a'
error: Assembly aborted (1 errors)!

View File

View File

@@ -0,0 +1,3 @@
ERROR: syntax-error.asm(2):
syntax error
error: Assembly aborted (1 errors)!

View File

@@ -47,13 +47,26 @@ warning: quote"file.asm(1): [-Wuser]
EOF
fi
# Check whether to use '.simple.err' files if they exist
# (rgbasm with pre-3.0 Bison just reports "syntax error")
../../rgbasm -Weverything -o $o syntax-error.asm > $output 2> $errput
cmp syntax-error.err $errput > /dev/null 2> /dev/null
simple_error=$?
if [ "$simple_error" -eq 1 ]; then
echo "${bold}${orange}Warning: using .simple.err files when available.${rescolors}${resbold}"
fi
for i in *.asm; do
for variant in '' '.pipe'; do
echo "${bold}${green}${i%.asm}${variant}...${rescolors}${resbold}"
desired_errname=${i%.asm}.err
if [ "$simple_error" -eq 1 ] && [ -e ${i%.asm}.simple.err ]; then
desired_errname=${i%.asm}.simple.err
fi
if [ -z "$variant" ]; then
../../rgbasm -Weverything -o $o $i > $output 2> $errput
desired_output=${i%.asm}.out
desired_errput=${i%.asm}.err
desired_errput=$desired_errname
else
# `include-recursion.asm` refers to its own name inside the test code.
# Skip testing with stdin input for that file.
@@ -74,7 +87,7 @@ for i in *.asm; do
subst="$(printf '%s\n' "$i" | sed 's:[][\/.^$*]:\\&:g')"
# Replace the file name with a dash to match changed output
sed "s/$subst/<stdin>/g" ${i%.asm}.out > $desired_output
sed "s/$subst/<stdin>/g" ${i%.asm}.err > $desired_errput
sed "s/$subst/<stdin>/g" $desired_errname > $desired_errput
fi
tryDiff $desired_output $output out