diff options
Removed old homeworks
9 files changed, 0 insertions, 206 deletions
| -rw-r--r-- | homework/81248/cToHtml/.gitignore | 3 | ||||
| -rw-r--r-- | homework/81248/cToHtml/README.md | 8 | ||||
| -rw-r--r-- | homework/81248/cToHtml/Setup.hs | 2 | ||||
| -rw-r--r-- | homework/81248/cToHtml/app/.Main.hs.swp | bin | 12288 -> 0 bytes | |||
| -rw-r--r-- | homework/81248/cToHtml/app/Main.hs | 29 | ||||
| -rw-r--r-- | homework/81248/cToHtml/package.yaml | 34 | ||||
| -rw-r--r-- | homework/81248/cToHtml/sample.c | 95 | ||||
| -rw-r--r-- | homework/81248/cToHtml/src/Html.hs | 30 | ||||
| -rw-r--r-- | homework/81248/cToHtml/stack.yaml | 5 |
diff --git a/homework/81248/cToHtml/.gitignore b/homework/81248/cToHtml/.gitignore deleted file mode 100644 index 37d0663..0000000 --- a/homework/81248/cToHtml/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.stack-work/ -cToHtml.cabal -*~
\ No newline at end of file diff --git a/homework/81248/cToHtml/README.md b/homework/81248/cToHtml/README.md deleted file mode 100644 index d56ce26..0000000 --- a/homework/81248/cToHtml/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# cToHtml - -При подаден C файл го конвертира до html файл, в който всичките литерали, -ключови думи и оператори са оцветени в някакъв подаден цвят. Мързеше ме да оцветявам -всичко различно, но принципно става много лесно. - -Не обработвам препроцесорски директиви (те не са част от езика) и коментари -(бих предположил, че препроцесорът ги маха и тях). diff --git a/homework/81248/cToHtml/Setup.hs b/homework/81248/cToHtml/Setup.hs deleted file mode 100644 index 9a994af..0000000 --- a/homework/81248/cToHtml/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/homework/81248/cToHtml/app/.Main.hs.swp b/homework/81248/cToHtml/app/.Main.hs.swp Binary files differdeleted file mode 100644 index d6ddc14..0000000 --- a/homework/81248/cToHtml/app/.Main.hs.swp +++ /dev/null diff --git a/homework/81248/cToHtml/app/Main.hs b/homework/81248/cToHtml/app/Main.hs deleted file mode 100644 index b504b82..0000000 --- a/homework/81248/cToHtml/app/Main.hs +++ /dev/null @@ -1,29 +0,0 @@ -module Main - ( main - ) where - -import qualified Data.ByteString as BS - -import System.Environment (getArgs) - -import Lucid (renderToFile) - -import Clex.Lex (lexC) -import Html (cToHtml) - -main :: IO () -main = do - xs <- getArgs - if length xs /= 3 - then putStrLn usage - else do - let [inFile, outFile, col] = xs - file <- BS.readFile inFile - renderToFile outFile $ cToHtml col $ either fail id $ lexC file - -usage :: String -usage = " \nUsage: cToHtml inFile.c outFile.html <colour>\n\ - \ Converts inFile.c to a colourised version in which all\n\ - \ keywords, identifiers and literals are coloured in <colour>.\n\ - \ We rely on <colour> working in a style tag.\n\ - \ (we basically set \"color:<colour>\" as a style)\n" diff --git a/homework/81248/cToHtml/package.yaml b/homework/81248/cToHtml/package.yaml deleted file mode 100644 index f34147c..0000000 --- a/homework/81248/cToHtml/package.yaml +++ /dev/null @@ -1,34 +0,0 @@ -name: cToHtml -version: 0.0.0.1 -author: "Georgi Lyubenov" -maintainer: "godzbanebane@gmail.com" - -description: Lex c using clex and then output coloured C. - -extra-source-files: -- README.md - -dependencies: -- base >= 4.7 && < 5 -- clex -- lucid -- bytestring -- text - -library: - source-dirs: src - -ghc-options: -- -Wall -- -Werror - -executables: - cToHtml: - main: Main.hs - source-dirs: app - ghc-options: - - -threaded - - -rtsopts - - -with-rtsopts=-N - dependencies: - - cToHtml diff --git a/homework/81248/cToHtml/sample.c b/homework/81248/cToHtml/sample.c deleted file mode 100644 index dad89ad..0000000 --- a/homework/81248/cToHtml/sample.c +++ /dev/null @@ -1,95 +0,0 @@ -float xs = 0.5e123213f; -float xss = .5f; - -typedef struct word_struct { - const char* begin; - int length; -} word; - -const word get_word(const char* begin){ - const char* current = begin; - short len = 0; - while( (*current != ' ') && (*current != 0) && (*current != '\n') ) { - current++; - len++; - } - word res = { - .begin = begin, - .length = len - }; - return res; -} - -void print_op(const char symb, FILE* file_write) { - fprintf(file_write, "%c", symb); -} - -const int single_char(char *line, int *count, FILE* file_write) { - char letter = *(line + *count); - switch(letter) { - case ';': print_op(';', file_write); return 1; - case '{': print_op('{', file_write); return 1; - case '}': print_op('}', file_write); return 1; - case ',': print_op(',', file_write); return 1; - case ':': print_op(':', file_write); return 1; - case '=': print_op('=', file_write); return 1; - case '(': print_op('(', file_write); return 1; - case ')': print_op(')', file_write); return 1; - case '[': print_op('[', file_write); return 1; - case ']': print_op(']', file_write); return 1; - case '.': print_op('.', file_write); return 1; - case '&': print_op('&', file_write); return 1; - case '!': print_op('!', file_write); return 1; - case '~': print_op('~', file_write); return 1; - case '-': print_op('-', file_write); return 1; - case '+': print_op('+', file_write); return 1; - case '*': print_op('*', file_write); return 1; - case '/': print_op('/', file_write); return 1; - case '%': print_op('%', file_write); return 1; - case '<': print_op('<', file_write); return 1; - case '>': print_op('>', file_write); return 1; - case '^': print_op('^', file_write); return 1; - case '|': print_op('|', file_write); return 1; - case '?': print_op('?', file_write); return 1; - default: print_op('n', file_write); return 1; - - } -} - -const int number(char *line, int *count, FILE* file_write){ - -} - -int main (void) { - - FILE *file_read; - FILE *file_write; - - file_read = fopen("example_code.c", "r"); - file_write = fopen("output", "w"); - - char *line = NULL; - size_t len = 0; - ssize_t nread; - printf("------------------------------\n\tWRITING\n------------------------------\n"); - while((nread = getline(&line, &len, file_read)) != -1) { - int counter = 0; - while(*(line + counter) != 0 ) { - if(*(line+counter) == '\n') { - print_op('\n', file_write); - } - if(single_char(line, &counter, file_write)) { - counter++; - continue; - } - if(number(line, &counter, file_write)) { - continue; - } - - - - } - } - - -} diff --git a/homework/81248/cToHtml/src/Html.hs b/homework/81248/cToHtml/src/Html.hs deleted file mode 100644 index 49c6eb1..0000000 --- a/homework/81248/cToHtml/src/Html.hs +++ /dev/null @@ -1,30 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE ExtendedDefaultRules #-} - -module Html - ( cToHtml - ) where - -import qualified Data.Text as T - -import Lucid - -import Clex.Types - -cToHtml :: String -> [Token] -> Html () -cToHtml col toks = pre_ $ foldMap (colourize col) toks - -colourize :: String -> Token -> Html () -colourize _ (Whitespace bs) = toHtmlRaw bs -colourize _ (HexNumber bs) = toHtml bs -colourize _ (OctNumber bs) = toHtml bs -colourize _ (Number bs) = toHtml bs -colourize _ (CharLit bs) = toHtml bs -colourize _ (Scientific bs) = toHtml bs -colourize _ (DotFloat bs) = toHtml bs -colourize _ (LeadingDot bs) = toHtml bs -colourize _ (StringLit bs) = toHtml bs -colourize _ (Identifier bs) = toHtml bs -colourize col x = span_ [style_ $ "color:" <> col'] $ toHtml $ tokenToBS x - where col' = T.pack col diff --git a/homework/81248/cToHtml/stack.yaml b/homework/81248/cToHtml/stack.yaml deleted file mode 100644 index 80ae9b2..0000000 --- a/homework/81248/cToHtml/stack.yaml +++ /dev/null @@ -1,5 +0,0 @@ -resolver: lts-12.13 - -packages: -- . -- ../clex |
