diff options
[IPL/HW02] Copied work from HW01, added a help message to lexer.sh, added left margin to pre tag
1 files changed, 40 insertions, 0 deletions
| -rwxr-xr-x | Year 2/Implementation of Programming Languages/Homework 02/lexer.sh | 40 |
diff --git a/Year 2/Implementation of Programming Languages/Homework 02/lexer.sh b/Year 2/Implementation of Programming Languages/Homework 02/lexer.sh new file mode 100755 index 0000000..5a07c15 --- /dev/null +++ b/Year 2/Implementation of Programming Languages/Homework 02/lexer.sh @@ -0,0 +1,40 @@ +#! /bin/bash + +if [ "$1" = "-h" ] || [ "$1" = "-?" ] || [ "$1" = "--help" ]; then + cat << EOF +lexer.sh [-h|-?|--help|-b|-r|-p] <OPTION> + +-h +-? +--help Brings up this help message + +-b <FILES> Puts <FILES> through flex and compiles with gcc + Outputed executable is "a.out" +-r <FILES> Runs <FILES> through compiled lexer and prints results + Expects "a.out" as the compiled lexer (in the current folder) +-p <FILES> Runs <FILES> through compiled lexer and creates webpage with highlighting + Expects "a.out" as the compiled lexer (in the current folder) + Webpage is always named "highlighted.html". It is created by putting lexer + output between "page_top.html" and "page_bottom.html" +EOF + exit +fi + +if [ "$1" = "-b" ]; then + shift + flex $@ + gcc lex.yy.c -lfl +fi + +if [ "$1" = "-r" ]; then + shift + ./a.out < $@ +fi + +if [ "$1" = "-p" ]; then + filename="highlighted.html" + cat ./page_top.html > $filename + shift + ./a.out < $@ >> $filename + cat ./page_bottom.html >> $filename +fi |
