forked from ksundberg/CS5300
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyntax_check.sh
More file actions
executable file
·32 lines (30 loc) · 1.04 KB
/
syntax_check.sh
File metadata and controls
executable file
·32 lines (30 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
# This script uses the CS6300 compiler (https://github.com/ksundberg/CS6300)
# to verify files are free of syntax errors.
DARK_GREY='\033[1;30m'
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m'
if [ -z $1 ]; then
echo "usage: syntax_check.sh pattern_for_test_files /path/to/compiler"
exit 1;
fi
filelist=($@)
echo -e "${DARK_GREY} ${#filelist[@]} file(s) being parsed${NC}"
mkdir parser_logs
mkdir asm_output
for ((i=0; i < ${#filelist[@]}-1; i++)); do
filepatharr=(${filelist[$i]//\// })
filename=${filepatharr[${#filepatharr[@]}-1]}
echo -e "${DARK_GREY}Parsing ${filelist[$i]}${NC}"
result="$(${@: -1} -i ${filelist[$i]} -o asm_output/${filename}.asm)"
echo "${result}" > parser_logs/${filename}_output.txt
if [[ $result == *"syntax error"* ]]; then
echo -e "${RED}Syntax errors in ${filename}${NC}"
elif [[ $result != "" ]]; then
echo -e "${YELLOW}Other compile time errors in ${filename}${NC}"
else
echo -e "${GREEN}Successfully compiled ${filename}${NC}"
fi
done