You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
823 B
30 lines
823 B
#!/bin/bash
|
|
|
|
program=${1}
|
|
command=${2}
|
|
if [[ "x${program}" == "x" ]]; then
|
|
usage "${0} <program>.mn [lex|parse|run]"
|
|
exit 1
|
|
fi
|
|
if [[ "x${command}" == "x" ]]; then
|
|
command="run"
|
|
fi
|
|
|
|
if [[ "${command}" == "lex" ]]; then
|
|
./lexer.py ${program} | jq . > ${program}.tokens && cat ${program}.tokens
|
|
rm ${program}.tokens
|
|
exit 0
|
|
fi
|
|
if [[ "${command}" == "parse" ]]; then
|
|
./lexer.py ${program} | jq . > ${program}.tokens && ./parser.py ${program}.tokens | jq . > ${program}.ast && cat ${program}.ast
|
|
rm ${program}.tokens ${program}.ast
|
|
exit 0
|
|
fi
|
|
if [[ "${command}" == "run" ]]; then
|
|
./lexer.py ${program} | jq . > ${program}.tokens && ./parser.py ${program}.tokens | jq . > ${program}.ast && ./interpreter.py ${program}.ast
|
|
rm ${program}.tokens ${program}.ast
|
|
exit 0
|
|
fi
|
|
usage "${0} <program>.mn [lex|parse|run]"
|
|
exit 1
|