diff options
[IPL/HW02] Replaced lexer.sh script with a Makefile
2 files changed, 31 insertions, 40 deletions
| -rw-r--r-- | Year 2/Implementation of Programming Languages/Homework 02/Makefile | 31 | ||||
| -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/Makefile b/Year 2/Implementation of Programming Languages/Homework 02/Makefile new file mode 100644 index 0000000..91f0182 --- /dev/null +++ b/Year 2/Implementation of Programming Languages/Homework 02/Makefile @@ -0,0 +1,31 @@ +in="example.lisp" +out="highlighted.html" + +CC=gcc +CFLAGS=-lfl -g +LEX=flex +YACC=bison -t -d + +.PHONY: all +all: build-all webpage + +.PHONY: webpage +webpage: + cat ./page_top.html > $(out) + ./a.out < $(in) >> $(out) + cat ./page_bottom.html >> $(out) + +build-all: build-bison build-flex + $(CC) lex.yy.c commonlisp2html.tab.c $(CFLAGS) + +.PHONY: build-flex +build-flex: commonlisp2html.l + $(LEX) commonlisp2html.l + +.PHONY: build-bison +build-bison: commonlisp2html.y + $(YACC) commonlisp2html.y + +.PHONY: clean +clean: + rm -f a.out *.tab.* lex.yy.c diff --git a/Year 2/Implementation of Programming Languages/Homework 02/lexer.sh b/Year 2/Implementation of Programming Languages/Homework 02/lexer.sh deleted file mode 100755 index 5a07c15..0000000 --- a/Year 2/Implementation of Programming Languages/Homework 02/lexer.sh +++ /dev/null @@ -1,40 +0,0 @@ -#! /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 |
