Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Implementation of Programming Languages / Homework 02 / lexer.sh
diff options
context:
space:
mode:
Commit7c8f2a8aa04603d5bc83441353184589640e8c41 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-11-08 19:45:50 +0200
Committer
 Syndamia <kamen@syndamia.com>
2022-11-08 19:45:50 +0200
Files7443dae4cc342e194c486aa964f3e15e18ae3265 /Year 2/Implementation of Programming Languages/Homework 02/lexer.sh
uni-projects-7c8f2a8aa04603d5bc83441353184589640e8c41.tar
uni-projects-7c8f2a8aa04603d5bc83441353184589640e8c41.tar.gz
uni-projects-7c8f2a8aa04603d5bc83441353184589640e8c41.zip
Parentd462bad3f4ed30d2c9e4562968a0b8a2ad9e3db7 (diff)
[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-xYear 2/Implementation of Programming Languages/Homework 02/lexer.sh40
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