Website Summary Files Commits Branches @commit @diff @stats
path: root / homework / 81319 / golang2html
diff options
context:
space:
mode:
Commitaeb0d4f887a0c18c36b59acc7b5df08e62020c50 (patch)
Author
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2020-10-11 21:32:48 +0300
Committer
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2020-10-11 21:33:38 +0300
Filesb6abdc6e1810326b587f2a160f39570f1f568f27 /homework/81319/golang2html
IPL-aeb0d4f887a0c18c36b59acc7b5df08e62020c50.tar
IPL-aeb0d4f887a0c18c36b59acc7b5df08e62020c50.tar.gz
IPL-aeb0d4f887a0c18c36b59acc7b5df08e62020c50.zip
Parent154b7cd30f21af1554ca26986ff1643e28857727 (diff)
Removed old homeworks
3 files changed, 0 insertions, 172 deletions
-rw-r--r--homework/81319/golang2html/README.md30
-rw-r--r--homework/81319/golang2html/golang2html.flex121
-rw-r--r--homework/81319/golang2html/hello_world.go21
diff --git a/homework/81319/golang2html/README.md b/homework/81319/golang2html/README.md
deleted file mode 100644
index 63c5f53..0000000
--- a/homework/81319/golang2html/README.md
+++ /dev/null
@@ -1,30 +0,0 @@
-# How-to guide
-
-## Compiling the highlighter
-
-1. Transpile flex file to c file
-```
-flex golang2html.flex
-```
-
-2. Compile the produced output file
-
-```
-gcc lex.yy.c -o lexer
-```
-
-The produced output is the 'lexer' file. You use it to highlight
-your own golang source files.
-
-## Highlighting Golang code
-
-1. Create your own golang source file with whatever name you wish. For
-this example, let your golang source be 'hello_world.go'.
-
-2. Produce the highlighted html output
-
-```
-./lexer hello_world.go > hello_world.html
-```
-
-## Enjoy
diff --git a/homework/81319/golang2html/golang2html.flex b/homework/81319/golang2html/golang2html.flex
deleted file mode 100644
index 9501645..0000000
--- a/homework/81319/golang2html/golang2html.flex
+++ /dev/null
@@ -1,121 +0,0 @@
-/* golang scanner */
-
-%{
-#define YY_NO_UNISTD_H
-%}
-
-DIGIT [0-9]
-ID [a-zA-Z_][a-zA-Z0-9_]*
-STRQ '([^\']|(\\\'))*'
-STRDQ \"([^\"]|(\\\"))*\"
-
-%%
-
-{DIGIT}+ {
- printf("<span class=\"number\">%s</span>", yytext);
- }
-
-{DIGIT}+"."{DIGIT}* {
- printf("<span class=\"number\">%s</span>", yytext);
- }
-
-break|default|func|interface|select|case|defer|go|map|struct {
- printf("<span class=\"keyword\">%s</span>", yytext);
-}
-
-chan|else|goto|package|switch|const|fallthrough|if|range|type|continue|for|import|return|var {
- printf("<span class=\"keyword\">%s</span>", yytext);
-}
-
-{ID} printf("<span class=\"identifier\">%s</span>", yytext);
-{STRQ}|{STRDQ} printf("<span class=\"string\">%s</span>", yytext);
-
-"+"|"&"|"+="|"&="|"&&"|"=="|"!="|"-"|"|"|"-="|"|="|"||"|"<" {
- printf("<span class=\"operator\">%s</span>", yytext);
-}
-
-"<="|"["|"]"|"*"|"^"|"*="|"^="|"<-"|">"|">="|"{"|"}"|"/"|"<<"|"/=" {
- printf("<span class=\"operator\">%s</span>", yytext);
-}
-
-"<<="|"++"|"="|":="|","|";"|"%"|">>"|"%="|">>="|"--"|"!"|"..."|"."|":"|"&^"|"&^=" {
- printf("<span class=\"operator\">%s</span>", yytext);
-}
-
-
-[;(){}? \t\n]+ printf("%s", yytext); /* echo the rest */
-
-. printf( "Unrecognized character: %s\n", yytext );
-
-%%
-
-int yywrap()
-{
- return 1;
-}
-
-void printStyles() {
- puts(
- " <style>"
- " .identifier {"
- " color: brown;"
- " }"
- " .keyword {"
- " color: #1fbfe2;"
- " }"
- " .number {"
- " color: blue;"
- " }"
- " .string {"
- " color: green;"
- " }"
- " .operator {"
- " color: #db184c;"
- " font-style: bold;"
- " }"
- " </style>"
- );
-}
-
-void printHtmlHeader() {
- puts(
- "<head>"
- " <title>hello_world.go</title>"
- );
- printStyles();
- puts(
- "</head>"
- );
-}
-
-void printBody() {
- puts(
- "<body bgcolor=\"#e2cdb7\">"
- " <pre class=\"code\">"
- );
- yylex();
- puts("</pre></body>");
-}
-
-
-void printHTML() {
- puts(
- "<!doctype>"
- "<html>"
- );
- printHtmlHeader();
- printBody();
- puts("</html>");
-}
-
-int main(int argc, const char* argv[])
-{
- ++argv, --argc; /* skip over program name */
- if ( argc > 0 )
- yyin = fopen( argv[0], "r" );
- else
- yyin = stdin;
-
- printHTML();
- return 0;
-}
diff --git a/homework/81319/golang2html/hello_world.go b/homework/81319/golang2html/hello_world.go
deleted file mode 100644
index 0a31497..0000000
--- a/homework/81319/golang2html/hello_world.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package main
-
-import (
- "fmt"
-)
-
-type HelloWorlder struct {
- message string
-}
-
-func (hw *HelloWorlder) greet() {
- fmt.Println(hw.message)
-}
-
-func main() {
- helloWorlder := &HelloWorlder{
- message: "Hello, world!",
- }
-
- helloWorlder.greet()
-} \ No newline at end of file