Website Summary Files Commits Branches @commit @diff @stats
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
IPL-aeb0d4f887a0c18c36b59acc7b5df08e62020c50.tar
IPL-aeb0d4f887a0c18c36b59acc7b5df08e62020c50.tar.gz
IPL-aeb0d4f887a0c18c36b59acc7b5df08e62020c50.zip
Parent154b7cd30f21af1554ca26986ff1643e28857727 (diff)
Removed old homeworks
289 files changed, 0 insertions, 37726 deletions
-rw-r--r--homework/45180/README.md19
-rw-r--r--homework/45180/hw1.html75
-rw-r--r--homework/45180/input.js51
-rw-r--r--homework/45180/lexer.go599
-rw-r--r--homework/45183/.gitignore6
-rw-r--r--homework/45183/CodeFormatting/README.md16
-rw-r--r--homework/45183/CodeFormatting/genie.lua25
-rw-r--r--homework/45183/CodeFormatting/input1.js127
-rw-r--r--homework/45183/CodeFormatting/input2.js71
-rw-r--r--homework/45183/CodeFormatting/input3.js9
-rw-r--r--homework/45183/CodeFormatting/input4.js1
-rw-r--r--homework/45183/CodeFormatting/main.cpp405
-rw-r--r--homework/45278/js2html/.gitignore334
-rw-r--r--homework/45278/js2html/js2html/Extensions/TokenizerExtensions.cs79
-rw-r--r--homework/45278/js2html/js2html/Models/Token.cs22
-rw-r--r--homework/45278/js2html/js2html/Models/TokenType.cs106
-rw-r--r--homework/45278/js2html/js2html/Program.cs29
-rw-r--r--homework/45278/js2html/js2html/Tokenizer.cs288
-rw-r--r--homework/45278/js2html/js2html/hello.html7
-rw-r--r--homework/45278/js2html/js2html/hello.js4
-rw-r--r--homework/45278/js2html/js2html/js2html.csproj14
-rw-r--r--homework/61984/HW3/main.cpp30
-rw-r--r--homework/81013/README.md1
-rw-r--r--homework/81013/go2html/CommonTypes.h37
-rw-r--r--homework/81013/go2html/Highlighter.cpp219
-rw-r--r--homework/81013/go2html/Highlighter.h8
-rw-r--r--homework/81013/go2html/Lexer.cpp668
-rw-r--r--homework/81013/go2html/Lexer.h125
-rw-r--r--homework/81013/go2html/README.md8
-rw-r--r--homework/81013/go2html/main.cpp19
-rw-r--r--homework/81013/go2html/premake5.lua22
-rw-r--r--homework/81013/go2html/sample.go308
-rw-r--r--homework/81030/1,2-rust2html/.gitignore5
-rw-r--r--homework/81030/1,2-rust2html/Makefile21
-rw-r--r--homework/81030/1,2-rust2html/README.md50
-rw-r--r--homework/81030/1,2-rust2html/example-chains.rs871
-rw-r--r--homework/81030/1,2-rust2html/example-ugly.rs29
-rw-r--r--homework/81030/1,2-rust2html/example.rs29
-rw-r--r--homework/81030/1,2-rust2html/rust2html-prettyprint.l344
-rw-r--r--homework/81030/1,2-rust2html/rust2html.l130
-rw-r--r--homework/81248/.gitignore3
-rw-r--r--homework/81248/README.md28
-rw-r--r--homework/81248/brainfsck/.gitignore3
-rw-r--r--homework/81248/brainfsck/README.md8
-rw-r--r--homework/81248/brainfsck/Setup.hs2
-rw-r--r--homework/81248/brainfsck/app/Main.hs21
-rw-r--r--homework/81248/brainfsck/asdf.bf2
-rw-r--r--homework/81248/brainfsck/package.yaml32
-rw-r--r--homework/81248/brainfsck/src/Brainfsck/Eval.hs35
-rw-r--r--homework/81248/brainfsck/src/Brainfsck/Parse.hs60
-rw-r--r--homework/81248/brainfsck/src/Brainfsck/Types.hs28
-rw-r--r--homework/81248/brainfsck/stack.yaml4
-rw-r--r--homework/81248/cToHtml/.gitignore3
-rw-r--r--homework/81248/cToHtml/README.md8
-rw-r--r--homework/81248/cToHtml/Setup.hs2
-rw-r--r--homework/81248/cToHtml/app/.Main.hs.swpbin12288 -> 0 bytes
-rw-r--r--homework/81248/cToHtml/app/Main.hs29
-rw-r--r--homework/81248/cToHtml/package.yaml34
-rw-r--r--homework/81248/cToHtml/sample.c95
-rw-r--r--homework/81248/cToHtml/src/Html.hs30
-rw-r--r--homework/81248/cToHtml/stack.yaml5
-rw-r--r--homework/81248/clex/.gitignore4
-rw-r--r--homework/81248/clex/Setup.hs2
-rw-r--r--homework/81248/clex/keyword-strings.txt76
-rw-r--r--homework/81248/clex/package.yaml33
-rw-r--r--homework/81248/clex/sample.c95
-rw-r--r--homework/81248/clex/src/Clex/Lex.hs181
-rw-r--r--homework/81248/clex/src/Clex/Types.hs377
-rw-r--r--homework/81248/clex/stack.yaml7
-rw-r--r--homework/81248/clex/test/Clex/LexSpec.hs58
-rw-r--r--homework/81248/clex/test/Clex/TypesSpec.hs177
-rw-r--r--homework/81248/clex/test/Spec.hs1
-rw-r--r--homework/81248/stack.yaml9
-rw-r--r--homework/81270/.gitignore2
-rw-r--r--homework/81270/CMakeLists.txt8
-rw-r--r--homework/81270/brainf-interpret/CMakeLists.txt4
-rw-r--r--homework/81270/brainf-interpret/Interpreter.cpp90
-rw-r--r--homework/81270/brainf-interpret/hello.b3
-rw-r--r--homework/81270/brainf-interpret/primes.b221
-rw-r--r--homework/81270/js2html/CMakeLists.txt17
-rw-r--r--homework/81270/js2html/Common.h18
-rw-r--r--homework/81270/js2html/Highlighter.cpp71
-rw-r--r--homework/81270/js2html/Highlighter.h24
-rw-r--r--homework/81270/js2html/README.md8
-rw-r--r--homework/81270/js2html/Token.cpp5
-rw-r--r--homework/81270/js2html/Token.h37
-rw-r--r--homework/81270/js2html/hello.js13
-rw-r--r--homework/81270/js2html/js2html.cpp2042
-rw-r--r--homework/81270/js2html/js2html.flex99
-rw-r--r--homework/81270/js2html/style.css31
-rw-r--r--homework/81281/README.md1
-rw-r--r--homework/81281/brainfsckInterpreter/README.md21
-rw-r--r--homework/81281/brainfsckInterpreter/brainySource.pl132
-rw-r--r--homework/81281/brainfsckInterpreter/interpreterMain.pl35
-rwxr-xr-xhomework/81281/brainfsckInterpreter/runMeChooseMode.sh15
-rw-r--r--homework/81281/brainfsckInterpreter/testPrograms/bigProgram.b32
-rw-r--r--homework/81281/brainfsckInterpreter/testPrograms/input.txt1
-rw-r--r--homework/81281/brainfsckInterpreter/testPrograms/pr.b21
-rw-r--r--homework/81281/brainfsckInterpreter/testPrograms/smallProgram.b33
-rw-r--r--homework/81281/c2html/README.md40
-rw-r--r--homework/81281/c2html/c2html.pl132
-rw-r--r--homework/81281/c2html/c2htmlrun.sh13
-rw-r--r--homework/81281/c2html/controlStructures.pl56
-rw-r--r--homework/81281/c2html/essentials.pl14
-rw-r--r--homework/81281/c2html/exampleCodeAndTestPage/initialTest.c99
-rw-r--r--homework/81281/c2html/exampleCodeAndTestPage/messyCode.c139
-rw-r--r--homework/81281/c2html/exampleCodeAndTestPage/page.html266
-rw-r--r--homework/81281/c2html/prettify.pl384
-rw-r--r--homework/81281/c2html/print.pl103
-rw-r--r--homework/81281/c2html/tokens.pl229
-rw-r--r--homework/81319/bfinterpreter/Makefile15
-rw-r--r--homework/81319/bfinterpreter/README.md19
-rw-r--r--homework/81319/bfinterpreter/bf/cell.go21
-rw-r--r--homework/81319/bfinterpreter/bf/interpreter.go189
-rw-r--r--homework/81319/bfinterpreter/bf/interpreter_test.go58
-rw-r--r--homework/81319/bfinterpreter/bf/mem.go40
-rw-r--r--homework/81319/bfinterpreter/bf/repl.go44
-rw-r--r--homework/81319/bfinterpreter/bf/tokenizer.go124
-rw-r--r--homework/81319/bfinterpreter/main.go8
-rwxr-xr-xhomework/81319/bfinterpreter/make_temp_folders.sh5
-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
-rw-r--r--homework/81319/golang2html_code_fold/Makefile15
-rw-r--r--homework/81319/golang2html_code_fold/README.md18
-rw-r--r--homework/81319/golang2html_code_fold/input.go21
-rw-r--r--homework/81319/golang2html_code_fold/lexer.lex100
-rw-r--r--homework/81319/golang2html_code_fold/lexer_code.c1953
-rw-r--r--homework/81319/golang2html_code_fold/output.html45
-rw-r--r--homework/81319/golang2html_code_fold/parser.output274
-rw-r--r--homework/81319/golang2html_code_fold/parser.tab.c1826
-rw-r--r--homework/81319/golang2html_code_fold/parser.tab.h84
-rw-r--r--homework/81319/golang2html_code_fold/parser.y243
-rwxr-xr-xhomework/81319/golang2html_code_fold/stylize.sh3
-rw-r--r--homework/81333/brainfsck/.gitignore3
-rw-r--r--homework/81333/brainfsck/ChangeLog.md3
-rw-r--r--homework/81333/brainfsck/LICENSE232
-rw-r--r--homework/81333/brainfsck/README.md28
-rw-r--r--homework/81333/brainfsck/Setup.hs2
-rw-r--r--homework/81333/brainfsck/app/Main.hs22
-rw-r--r--homework/81333/brainfsck/brainfsck.cabal74
-rw-r--r--homework/81333/brainfsck/examples/fact.bf42
-rw-r--r--homework/81333/brainfsck/examples/hello.bf3
-rw-r--r--homework/81333/brainfsck/examples/input.bf13
-rw-r--r--homework/81333/brainfsck/examples/pretty.bf31
-rw-r--r--homework/81333/brainfsck/examples/sierpinski.bf5
-rw-r--r--homework/81333/brainfsck/examples/squares.bf5
-rw-r--r--homework/81333/brainfsck/examples/sum.bf100
-rw-r--r--homework/81333/brainfsck/package.yaml51
-rw-r--r--homework/81333/brainfsck/src/Lib.hs30
-rw-r--r--homework/81333/brainfsck/src/Text/Brainfsck/Parser.hs56
-rw-r--r--homework/81333/brainfsck/src/Text/Brainfsck/Types.hs24
-rw-r--r--homework/81333/brainfsck/src/Text/Brainfsck/Util.hs10
-rw-r--r--homework/81333/brainfsck/stack.yaml64
-rw-r--r--homework/81333/brainfsck/test/Spec.hs2
-rw-r--r--homework/81333/golang-highlighter/.gitignore8
-rw-r--r--homework/81333/golang-highlighter/ChangeLog.md3
-rw-r--r--homework/81333/golang-highlighter/LICENSE30
-rw-r--r--homework/81333/golang-highlighter/README.md23
-rw-r--r--homework/81333/golang-highlighter/Setup.hs2
-rw-r--r--homework/81333/golang-highlighter/app/Main.hs16
-rw-r--r--homework/81333/golang-highlighter/package.yaml50
-rw-r--r--homework/81333/golang-highlighter/src/Data/Highlighter.hs54
-rw-r--r--homework/81333/golang-highlighter/src/Data/Lexer.hs89
-rw-r--r--homework/81333/golang-highlighter/src/Data/Maps.hs21
-rw-r--r--homework/81333/golang-highlighter/src/Data/Token.hs16
-rw-r--r--homework/81333/golang-highlighter/src/Data/TokenTypes.hs289
-rw-r--r--homework/81333/golang-highlighter/src/Data/Utils.hs124
-rw-r--r--homework/81333/golang-highlighter/src/Lib.hs11
-rw-r--r--homework/81333/golang-highlighter/stack.yaml65
-rw-r--r--homework/81333/golang-highlighter/test/Spec.hs2
-rw-r--r--homework/81350/brainfuck_interpreter/Makefile7
-rw-r--r--homework/81350/brainfuck_interpreter/README9
-rw-r--r--homework/81350/brainfuck_interpreter/input.file1
-rw-r--r--homework/81350/brainfuck_interpreter/interpreter.cpp77
-rw-r--r--homework/81350/parser/Makefile13
-rw-r--r--homework/81350/parser/colapser/Makefile13
-rw-r--r--homework/81350/parser/colapser/README13
-rw-r--r--homework/81350/parser/colapser/input.file13
-rw-r--r--homework/81350/parser/colapser/lexer.lex236
-rw-r--r--homework/81350/parser/colapser/parser.y1107
-rw-r--r--homework/81350/parser/colapser/stack.c56
-rw-r--r--homework/81350/parser/colapser/stack.h16
-rw-r--r--homework/81350/parser/input.file3
-rw-r--r--homework/81350/parser/lexer.lex182
-rw-r--r--homework/81350/parser/parser.y441
-rw-r--r--homework/81350/parser/stack.c46
-rw-r--r--homework/81350/parser/stack.h12
-rw-r--r--homework/81350/py2html/README12
-rw-r--r--homework/81350/py2html/Token.cpp39
-rw-r--r--homework/81350/py2html/Token.h52
-rwxr-xr-xhomework/81350/py2html/build_lexer.sh5
-rw-r--r--homework/81350/py2html/program.py10
-rw-r--r--homework/81350/py2html/py2html.cpp258
-rw-r--r--homework/81352/README.md4
-rw-r--r--homework/81352/gcd-hw3/README.md10
-rw-r--r--homework/81352/gcd-hw3/spgcd.txt16
-rw-r--r--homework/81352/ts2html-hw1/README.md13
-rw-r--r--homework/81352/ts2html-hw1/example.ts7
-rwxr-xr-xhomework/81352/ts2html-hw1/flex.sh5
-rw-r--r--homework/81352/ts2html-hw1/highlighter.cpp32
-rw-r--r--homework/81352/ts2html-hw1/highlighter.h17
-rw-r--r--homework/81352/ts2html-hw1/lex.yy.c2257
-rw-r--r--homework/81352/ts2html-hw1/token.cpp32
-rw-r--r--homework/81352/ts2html-hw1/token.h35
-rw-r--r--homework/81352/ts2html-hw1/ts2html.flex115
-rw-r--r--homework/81352/ts2html-hw2/Makefile12
-rw-r--r--homework/81352/ts2html-hw2/README.md19
-rw-r--r--homework/81352/ts2html-hw2/example.html15
-rw-r--r--homework/81352/ts2html-hw2/example.ts15
-rw-r--r--homework/81352/ts2html-hw2/lex.yy.c2019
-rwxr-xr-xhomework/81352/ts2html-hw2/parser.sh2
-rw-r--r--homework/81352/ts2html-hw2/parser.tab.c1551
-rw-r--r--homework/81352/ts2html-hw2/parser.tab.h77
-rw-r--r--homework/81352/ts2html-hw2/parser.y86
-rw-r--r--homework/81352/ts2html-hw2/ts2html.flex71
-rw-r--r--homework/81459/js2html/README.md9
-rw-r--r--homework/81459/js2html/highlight.js103
-rw-r--r--homework/81459/js2html/output.html74
-rw-r--r--homework/81459/js2html/testfile.js35
-rw-r--r--homework/81489/bf_interpreter/main.cpp68
-rw-r--r--homework/81498/.gitignore.txt334
-rw-r--r--homework/81498/Project/Wizard/Homeworks/WeekOne/BooleanOperatorsTokenTypes.cs29
-rw-r--r--homework/81498/Project/Wizard/Homeworks/WeekOne/Colour.cs19
-rw-r--r--homework/81498/Project/Wizard/Homeworks/WeekOne/TokenHandler.cs93
-rw-r--r--homework/81498/Project/Wizard/Misc/ExactMatchSymbolsToTokensMap.cs32
-rw-r--r--homework/81498/Project/Wizard/Misc/KeywordsToTokensMap.cs58
-rw-r--r--homework/81498/Project/Wizard/Misc/OperatorsToTokensMap.cs54
-rw-r--r--homework/81498/Project/Wizard/Program.cs42
-rw-r--r--homework/81498/Project/Wizard/Text files/simpleFunction.html1
-rw-r--r--homework/81498/Project/Wizard/Text files/simpleFunction.js6
-rw-r--r--homework/81498/Project/Wizard/Tokenizing/Lexer.cs428
-rw-r--r--homework/81498/Project/Wizard/Tokenizing/Token.cs33
-rw-r--r--homework/81498/Project/Wizard/Tokenizing/TokenTypeEnumerator.cs116
-rw-r--r--homework/81568/BF_Interpreter/CLI11.hpp4043
-rw-r--r--homework/81568/BF_Interpreter/Makefile2
-rw-r--r--homework/81568/BF_Interpreter/README.md40
-rw-r--r--homework/81568/BF_Interpreter/bf_interpreter.cpp114
-rw-r--r--homework/81568/BF_Interpreter/bf_interpreter.h33
-rw-r--r--homework/81568/BF_Interpreter/main.cpp68
-rw-r--r--homework/81568/c2html/.gitignore2
-rw-r--r--homework/81568/c2html/Makefile2
-rw-r--r--homework/81568/c2html/README.md8
-rw-r--r--homework/81568/c2html/cyclomatic.cpp95
-rw-r--r--homework/81568/c2html/cyclomatic.h19
-rw-r--r--homework/81568/c2html/html_utils.cpp87
-rw-r--r--homework/81568/c2html/html_utils.h18
-rw-r--r--homework/81568/c2html/lexcer.cpp327
-rw-r--r--homework/81568/c2html/lexcer.h76
-rw-r--r--homework/81568/c2html/lexconst.h42
-rw-r--r--homework/81568/c2html/main.cpp114
-rw-r--r--homework/81568/c2html/test.c114
-rw-r--r--homework/81568/c2html/test.html192
-rw-r--r--homework/81625/Brainfuck-Interpretator/README.md3
-rw-r--r--homework/81625/Brainfuck-Interpretator/src/BFI.cpp175
-rw-r--r--homework/81625/Brainfuck-Interpretator/src/BFI.h39
-rw-r--r--homework/81625/Brainfuck-Interpretator/src/main.cpp37
-rw-r--r--homework/81625/Brainfuck-Interpretator/src/run.sh3
-rw-r--r--homework/81625/cpp2html/.gitignore5
-rw-r--r--homework/81625/cpp2html/cpp2.html41
-rw-r--r--homework/81625/cpp2html/src/Lexer.cpp689
-rw-r--r--homework/81625/cpp2html/src/Lexer.h223
-rw-r--r--homework/81625/cpp2html/src/main.cpp107
-rw-r--r--homework/81709/.gitignore334
-rw-r--r--homework/81709/JSCompiler.Core.Tests/BaseInputStreamFileTests.cs117
-rw-r--r--homework/81709/JSCompiler.Core.Tests/JSCompiler.Core.Tests.csproj75
-rw-r--r--homework/81709/JSCompiler.Core.Tests/LexerTests.cs576
-rw-r--r--homework/81709/JSCompiler.Core.Tests/Properties/AssemblyInfo.cs20
-rw-r--r--homework/81709/JSCompiler.Core.Tests/packages.config5
-rw-r--r--homework/81709/JSCompiler.Core/BaseInputStream.cs91
-rw-r--r--homework/81709/JSCompiler.Core/IInputStream.cs17
-rw-r--r--homework/81709/JSCompiler.Core/JSCompiler.Core.csproj56
-rw-r--r--homework/81709/JSCompiler.Core/Lexer.cs276
-rw-r--r--homework/81709/JSCompiler.Core/NumToken.cs42
-rw-r--r--homework/81709/JSCompiler.Core/Properties/AssemblyInfo.cs36
-rw-r--r--homework/81709/JSCompiler.Core/ReservedStrings.cs82
-rw-r--r--homework/81709/JSCompiler.Core/Token.cs48
-rw-r--r--homework/81709/JSCompiler.Core/TokenType.cs134
-rw-r--r--homework/81709/JSCompiler.Core/Utils.cs41
-rw-r--r--homework/81709/JSCompiler.Core/WordToken.cs45
-rw-r--r--homework/81709/JSCompiler.SyntaxHighlighter/App.config6
-rw-r--r--homework/81709/JSCompiler.SyntaxHighlighter/JSCompiler.SyntaxHighlighter.csproj62
-rw-r--r--homework/81709/JSCompiler.SyntaxHighlighter/Program.cs36
-rw-r--r--homework/81709/JSCompiler.SyntaxHighlighter/Properties/AssemblyInfo.cs36
-rw-r--r--homework/81709/JSCompiler.SyntaxHighlighter/SyntaxHighlighter.cs187
-rw-r--r--homework/81709/JSCompiler.SyntaxHighlighter/test/test.js23
-rw-r--r--homework/81709/JSCompiler.SyntaxHighlighter/test/testout.html49
-rw-r--r--homework/81709/JSCompiler.sln42
-rw-r--r--homework/81709/README.md5
diff --git a/homework/45180/README.md b/homework/45180/README.md
deleted file mode 100644
index 3c56991..0000000
--- a/homework/45180/README.md
+++ /dev/null
@@ -1,19 +0,0 @@
-# Homework 1
-Create a xxx2html syntax highlighter for a language of your choice.
-
-### How to install and use the go toolchain
-
-+ [How to install the Go programming language](https://golang.org/doc/install)
-
---------------
-
-# Disclaimer
-
- - Written on my own, does not support comments (nor single line, neither multiline)
- - Parsing numbers is done in the most naive way possible. For example if the
- input is 2-3 it will be considered a single number.
-
-
-# Running the whole thing
-
-``` go run lexer.go ./ingput.hs > output.html ```
diff --git a/homework/45180/hw1.html b/homework/45180/hw1.html
deleted file mode 100644
index 74c7f4b..0000000
--- a/homework/45180/hw1.html
+++ /dev/null
@@ -1,75 +0,0 @@
-
-<!doctype>
-<html>
- <head>
- <style>
- .keyword {
- color: red;
- }
- .number {
- color: blue;
- }
- .string {
- color: green;
- }
- .operator {
- font-style: bold;
- }
- .identifier {
- color: orange;
- }
- </style>
- </head>
- <body>
- <pre class="code">
-<span class="keyword">export</span> <span class="keyword">default</span> <span class="keyword">class</span> <span class="identifier">Queue</span> {
- <span class="identifier">constructor</span>() {
- <span class="keyword">this</span>.<span class="identifier">_firstNode</span> <span class="operator">=</span> <span class="keyword">null</span>;
- <span class="keyword">this</span>.<span class="identifier">_lastNode</span> <span class="operator">=</span> <span class="keyword">null</span>;
- }
-
- <span class="identifier">dequeue</span>() {
- <span class="keyword">if</span> (<span class="operator">!</span><span class="keyword">this</span>.<span class="identifier">_firstNode</span>) {
- <span class="keyword">return</span> <span class="keyword">this</span>.<span class="identifier">_firstNode</span>;
- }
-
- <span class="keyword">const</span> <span class="identifier">payload</span> <span class="operator">=</span> <span class="keyword">this</span>.<span class="identifier">_firstNode</span>.<span class="identifier">payload</span>;
-
- <span class="keyword">this</span>.<span class="identifier">_firstNode</span> <span class="operator">=</span> <span class="keyword">this</span>.<span class="identifier">_firstNode</span>.<span class="identifier">next</span>;
-
- <span class="keyword">return</span> <span class="identifier">payload</span>;
- }
-
- <span class="identifier">enqueue</span>(<span class="identifier">item</span>) {
- <span class="keyword">const</span> <span class="identifier">newNode</span> <span class="operator">=</span> {
- <span class="identifier">payload</span>: <span class="identifier">item</span>,
- <span class="identifier">next</span>: <span class="keyword">null</span>
- };
-
- <span class="keyword">if</span> (<span class="keyword">this</span>.<span class="identifier">_firstNode</span> <span class="operator">===</span> <span class="keyword">null</span>) {
- <span class="keyword">this</span>.<span class="identifier">_firstNode</span> <span class="operator">=</span> <span class="identifier">newNode</span>;
- <span class="keyword">this</span>.<span class="identifier">_lastNode</span> <span class="operator">=</span> <span class="identifier">newNode</span>;
-
- } <span class="keyword">else</span> {
- <span class="keyword">this</span>.<span class="identifier">_lastNode</span>.<span class="identifier">next</span> <span class="operator">=</span> <span class="identifier">newNode</span>;
- <span class="keyword">this</span>.<span class="identifier">_lastNode</span> <span class="operator">=</span> <span class="identifier">newNode</span>;
- }
- }
-
- <span class="identifier">clear</span>() {
- <span class="keyword">this</span>.<span class="identifier">_firstNode</span> <span class="operator">=</span> <span class="keyword">null</span>;
- <span class="keyword">this</span>.<span class="identifier">_lastNode</span> <span class="operator">=</span> <span class="keyword">null</span>;
- }
-
- <span class="identifier">top</span>() {
- <span class="keyword">if</span> (<span class="operator">!</span><span class="keyword">this</span>.<span class="identifier">_firstNode</span>) {
- <span class="keyword">return</span> <span class="keyword">this</span>.<span class="identifier">_firstNode</span>;
- }
-
- <span class="keyword">return</span> <span class="keyword">this</span>.<span class="identifier">_firstNode</span>.<span class="identifier">payload</span>;
- }
-
- <span class="identifier">isEmpty</span>() {
- <span class="keyword">return</span> <span class="operator">!</span><span class="keyword">this</span>.<span class="identifier">_firstNode</span>;
- }
-}</pre></body></html> \ No newline at end of file
diff --git a/homework/45180/input.js b/homework/45180/input.js
deleted file mode 100644
index 6974019..0000000
--- a/homework/45180/input.js
+++ /dev/null
@@ -1,51 +0,0 @@
-export default class Queue {
- constructor() {
- this._firstNode = null;
- this._lastNode = null;
- }
-
- dequeue() {
- if (!this._firstNode) {
- return this._firstNode;
- }
-
- const payload = this._firstNode.payload;
-
- this._firstNode = this._firstNode.next;
-
- return payload;
- }
-
- enqueue(item) {
- const newNode = {
- payload: item,
- next: null
- };
-
- if (this._firstNode === null) {
- this._firstNode = newNode;
- this._lastNode = newNode;
-
- } else {
- this._lastNode.next = newNode;
- this._lastNode = newNode;
- }
- }
-
- clear() {
- this._firstNode = null;
- this._lastNode = null;
- }
-
- top() {
- if (!this._firstNode) {
- return this._firstNode;
- }
-
- return this._firstNode.payload;
- }
-
- isEmpty() {
- return !this._firstNode;
- }
-}
diff --git a/homework/45180/lexer.go b/homework/45180/lexer.go
deleted file mode 100644
index 9185462..0000000
--- a/homework/45180/lexer.go
+++ /dev/null
@@ -1,599 +0,0 @@
-package main
-
-import (
- "bufio"
- "errors"
- "fmt"
- "io"
- "os"
- "strings"
- "unicode"
-)
-
-const (
- // Single-character tokens.
- TokenLeftParen = iota
- TokenRightParen
- TokenLeftBrace
- TokenRightBrace
- TokenSemicolon
- TokenDot
- TokenComma
- TokenColon
- TokenQuestionmark
- TokenLeftSquareBracket
- TokenRightSquareBracket
- TokenMinus
- TokenPlus
- TokenStar
- TokenDivision
- TokenModulo
- TokenBitwiseNot
- TokenBitwiseAnd
- TokenBitwiseXor
- TokenBitwiseOr
-
- // One or two character tokens
- TokenBang
- TokenNotEqual
- TokenEqual
- TokenEqualEqual
- TokenStrictEqual
- TokenStrictNotEqual
- TokenGreater
- TokenGreaterEqual
- TokenLess
- TokenLessEqual
- TokenMinusMinus
- TokenPlusplus
- TokenLeftShift
- TokenRightShift
- TokenLogicalAnd
- TokenLogicalOr
- TokenStarEqual
- TokenDivideEqual
- TokenModuloEqual
- TokenPlusEqual
- TokenMinusEqual
- TokenLeftShiftEqual
- TokenRightShiftEqual
- TokenBitwiseAndEqual
- TokenBitwiseXorEqual
- TokenBitwiseOrEqual
-
- TokenString
- TokenNumber
- TokenKeyword
- TokenWhitespace
- TokenIdentifier
-
- TokenEOF
- TokenError
-)
-
-var keywords = map[string]struct{}{
- "break": {},
- "case": {},
- "catch": {},
- "class": {},
- "const": {},
- "continue": {},
- "debugger": {},
- "default": {},
- "delete": {},
- "do": {},
- "else": {},
- "export": {},
- "extends": {},
- "finally": {},
- "for": {},
- "function": {},
- "if": {},
- "import": {},
- "in": {},
- "instanceof": {},
- "new": {},
- "return": {},
- "super": {},
- "switch": {},
- "this": {},
- "throw": {},
- "try": {},
- "typeof": {},
- "var": {},
- "void": {},
- "while": {},
- "with": {},
- "yield": {},
- "null": {},
- "undefined": {},
- "true": {},
- "false": {},
-}
-
-var singleCharTokens = map[rune]struct{}{
- '(': {},
- ')': {},
- '[': {},
- ']': {},
- '{': {},
- '}': {},
- ',': {},
- '.': {},
- ';': {},
- '-': {},
- '+': {},
- '*': {},
- '/': {},
- '%': {},
- '~': {},
- '=': {},
- '!': {},
- '>': {},
- '<': {},
- '&': {},
- '|': {},
- '^': {},
- '?': {},
- ':': {},
-}
-
-type Token struct {
- TokenType int
- TokenValue string
- Err error
-}
-
-type Tokenizer interface {
- Tokenize(reader io.Reader, tokens chan Token)
-}
-
-type tokenizerImpl struct {
- emitWhitespace bool
-}
-
-func NewTokenizer(emitWhitespace bool) Tokenizer {
- return tokenizerImpl{emitWhitespace}
-}
-
-func (tokenizer tokenizerImpl) Tokenize(in io.Reader, tokens chan Token) {
- reader := bufio.NewReader(in)
- defer close(tokens)
- for {
- var symbol rune
- var err error
-
- if token := newToken(reader, readWhitespace); tokenizer.emitWhitespace {
- tokens <- token
- }
- if symbol, err = peek(reader); err != nil {
- var tokenType int
- if err == io.EOF {
- tokenType = TokenEOF
- } else {
- tokenType = TokenError
- }
- tokens <- Token{tokenType, "", err}
- return
- }
-
- if isSingleCharToken(symbol) {
- tokens <- newToken(reader, readSingleCharToken)
- continue
- } else {
- reader.UnreadRune()
- }
-
- if unicode.IsDigit(symbol) {
- tokens <- newToken(reader, readNumber)
- continue
- }
-
- if symbol == '"' {
- tokens <- newToken(reader, readString)
- continue
- }
-
- tokens <- newToken(reader, readKeywordOrIdentifier)
- }
-}
-
-func newToken(reader *bufio.Reader, tokenGenerator func(reader *bufio.Reader) (int, string, error)) Token {
- if tokenType, tokenValue, err := tokenGenerator(reader); err != nil {
- if err == io.EOF {
- tokenType = TokenEOF
- } else {
- tokenType = TokenError
- }
- return Token{tokenType, "", err}
- } else {
- return Token{tokenType, tokenValue, nil}
- }
-}
-
-func peek(reader *bufio.Reader) (rune, error) {
- symbol, _, err := reader.ReadRune()
- reader.UnreadRune()
- return symbol, err
-}
-
-func isWhitespace(r rune) bool {
- return r == ' ' || r == '\t' || r == '\n'
-}
-
-func readWhitespace(reader *bufio.Reader) (int, string, error) {
- var symbol rune
- var err error
- var sb strings.Builder
- for {
- if symbol, _, err = reader.ReadRune(); err == nil && isWhitespace(symbol) {
- sb.WriteRune(symbol)
- } else {
- break
- }
- }
- reader.UnreadRune()
- return TokenWhitespace, sb.String(), err
-}
-
-func isSingleCharToken(symbol rune) bool {
- _, isPresent := singleCharTokens[symbol]
- return isPresent
-}
-
-func readSingleCharToken(reader *bufio.Reader) (int, string, error) {
- var token int
- symbol, _, err := reader.ReadRune()
- tokenValue := string(symbol)
- switch symbol {
- case '(':
- token = TokenLeftParen
- break
- case ')':
- token = TokenRightParen
- break
- case '[':
- token = TokenLeftSquareBracket
- break
- case ']':
- token = TokenRightSquareBracket
- break
- case '{':
- token = TokenLeftBrace
- break
- case '}':
- token = TokenRightBrace
- break
- case ',':
- token = TokenComma
- break
- case '.':
- token = TokenDot
- break
- case ';':
- token = TokenSemicolon
- break
- case '-':
- token = TokenMinus
- if s, _, readErr := reader.ReadRune(); err != nil {
- err = readErr
- } else if s == '=' {
- token = TokenMinusEqual
- tokenValue = "-="
- } else if s == '-' {
- token = TokenMinusMinus
- tokenValue = "--"
- } else {
- reader.UnreadRune()
- }
- break
- case '+':
- token = TokenPlus
- if s, _, readErr := reader.ReadRune(); err != nil {
- err = readErr
- } else if s == '=' {
- token = TokenPlusEqual
- tokenValue = "+="
- } else if s == '+' {
- token = TokenPlusplus
- tokenValue = "++"
- } else {
- reader.UnreadRune()
- }
- break
- case '*':
- token = TokenStar
- if s, _, readErr := reader.ReadRune(); err != nil {
- err = readErr
- } else if s == '=' {
- token = TokenStarEqual
- tokenValue = "*="
- } else {
- reader.UnreadRune()
- }
- break
- case '/':
- token = TokenDivision
- if s, _, readErr := reader.ReadRune(); err != nil {
- err = readErr
- } else if s == '=' {
- token = TokenDivideEqual
- tokenValue = "/="
- } else {
- reader.UnreadRune()
- }
- break
- case '%':
- token = TokenModulo
- if s, _, readErr := reader.ReadRune(); err != nil {
- err = readErr
- } else if s == '=' {
- token = TokenModuloEqual
- tokenValue = "%="
- } else {
- reader.UnreadRune()
- }
- break
- case '~':
- token = TokenBitwiseNot
- break
- case '=':
- token = TokenEqual
- if s, _, readErr := reader.ReadRune(); err != nil {
- err = readErr
- } else if s == '=' {
- if s, _, readErr := reader.ReadRune(); err != nil {
- err = readErr
- } else if s == '=' {
- token = TokenStrictEqual
- tokenValue = "==="
- } else {
- token = TokenEqualEqual
- reader.UnreadRune()
- tokenValue = "=="
- }
- } else {
- reader.UnreadRune()
- }
- break
- case '!':
- token = TokenBang
- if s, _, readErr := reader.ReadRune(); err != nil {
- err = readErr
- } else if s == '=' {
- if s, _, readErr := reader.ReadRune(); err != nil {
- err = readErr
- } else if s == '=' {
- token = TokenStrictNotEqual
- tokenValue = "!==="
- } else {
- token = TokenNotEqual
- tokenValue = "!=="
- reader.UnreadRune()
- }
- } else {
- reader.UnreadRune()
- }
- break
- case '>':
- token = TokenGreater
- if s, _, readErr := reader.ReadRune(); err != nil {
- err = readErr
- } else if s == '=' {
- token = TokenGreaterEqual
- tokenValue = ">="
- } else if s == '>' {
- if s, _, readErr := reader.ReadRune(); err != nil {
- err = readErr
- } else if s == '=' {
- token = TokenRightShiftEqual
- tokenValue = ">>="
- } else {
- reader.UnreadRune()
- token = TokenRightShift
- tokenValue = ">>"
- }
- } else {
- reader.UnreadRune()
- }
- break
- case '<':
- token = TokenLess
- if s, _, readErr := reader.ReadRune(); err != nil {
- err = readErr
- } else if s == '=' {
- token = TokenLessEqual
- } else if s == '>' {
- if s, _, readErr := reader.ReadRune(); err != nil {
- err = readErr
- } else if s == '=' {
- token = TokenLeftShiftEqual
- tokenValue = "<<="
- } else {
- reader.UnreadRune()
- token = TokenLeftShift
- tokenValue = "<<"
- }
- } else {
- reader.UnreadRune()
- }
- break
- case '&':
- token = TokenBitwiseAnd
- if s, _, readErr := reader.ReadRune(); err != nil {
- err = readErr
- } else if s == '=' {
- token = TokenBitwiseAndEqual
- tokenValue = "&="
- } else if s == '&' {
- token = TokenLogicalAnd
- tokenValue = "&&"
- } else {
- reader.UnreadRune()
- }
- break
- case '|':
- token = TokenBitwiseOr
- if s, _, readErr := reader.ReadRune(); err != nil {
- err = readErr
- } else if s == '=' {
- token = TokenBitwiseOrEqual
- tokenValue = "|="
- } else if s == '|' {
- token = TokenLogicalOr
- tokenValue = "||"
- } else {
- reader.UnreadRune()
- }
- break
- case '^':
- token = TokenBitwiseXor
- if s, _, readErr := reader.ReadRune(); err != nil {
- err = readErr
- } else if s == '=' {
- token = TokenBitwiseXorEqual
- tokenValue = "^="
- } else {
- reader.UnreadRune()
- }
- break
- case '?':
- token = TokenQuestionmark
- break
- case ':':
- token = TokenColon
- break
- default:
- err = errors.New(fmt.Sprintf("Invalid token %s", symbol))
- token = TokenError
- }
- return token, tokenValue, err
-}
-
-func isKeyword(rawToken string) bool {
- _, isPresent := keywords[strings.ToLower(rawToken)]
- return isPresent
-}
-
-func isIdentifierOrKeywordSymbol(symbol rune) bool {
- return unicode.IsLetter(symbol) || unicode.IsDigit(symbol) || symbol == '_'
-}
-
-func readKeywordOrIdentifier(reader *bufio.Reader) (int, string, error) {
- var sb strings.Builder
- for {
- symbol, _, err := reader.ReadRune()
- if err != nil || isWhitespace(symbol) || !isIdentifierOrKeywordSymbol(symbol) {
- if err == nil {
- reader.UnreadRune()
- break
- }
- if err != io.EOF {
- return TokenError, "", err
- }
- if err == io.EOF {
- return TokenEOF, "", err
- }
- } else {
- sb.WriteRune(symbol)
- }
- }
- rawToken := sb.String()
- if isKeyword(rawToken) {
- return TokenKeyword, rawToken, nil
- } else {
- return TokenIdentifier, rawToken, nil
- }
-}
-
-func isNumberSymbol(symbol rune) bool {
- return unicode.IsDigit(symbol) || symbol == '.' || symbol == 'e' || symbol == '-'
-}
-
-// Obviously extremely naive and will most certainly not work correctly in anything but the
-// straightforward case. For example this fails epicly if we have an expression like
-// 2+3 which will be parsed as a valid single number.
-// TODO Address this nonsense.
-func readNumber(reader *bufio.Reader) (int, string, error) {
- var sb strings.Builder
- for {
- if symbol, _, err := reader.ReadRune(); err != nil || !isNumberSymbol(symbol) {
- reader.UnreadRune()
- return TokenNumber, sb.String(), err
- } else {
- sb.WriteRune(symbol)
- }
- }
-}
-
-func readString(reader *bufio.Reader) (int, string, error) {
- var sb strings.Builder
- openingQuote, _, err := reader.ReadRune()
- if err != nil {
- return TokenError, "", err
- }
- for {
- if symbol, _, err := reader.ReadRune(); err != nil {
- return TokenError, "", err
- } else if symbol == openingQuote {
- return TokenString, sb.String(), nil
- } else {
- sb.WriteRune(symbol)
- }
- }
-}
-
-func main() {
- file, _ := os.Open(os.Args[1])
- reader := bufio.NewReader(file)
-
- tokenChan := make(chan Token)
- go NewTokenizer(true).Tokenize(reader, tokenChan)
- fmt.Println(`
-<!doctype>
-<html>
- <head>
- <style>
- .keyword {
- color: red;
- }
- .number {
- color: blue;
- }
- .string {
- color: green;
- }
- .operator {
- font-style: bold;
- }
- .identifier {
- color: orange;
- }
- </style>
- </head>
- <body>
- <pre class="code">`)
-
- for token := range tokenChan {
- if token.TokenType >= TokenMinus && token.TokenType <= TokenBitwiseOrEqual {
- outputToken("operator", token.TokenValue)
- } else if token.TokenType == TokenString {
- outputToken("string", token.TokenValue)
- } else if token.TokenType == TokenKeyword {
- outputToken("keyword", token.TokenValue)
- } else if token.TokenType == TokenNumber {
- outputToken("number", token.TokenValue)
- } else if token.TokenType == TokenIdentifier {
- outputToken("identifier", token.TokenValue)
- } else {
- fmt.Print(token.TokenValue)
- }
- }
-
- fmt.Print("</pre></body></html>")
- file.Close()
-}
-
-func outputToken(tokenType, tokenValue string) {
- fmt.Print(fmt.Sprintf("<span class=\"%s\">%s</span>", tokenType, tokenValue))
-}
diff --git a/homework/45183/.gitignore b/homework/45183/.gitignore
deleted file mode 100644
index 1a084de..0000000
--- a/homework/45183/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-build
-**/.vs
-**/*.user
-**/x64
-**/Debug
-**/Release \ No newline at end of file
diff --git a/homework/45183/CodeFormatting/README.md b/homework/45183/CodeFormatting/README.md
deleted file mode 100644
index 51e8155..0000000
--- a/homework/45183/CodeFormatting/README.md
+++ /dev/null
@@ -1,16 +0,0 @@
-# Overview
-The code here takes `.js` files as input and produces color formatted JavaScript code in an `.html` file.
-
-# Prerequisites
-* Windows OS
-* VisualStudio 2015 or 2017
-
-# How to use
-* Download GENie from https://github.com/bkaradzic/GENie
-* Execute `./genie.exe vs2017` to generate a Visual Studio 2017 project.
-* Open the solution to Build and Run.
-* The output files should be created in the same folder as the `.js` files and they should open in your browser.
-
-# Known issues
-* Lexer can't parse RegExp.
-* Lexer can't parse Template literals. \ No newline at end of file
diff --git a/homework/45183/CodeFormatting/genie.lua b/homework/45183/CodeFormatting/genie.lua
deleted file mode 100644
index 74b3734..0000000
--- a/homework/45183/CodeFormatting/genie.lua
+++ /dev/null
@@ -1,25 +0,0 @@
-PROJ_DIR = path.getabsolute(".")
-
-solution 'CodeFormatting'
- configurations { 'Debug' }
- configuration 'Windows'
- flags {
- 'FatalWarnings',
- 'ExtraWarnings',
- 'Symbols',
- 'FullSymbols'
- }
- startproject 'CodeFormatting'
-
-configuration 'Debug'
- targetdir(path.join(PROJ_DIR, 'bin', 'debug'))
- objdir(path.join(PROJ_DIR, 'bin', 'debug'))
-
-project 'CodeFormatting'
- kind 'ConsoleApp'
- language 'C++'
- files {
- path.join(PROJ_DIR, "main.cpp"),
- path.join(PROJ_DIR, "..", "..", "..", "JSImpl", "src", "Lexer.h"),
- path.join(PROJ_DIR, "..", "..", "..", "JSImpl", "src", "Lexer.cpp")
- } \ No newline at end of file
diff --git a/homework/45183/CodeFormatting/input1.js b/homework/45183/CodeFormatting/input1.js
deleted file mode 100644
index 1c241e4..0000000
--- a/homework/45183/CodeFormatting/input1.js
+++ /dev/null
@@ -1,127 +0,0 @@
-true;
-false;
-undefined;
-null;
-
-import CoherentUtilities from "../CoherentUtilities";
-import Select from "../components/Select/Select";
-import { SUPPORTED_UNIT_TYPES } from './UnitTypes';
-
-const DEFAULT_OPTION = Object.freeze({
- value: 'default',
- displayed: 'Use default units'
-});
-
-const SUPPORTED_UNIT_TYPES_POSITIONS = Object.assign([], SUPPORTED_UNIT_TYPES);
-SUPPORTED_UNIT_TYPES_POSITIONS.push(DEFAULT_OPTION);
-Object.freeze(SUPPORTED_UNIT_TYPES_POSITIONS);
-
-const SUPPORTED_UNITS_TYPE_FONT_SIZE = Object.assign([], SUPPORTED_UNIT_TYPES_POSITIONS);
-for (let i = 0; i < SUPPORTED_UNITS_TYPE_FONT_SIZE.length; ++i) {
- if (SUPPORTED_UNITS_TYPE_FONT_SIZE[i].value === 'percents') {
- SUPPORTED_UNITS_TYPE_FONT_SIZE.splice(i, 1);
- break;
- }
-}
-Object.freeze(SUPPORTED_UNITS_TYPE_FONT_SIZE);
-
-const AUTO_OPTION = Object.freeze({
- value: 'auto',
- displayed: 'auto'
-});
-
-const SUPPORTED_UNITS_TYPE_DIMENSIONS = Object.assign([], SUPPORTED_UNIT_TYPES);
-SUPPORTED_UNITS_TYPE_DIMENSIONS.push(AUTO_OPTION);
-SUPPORTED_UNITS_TYPE_DIMENSIONS.push(DEFAULT_OPTION);
-Object.freeze(SUPPORTED_UNITS_TYPE_DIMENSIONS);
-
-const DEFAULT_UNIT_SELECTION_INDEX = SUPPORTED_UNIT_TYPES_POSITIONS.length - 1;
-const DEFAULT_UNITS_SELECTION_VALUE = SUPPORTED_UNIT_TYPES_POSITIONS[DEFAULT_UNIT_SELECTION_INDEX].value;
-
-const UNITS_SELECT_CONFIGURATIONS = Object.freeze({
- WIDTH: Object.freeze({
- sSelector: '#widthUnits',
- aOptionObj: SUPPORTED_UNITS_TYPE_DIMENSIONS,
- nSelected: DEFAULT_UNIT_SELECTION_INDEX
- }),
- HEIGHT: Object.freeze({
- sSelector: '#heightUnits',
- aOptionObj: SUPPORTED_UNITS_TYPE_DIMENSIONS,
- nSelected: DEFAULT_UNIT_SELECTION_INDEX
- }),
- TOP: Object.freeze({
- sSelector: '#topUnits',
- aOptionObj: SUPPORTED_UNIT_TYPES_POSITIONS,
- nSelected: DEFAULT_UNIT_SELECTION_INDEX
- }),
- LEFT: Object.freeze({
- sSelector: '#leftUnits',
- aOptionObj: SUPPORTED_UNIT_TYPES_POSITIONS,
- nSelected: DEFAULT_UNIT_SELECTION_INDEX
- }),
- FONTSIZE: Object.freeze({
- sSelector: '#fontSizeUnits',
- aOptionObj: SUPPORTED_UNITS_TYPE_FONT_SIZE,
- nSelected: 0
- })
-});
-
-export default class UnitsTab {
- constructor() {
- /**
- * @type {Object.<string, Select>}
- */
- UnitsTab.units = {
- width: new Select(UNITS_SELECT_CONFIGURATIONS.WIDTH),
- height: new Select(UNITS_SELECT_CONFIGURATIONS.HEIGHT),
- top: new Select(UNITS_SELECT_CONFIGURATIONS.TOP),
- left: new Select(UNITS_SELECT_CONFIGURATIONS.LEFT),
- fontSize: new Select(UNITS_SELECT_CONFIGURATIONS.FONTSIZE)
- }
- UnitsTab.addEventHandlers();
- }
-
- /**
- * Sets all values of the Unit Selects and writes the new values to the current selection.
- *
- * @param {Object} metadata - UnitsTab types for some item.
- * @param {boolean} disable - Whether the units Select should be disabled.
- */
- static deserializeUnitsPrefs(metadata, disable) {
- const toWriteValues = [];
- const toWriteTypes = [];
-
- for (let unitsType in UnitsTab.units) {
- let metaValue = metadata.units[unitsType];
-
- // Backwards compatability.
- if (metaValue === '' || metaValue === undefined) {
- metaValue = DEFAULT_UNITS_SELECTION_VALUE;
- }
- if (metaValue === 'px') {
- metaValue = 'pixels';
- }
-
- UnitsTab.units[unitsType].setValue(metaValue, true);
- UnitsTab.units[unitsType].setDisabled(disable);
-
- toWriteValues.push(metaValue);
- toWriteTypes.push(unitsType);
- }
- }
-
- /**
- * Attaches a change event listener to each UnitsTab Select that writes
- * the new units type to the current selection.
- */
- static addEventHandlers() {
- for (let unitsType in UnitsTab.units) {
- UnitsTab.units[unitsType].addEventListener('change', event => {
- CoherentUtilities.fl_changeDataProperty(
- unitsType,
- "units",
- event.detail.value);
- });
- }
- }
-}
diff --git a/homework/45183/CodeFormatting/input2.js b/homework/45183/CodeFormatting/input2.js
deleted file mode 100644
index c1c377c..0000000
--- a/homework/45183/CodeFormatting/input2.js
+++ /dev/null
@@ -1,71 +0,0 @@
-export default class Queue {
- constructor() {
- this._firstNode = null;
- this._lastNode = null;
- }
-
- /**
- * Retrieves the first element in the queue.
- * It also removes it from the queue.
- * @returns {*}
- */
- dequeue() {
- if (!this._firstNode) {
- return this._firstNode;
- }
-
- const payload = this._firstNode.payload;
-
- this._firstNode = this._firstNode.next;
-
- return payload;
- }
-
- /**
- * Adds an item to the queue
- * @param {*} item
- */
- enqueue(item) {
- const newNode = {
- payload: item,
- next: null
- };
-
- if (this._firstNode === null) {
- this._firstNode = newNode;
- this._lastNode = newNode;
-
- } else {
- this._lastNode.next = newNode;
- this._lastNode = newNode;
- }
- }
-
- /**
- * Empties the queue
- */
- clear() {
- this._firstNode = null;
- this._lastNode = null;
- }
-
- /**
- * Gets the first element of the queue
- * @returns {*}
- */
- top() {
- if (!this._firstNode) {
- return this._firstNode;
- }
-
- return this._firstNode.payload;
- }
-
- /**
- * Checks whether the queue is empty or not
- * @returns {boolean}
- */
- isEmpty() {
- return !this._firstNode;
- }
-} \ No newline at end of file
diff --git a/homework/45183/CodeFormatting/input3.js b/homework/45183/CodeFormatting/input3.js
deleted file mode 100644
index 11de05a..0000000
--- a/homework/45183/CodeFormatting/input3.js
+++ /dev/null
@@ -1,9 +0,0 @@
-/**
- * @type {Object.<string, Select>}
- */
-
-if (1 < 2) {
- console.log(false);
-}
-
-console.log("<>"); \ No newline at end of file
diff --git a/homework/45183/CodeFormatting/input4.js b/homework/45183/CodeFormatting/input4.js
deleted file mode 100644
index 9c342c9..0000000
--- a/homework/45183/CodeFormatting/input4.js
+++ /dev/null
@@ -1 +0,0 @@
-/regexp/i \ No newline at end of file
diff --git a/homework/45183/CodeFormatting/main.cpp b/homework/45183/CodeFormatting/main.cpp
deleted file mode 100644
index 9498bff..0000000
--- a/homework/45183/CodeFormatting/main.cpp
+++ /dev/null
@@ -1,405 +0,0 @@
-#include "../../../JSImpl/src/Lexer.h"
-#include <Windows.h>
-#include <fstream>
-#include <iostream>
-#include <sstream>
-#include <cassert>
-
-// Theme
-#define IDENTIFIER_COLOR "#e2c071"
-#define SINGLE_KEYWORD_COLOR "#b9b8b9"
-#define KEYWORD_COLOR "#bd6fd6"
-#define OPERATOR_KEYWORD_COLOR "#5faee8"
-#define NUMBER_COLOR "#e2c071"
-#define STRING_COLOR "#8daf56"
-#define BACKGROUND_COLOR "#1e1e1e"
-#define COMMENT_COLOR "#5d6371"
-#define MISC_COLOR "#dd7076"
-#define BOLD "font-weight: bold;"
-
-void FormatCode(const IPLString& in, const IPLString& out);
-
-IPLString GetSolutionDir();
-IPLString GetInputCode(const IPLString& inputName);
-bool DumpFormattedCode(const IPLVector<Token>& tokens, const IPLString& outName);
-void PreviewFormattedCode(const IPLString& outName);
-
-void DumpFileBeginning(std::ofstream& out);
-void DumpTokens(std::ofstream& out, const IPLVector<Token>& tokens);
-void DumpFileEnd(std::ofstream& out);
-
-inline void DumpClassWithValue(std::ofstream& out, const IPLString& cssClass, const IPLString& lexeme);
-inline void DumpClassWithValue(std::ofstream& out, const IPLString& cssClass, double number);
-inline void DumpClassWithFormattedLexeme(std::ofstream& out, const IPLString& cssClass, const IPLString& lexeme);
-void DumpCompatibleHTML(std::ofstream& out, const IPLString& text);
-
-inline void DumpOperatorKeyword(std::ofstream& out, const Token& token);
-inline void DumpSingleKeyword(std::ofstream& out, const Token& token);
-inline void DumpKeyword(std::ofstream& out, const Token& token);
-inline void DumpString(std::ofstream& out, const Token& token);
-inline void DumpMisc(std::ofstream& out, const Token& token);
-inline void DumpNumber(std::ofstream& out, const Token& token);
-inline void DumpIdentifier(std::ofstream& out, const Token& token);
-inline void DumpComment(std::ofstream& out, const Token& token);
-
-int main()
-{
- const IPLVector<IPLString> inputs = { "input1.js","input2.js", "input3.js", "input4.js"};
- const IPLString outputFilePrefix = "output";
-
- for (std::size_t i = 0; i < inputs.size(); ++i)
- {
- FormatCode(inputs[i], outputFilePrefix + std::to_string(i + 1) + ".html");
- }
-
- return 0;
-}
-
-IPLString GetSolutionDir()
-{
- TCHAR* buffer = new TCHAR[MAX_PATH];
- int nSize = GetModuleFileName(NULL, buffer, MAX_PATH);
-
- if (nSize != 0)
- {
- IPLString ret(buffer);
- delete[] buffer;
-
- auto dirDelim = ret.rfind("\\bin");
-
- if (dirDelim != IPLString::npos)
- {
- ret.resize(dirDelim + 1);
- return ret;
- }
- }
-
- return IPLString();
-}
-
-IPLString GetInputCode(const IPLString& inputName)
-{
- auto dir = GetSolutionDir();
- if (!dir.empty())
- {
- std::ifstream input(dir + inputName);
- if (input.good())
- {
- std::stringstream buffer;
- buffer << input.rdbuf();
- input.close();
- return buffer.str();
- }
- }
-
- std::cerr << "Input file error.\n";
- return IPLString();
-}
-
-void DumpFileBeginning(std::ofstream& out)
-{
- out << "<html>\n\n"
- << "<head>\n"
- << "\t<style>\n"
- << "\t\tdiv {\n\t\t\twhite-space: pre-wrap;\n\t\t}\n\n"
- << "\t\tbody {\n"
- << "\t\t\tbackground-color: " << BACKGROUND_COLOR << ";\n"
- << "\t\t\tfont-size: 18px;\n"
- << "\t\t\tfont-family: 'Consolas';\n"
- << "\t\t}\n\n"
- << "\t\t.identifier {\n\t\t\tcolor: " << IDENTIFIER_COLOR << ";\n\t\t}\n\n"
- << "\t\t.single-keyword {\n\t\t\tcolor: " << SINGLE_KEYWORD_COLOR << ";\n\t\t}\n\n"
- << "\t\t.keyword {\n \t\t\tcolor: " << KEYWORD_COLOR << ";\n\t\t}\n\n"
- << "\t\t.operator-keyword {\n\t\t\tcolor: " << OPERATOR_KEYWORD_COLOR << "; " << BOLD << "\n\t\t}\n\n"
- << "\t\t.number {\n\t\t\tcolor: " << NUMBER_COLOR << ";\n\t\t}\n\n"
- << "\t\t.string {\n\t\t\tcolor: " << STRING_COLOR << ";\n\t\t}\n\n"
- << "\t\t.comment {\n\t\t\tcolor: " << COMMENT_COLOR << ";\n\t\t}\n\n"
- << "\t\t.misc {\n\t\t\tcolor: " << MISC_COLOR << ";\n\t\t}\n"
- << "\t</style>\n"
- << "</head>\n\n"
- << "<body>\n"
- << "\t<div id='text'></div>\n"
- << "\t<script>\n"
- << "\t\tdocument.getElementById('text').innerHTML = '";
-}
-
-void DumpFileEnd(std::ofstream& out)
-{
- out << "';\n"
- << "\t</script>\n"
- << "</body>\n\n"
- << "</html>";
-}
-
-void DumpCompatibleHTML(std::ofstream& out, const IPLString& text)
-{
- for (auto& ch : text)
- {
- if (ch == '\n')
- {
- out << "\\n";
- }
- else if (ch == '\t')
- {
- out << "\\t";
- }
- else if (ch == '<')
- {
- out << "&#60;";
- }
- else if (ch == '>')
- {
- out << "&#62;";
- }
- else
- {
- out << ch;
- }
- }
-}
-
-inline void DumpClassWithValue(std::ofstream& out, const IPLString& cssClass, const IPLString& lexeme)
-{
- out << "<span class=\"" << cssClass << "\">" << lexeme << "</span>";
-}
-
-inline void DumpClassWithValue(std::ofstream& out, const IPLString& cssClass, double number)
-{
- out << "<span class=\"" << cssClass << "\">" << number << "</span>";
-}
-
-inline void DumpClassWithFormattedLexeme(std::ofstream& out, const IPLString& cssClass, const IPLString& lexeme)
-{
- out << "<span class=\"" << cssClass << "\">";
- DumpCompatibleHTML(out, lexeme);
- out << "</span>";
-}
-
-inline void DumpComment(std::ofstream& out, const Token& token)
-{
- DumpClassWithFormattedLexeme(out, "comment", token.Lexeme);
-}
-
-inline void DumpIdentifier(std::ofstream& out, const Token& token)
-{
- DumpClassWithFormattedLexeme(out, "identifier", token.Lexeme);
-}
-
-inline void DumpNumber(std::ofstream& out, const Token& token)
-{
- DumpClassWithValue(out, "number", token.Number);
-}
-
-inline void DumpMisc(std::ofstream& out, const Token& token)
-{
- DumpClassWithValue(out, "misc", token.Lexeme);
-}
-
-inline void DumpString(std::ofstream& out, const Token& token)
-{
- auto str = token.Lexeme;
- str.insert(str.begin(), '\\');
- str.insert(str.end() - 1, '\\');
- DumpClassWithValue(out, "string", str);
-}
-
-inline void DumpKeyword(std::ofstream& out, const Token& token)
-{
- DumpClassWithValue(out, "keyword", token.Lexeme);
-}
-
-inline void DumpSingleKeyword(std::ofstream& out, const Token& token)
-{
- DumpClassWithValue(out, "single-keyword", token.Lexeme);
-}
-
-inline void DumpOperatorKeyword(std::ofstream& out, const Token& token)
-{
- DumpClassWithFormattedLexeme(out, "operator-keyword", token.Lexeme);
-}
-
-void DumpTokens(std::ofstream& out, const IPLVector<Token>& tokens)
-{
- for (auto& token : tokens)
- {
- assert(token.Type != TokenType::Invalid);
-
- switch (token.Type)
- {
- case TokenType::Comment:
- DumpComment(out, token);
- break;
- case TokenType::Whitespace:
- DumpCompatibleHTML(out, token.Lexeme);
- break;
- case TokenType::Identifier:
- DumpIdentifier(out, token);
- break;
- case TokenType::Null:
- case TokenType::Undefined:
- case TokenType::True:
- case TokenType::False:
- DumpMisc(out, token);
- break;
- case TokenType::Number:
- DumpNumber(out, token);
- break;
- case TokenType::String:
- DumpString(out, token);
- break;
- case TokenType::Break:
- case TokenType::Case:
- case TokenType::Catch:
- case TokenType::Class:
- case TokenType::Continue:
- case TokenType::Debugger:
- case TokenType::Default:
- case TokenType::Delete:
- case TokenType::Do:
- case TokenType::Else:
- case TokenType::Export:
- case TokenType::Extends:
- case TokenType::Finally:
- case TokenType::For:
- case TokenType::Function:
- case TokenType::If:
- case TokenType::Import:
- case TokenType::In:
- case TokenType::Instanceof:
- case TokenType::New:
- case TokenType::Return:
- case TokenType::Super:
- case TokenType::Switch:
- case TokenType::This:
- case TokenType::Throw:
- case TokenType::Try:
- case TokenType::Typeof:
- case TokenType::Void:
- case TokenType::While:
- case TokenType::With:
- case TokenType::Yield:
- case TokenType::Const:
- case TokenType::Var:
- case TokenType::Let:
- case TokenType::Dot:
- DumpKeyword(out, token);
- break;
- case TokenType::LeftParen:
- case TokenType::RightParen:
- case TokenType::LeftBrace:
- case TokenType::RightBrace:
- case TokenType::Comma:
- case TokenType::Semicolon:
- case TokenType::QuestionMark:
- case TokenType::Colon:
- case TokenType::LeftSquareBracket:
- case TokenType::RightSquareBracket:
- DumpSingleKeyword(out, token);
- break;
- case TokenType::PlusEqual:
- case TokenType::MinusEqual:
- case TokenType::Minus:
- case TokenType::Plus:
- case TokenType::Star:
- case TokenType::Division:
- case TokenType::Modulo:
- case TokenType::BitwiseNot:
- case TokenType::BitwiseAnd:
- case TokenType::BitwiseXor:
- case TokenType::BitwiseOr:
- case TokenType::Bang:
- case TokenType::BangEqual:
- case TokenType::Equal:
- case TokenType::EqualEqual:
- case TokenType::StrictEqual:
- case TokenType::StrictNotEqual:
- case TokenType::MinusMinus:
- case TokenType::PlusPlus:
- case TokenType::LogicalAnd:
- case TokenType::LogicalOr:
- case TokenType::StarEqual:
- case TokenType::DivideEqual:
- case TokenType::ModuloEqual:
- case TokenType::BitwiseAndEqual:
- case TokenType::BitwiseXorEqual:
- case TokenType::BitwiseOrEqual:
- case TokenType::Greater:
- case TokenType::GreaterEqual:
- case TokenType::LessEqual:
- case TokenType::Less:
- case TokenType::RightShift:
- case TokenType::LeftShift:
- case TokenType::LeftShiftEqual:
- case TokenType::RightShiftEqual:
- DumpOperatorKeyword(out, token);
- break;
- case TokenType::Eof:
- return;
- default:
- DumpMisc(out, token);
- break;
- }
- }
-}
-
-bool DumpFormattedCode(const IPLVector<Token>& tokens, const IPLString& outName)
-{
- auto dir = GetSolutionDir();
- if (!dir.empty())
- {
- std::ofstream out(dir + outName);
- if (out.good())
- {
- DumpFileBeginning(out);
- DumpTokens(out, tokens);
- DumpFileEnd(out);
- out.close();
- return true;
- }
- }
-
- std::cerr << "Output file error.\n";
- return false;
-}
-
-void PreviewFormattedCode(const IPLString& outName)
-{
- auto dir = GetSolutionDir();
- if (!dir.empty())
- {
- auto res = system((dir + outName).c_str());
- if (res == -1)
- {
- switch (errno)
- {
- case ENOENT:
- case E2BIG:
- case ENOEXEC:
- case ENOMEM:
- std::cerr << "Unable to preview output file.\n";
- default:
- break;
- }
- }
- }
-}
-
-void FormatCode(const IPLString& in, const IPLString& out)
-{
- IPLString code = GetInputCode(in);
- if (!code.empty())
- {
- IPLVector<Token> tokens;
- const auto& res = Tokenize(code.c_str(), tokens, { true, true });
- if (!res.IsSuccessful)
- {
- std::cerr << "Lexer error at row " << res.Error.Row << " column " << res.Error.Column << ": " << res.Error.What;
- return;
- }
-
- if (DumpFormattedCode(tokens, out))
- {
- PreviewFormattedCode(out);
- }
- }
-} \ No newline at end of file
diff --git a/homework/45278/js2html/.gitignore b/homework/45278/js2html/.gitignore
deleted file mode 100644
index f00a0eb..0000000
--- a/homework/45278/js2html/.gitignore
+++ /dev/null
@@ -1,334 +0,0 @@
-## Ignore Visual Studio temporary files, build results, and
-## files generated by popular Visual Studio add-ons.
-##
-## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
-
-# User-specific files
-*.rsuser
-*.suo
-*.user
-*.userosscache
-*.sln.docstates
-
-# User-specific files (MonoDevelop/Xamarin Studio)
-*.userprefs
-
-# Build results
-[Dd]ebug/
-[Dd]ebugPublic/
-[Rr]elease/
-[Rr]eleases/
-x64/
-x86/
-bld/
-[Bb]in/
-[Oo]bj/
-[Ll]og/
-
-# Visual Studio 2015/2017 cache/options directory
-.vs/
-# Uncomment if you have tasks that create the project's static files in wwwroot
-#wwwroot/
-
-# Visual Studio 2017 auto generated files
-Generated\ Files/
-
-# MSTest test Results
-[Tt]est[Rr]esult*/
-[Bb]uild[Ll]og.*
-
-# NUNIT
-*.VisualState.xml
-TestResult.xml
-
-# Build Results of an ATL Project
-[Dd]ebugPS/
-[Rr]eleasePS/
-dlldata.c
-
-# Benchmark Results
-BenchmarkDotNet.Artifacts/
-
-# .NET Core
-project.lock.json
-project.fragment.lock.json
-artifacts/
-
-# StyleCop
-StyleCopReport.xml
-
-# Files built by Visual Studio
-*_i.c
-*_p.c
-*_h.h
-*.ilk
-*.meta
-*.obj
-*.iobj
-*.pch
-*.pdb
-*.ipdb
-*.pgc
-*.pgd
-*.rsp
-*.sbr
-*.tlb
-*.tli
-*.tlh
-*.tmp
-*.tmp_proj
-*_wpftmp.csproj
-*.log
-*.vspscc
-*.vssscc
-.builds
-*.pidb
-*.svclog
-*.scc
-
-# Chutzpah Test files
-_Chutzpah*
-
-# Visual C++ cache files
-ipch/
-*.aps
-*.ncb
-*.opendb
-*.opensdf
-*.sdf
-*.cachefile
-*.VC.db
-*.VC.VC.opendb
-
-# Visual Studio profiler
-*.psess
-*.vsp
-*.vspx
-*.sap
-
-# Visual Studio Trace Files
-*.e2e
-
-# TFS 2012 Local Workspace
-$tf/
-
-# Guidance Automation Toolkit
-*.gpState
-
-# ReSharper is a .NET coding add-in
-_ReSharper*/
-*.[Rr]e[Ss]harper
-*.DotSettings.user
-
-# JustCode is a .NET coding add-in
-.JustCode
-
-# TeamCity is a build add-in
-_TeamCity*
-
-# DotCover is a Code Coverage Tool
-*.dotCover
-
-# AxoCover is a Code Coverage Tool
-.axoCover/*
-!.axoCover/settings.json
-
-# Visual Studio code coverage results
-*.coverage
-*.coveragexml
-
-# NCrunch
-_NCrunch_*
-.*crunch*.local.xml
-nCrunchTemp_*
-
-# MightyMoose
-*.mm.*
-AutoTest.Net/
-
-# Web workbench (sass)
-.sass-cache/
-
-# Installshield output folder
-[Ee]xpress/
-
-# DocProject is a documentation generator add-in
-DocProject/buildhelp/
-DocProject/Help/*.HxT
-DocProject/Help/*.HxC
-DocProject/Help/*.hhc
-DocProject/Help/*.hhk
-DocProject/Help/*.hhp
-DocProject/Help/Html2
-DocProject/Help/html
-
-# Click-Once directory
-publish/
-
-# Publish Web Output
-*.[Pp]ublish.xml
-*.azurePubxml
-# Note: Comment the next line if you want to checkin your web deploy settings,
-# but database connection strings (with potential passwords) will be unencrypted
-*.pubxml
-*.publishproj
-
-# Microsoft Azure Web App publish settings. Comment the next line if you want to
-# checkin your Azure Web App publish settings, but sensitive information contained
-# in these scripts will be unencrypted
-PublishScripts/
-
-# NuGet Packages
-*.nupkg
-# The packages folder can be ignored because of Package Restore
-**/[Pp]ackages/*
-# except build/, which is used as an MSBuild target.
-!**/[Pp]ackages/build/
-# Uncomment if necessary however generally it will be regenerated when needed
-#!**/[Pp]ackages/repositories.config
-# NuGet v3's project.json files produces more ignorable files
-*.nuget.props
-*.nuget.targets
-
-# Microsoft Azure Build Output
-csx/
-*.build.csdef
-
-# Microsoft Azure Emulator
-ecf/
-rcf/
-
-# Windows Store app package directories and files
-AppPackages/
-BundleArtifacts/
-Package.StoreAssociation.xml
-_pkginfo.txt
-*.appx
-
-# Visual Studio cache files
-# files ending in .cache can be ignored
-*.[Cc]ache
-# but keep track of directories ending in .cache
-!*.[Cc]ache/
-
-# Others
-ClientBin/
-~$*
-*~
-*.dbmdl
-*.dbproj.schemaview
-*.jfm
-*.pfx
-*.publishsettings
-orleans.codegen.cs
-
-# Including strong name files can present a security risk
-# (https://github.com/github/gitignore/pull/2483#issue-259490424)
-#*.snk
-
-# Since there are multiple workflows, uncomment next line to ignore bower_components
-# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
-#bower_components/
-
-# RIA/Silverlight projects
-Generated_Code/
-
-# Backup & report files from converting an old project file
-# to a newer Visual Studio version. Backup files are not needed,
-# because we have git ;-)
-_UpgradeReport_Files/
-Backup*/
-UpgradeLog*.XML
-UpgradeLog*.htm
-ServiceFabricBackup/
-*.rptproj.bak
-
-# SQL Server files
-*.mdf
-*.ldf
-*.ndf
-
-# Business Intelligence projects
-*.rdl.data
-*.bim.layout
-*.bim_*.settings
-*.rptproj.rsuser
-
-# Microsoft Fakes
-FakesAssemblies/
-
-# GhostDoc plugin setting file
-*.GhostDoc.xml
-
-# Node.js Tools for Visual Studio
-.ntvs_analysis.dat
-node_modules/
-
-# Visual Studio 6 build log
-*.plg
-
-# Visual Studio 6 workspace options file
-*.opt
-
-# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
-*.vbw
-
-# Visual Studio LightSwitch build output
-**/*.HTMLClient/GeneratedArtifacts
-**/*.DesktopClient/GeneratedArtifacts
-**/*.DesktopClient/ModelManifest.xml
-**/*.Server/GeneratedArtifacts
-**/*.Server/ModelManifest.xml
-_Pvt_Extensions
-
-# Paket dependency manager
-.paket/paket.exe
-paket-files/
-
-# FAKE - F# Make
-.fake/
-
-# JetBrains Rider
-.idea/
-*.sln.iml
-
-# CodeRush personal settings
-.cr/personal
-
-# Python Tools for Visual Studio (PTVS)
-__pycache__/
-*.pyc
-
-# Cake - Uncomment if you are using it
-# tools/**
-# !tools/packages.config
-
-# Tabs Studio
-*.tss
-
-# Telerik's JustMock configuration file
-*.jmconfig
-
-# BizTalk build output
-*.btp.cs
-*.btm.cs
-*.odx.cs
-*.xsd.cs
-
-# OpenCover UI analysis results
-OpenCover/
-
-# Azure Stream Analytics local run output
-ASALocalRun/
-
-# MSBuild Binary and Structured Log
-*.binlog
-
-# NVidia Nsight GPU debugger configuration file
-*.nvuser
-
-# MFractors (Xamarin productivity tool) working folder
-.mfractor/
-
-# Local History for Visual Studio
-.localhistory/ \ No newline at end of file
diff --git a/homework/45278/js2html/js2html/Extensions/TokenizerExtensions.cs b/homework/45278/js2html/js2html/Extensions/TokenizerExtensions.cs
deleted file mode 100644
index 1a9da1b..0000000
--- a/homework/45278/js2html/js2html/Extensions/TokenizerExtensions.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace js2html.Extensions
-{
- public static class TokenizerExtensions
- {
- public static IEnumerable<string> ParseHtml(this Tokenizer tokenizer)
- {
- var whitespace = string.Empty;
- foreach(var token in tokenizer.Tokens)
- {
- if (token.TokenType == Models.TokenType.Number)
- {
- var result = string.Format("<span class=\"number\">{0}{1}</span>", whitespace, token.Lexeme);
- whitespace = string.Empty;
- yield return result;
- }
- else if(token.TokenType == Models.TokenType.String)
- {
- var result = string.Format("<span class=\"string\" style=\"color:indianred\">{0}{1}</span>", whitespace, token.Lexeme);
- whitespace = string.Empty;
- yield return result;
- }
- else if (tokenizer.KeywordsTable.ContainsKey(token.Lexeme))
- {
- var result = string.Format("<span class=\"keyword\" style=\"color:blue\">{0}{1}</span>", whitespace, token.Lexeme);
- whitespace = string.Empty;
- yield return result;
- }
- else if (token.TokenType == Models.TokenType.Identifier)
- {
- var result = string.Format("<span class=\"identifier\">{0}{1}</span>", whitespace, token.Lexeme);
- whitespace = string.Empty;
- yield return result;
- }
- else if (token.TokenType == Models.TokenType.Whitespace)
- {
- if(whitespace != string.Empty)
- {
- var tempWhitespace = token.Lexeme.Replace(" ", "&nbsp;").Replace("\r\n", "<br>").Replace("\n","<br>").Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
- whitespace = whitespace + tempWhitespace;
- }
- else
- whitespace = token.Lexeme.Replace(" ", "&nbsp;").Replace("\r\n", "<br>").Replace("\n", "<br>").Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
- }
- else if (token.TokenType == Models.TokenType.Eof)
- yield return whitespace;
- else
- {
- //string result = "";
- //if (whitespace.Contains("<br>"))
- //{
- // result = string.Format("{0}<span class=\"operator\">{1}</span>", whitespace, token.Lexeme);
- //}
- //else
- var result = string.Format("<span class=\"operator\">{0}{1}</span>", whitespace, token.Lexeme);
- whitespace = string.Empty;
- yield return result;
- }
- }
- }
-
- //static private string BuildWhitespace(string lexeme)
- //{
- // StringBuilder result = new StringBuilder();
- // foreach(var c in lexeme)
- // {
- // if (c != '\n')
- // result.Append("&nbsp;");
- // else
- // result.Append("<br>");
- // }
-
- // return result.ToString();
- //}
- }
-}
diff --git a/homework/45278/js2html/js2html/Models/Token.cs b/homework/45278/js2html/js2html/Models/Token.cs
deleted file mode 100644
index a0204f3..0000000
--- a/homework/45278/js2html/js2html/Models/Token.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace js2html.Models
-{
- public class Token
- {
- public TokenType TokenType { get; set; }
- public int Line { get; set; }
- public string Lexeme { get; set; }
- public double NumericValue { get; set; }
-
- public Token(TokenType tokenType, int line, string lexeme = "", double numericValue = 0 )
- {
- TokenType = tokenType;
- Line = line;
- Lexeme = lexeme;
- NumericValue = numericValue;
- }
- }
-}
diff --git a/homework/45278/js2html/js2html/Models/TokenType.cs b/homework/45278/js2html/js2html/Models/TokenType.cs
deleted file mode 100644
index 13061e9..0000000
--- a/homework/45278/js2html/js2html/Models/TokenType.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace js2html.Models
-{
- public enum TokenType
- {
- // Single-character tokens.
- LeftParen,
- RightParen,
- LeftBrace,
- RightBrace,
- Comma,
- Dot,
- Minus,
- Plus,
- Semicolon,
- Star,
- Division,
- Modulo,
- BitwiseNot,
- BitwiseAnd,
- BitwiseXor,
- BitwiseOr,
- QuestionMark,
- Colon,
- LeftSquareBracket,
- RightSquareBracket,
-
- // One or two character tokens
- Bang,
- BangEqual,
- Equal,
- EqualEqual,
- StrictEqual,
- StrictNotEqual,
- Greater,
- GreaterEqual,
- Less,
- LessEqual,
- MinusMinus,
- PlusPlus,
- LeftShift,
- RightShift,
- LogicalAnd,
- LogicalOr,
- StarEqual,
- DivideEqual,
- ModuloEqual,
- PlusEqual,
- MinusEqual,
- LeftShiftEqual,
- RightShiftEqual,
- BitwiseAndEqual,
- BitwiseXorEqual,
- BitwiseOrEqual,
-
- Identifier,
- String,
- Number,
-
- // Keywords. ECMAScript 2015
- Break,
- Case,
- Catch,
- Class,
- Const,
- Continue,
- Debugger,
- Default,
- Delete,
- Do,
- Else,
- Export,
- Extends,
- Finally,
- For,
- Function,
- If,
- Import,
- In,
- Instanceof,
- New,
- Return,
- Super,
- Switch,
- This,
- Throw,
- Try,
- Typeof,
- Var,
- Void,
- While,
- With,
- Yield,
- Null,
- Undefined,
- True,
- False,
-
- Eof,
- Invalid,
- Whitespace
- }
-}
diff --git a/homework/45278/js2html/js2html/Program.cs b/homework/45278/js2html/js2html/Program.cs
deleted file mode 100644
index 9bf0ebb..0000000
--- a/homework/45278/js2html/js2html/Program.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using js2html.Extensions;
-using System;
-using System.IO;
-using System.Text;
-
-namespace js2html
-{
- class Program
- {
- static void Main(string[] args)
- {
- if(args.Length == 2)
- {
- string path = args[0];
- string code = File.ReadAllText(path);
- Tokenizer tokenizer = new Tokenizer(code);
- tokenizer.Tokens = tokenizer.Tokenize();
- StringBuilder html = new StringBuilder("<!DOCTYPE html>\n<html>\n<head>\n</head>\n<body>\n");
- foreach (var str in tokenizer.ParseHtml())
- {
- html.Append(str);
- }
- html.Append("</body>\n</html>");
- File.WriteAllText(args[1], html.ToString());
- Console.WriteLine("Finished...");
- }
- }
- }
-}
diff --git a/homework/45278/js2html/js2html/Tokenizer.cs b/homework/45278/js2html/js2html/Tokenizer.cs
deleted file mode 100644
index fa61775..0000000
--- a/homework/45278/js2html/js2html/Tokenizer.cs
+++ /dev/null
@@ -1,288 +0,0 @@
-using js2html.Models;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace js2html
-{
- public class Tokenizer
- {
- public Dictionary<string, TokenType> KeywordsTable { get; set; }
- public int Line { get; set; }
- public int Current { get; set; }
- public string Code { get; set; }
- public IEnumerable<Token> Tokens { get; set; }
- public Tokenizer(string code)
- {
- KeywordsTable = new Dictionary<string, TokenType>();
- KeywordsTable.Add("break", TokenType.Break);
- KeywordsTable.Add("case", TokenType.Case);
- KeywordsTable.Add("catch", TokenType.Catch);
- KeywordsTable.Add("class", TokenType.Class);
- KeywordsTable.Add("const", TokenType.Const);
- KeywordsTable.Add("continue", TokenType.Continue);
- KeywordsTable.Add("debugger", TokenType.Debugger);
- KeywordsTable.Add("default", TokenType.Default);
- KeywordsTable.Add("delete", TokenType.Delete);
- KeywordsTable.Add("do", TokenType.Do);
- KeywordsTable.Add("else", TokenType.Else);
- KeywordsTable.Add("export", TokenType.Export);
- KeywordsTable.Add("extends", TokenType.Extends);
- KeywordsTable.Add("finally", TokenType.Finally);
- KeywordsTable.Add("for", TokenType.For);
- KeywordsTable.Add("function", TokenType.Function);
- KeywordsTable.Add("if", TokenType.If);
- KeywordsTable.Add("import", TokenType.Import);
- KeywordsTable.Add("in", TokenType.In);
- KeywordsTable.Add("instanceof", TokenType.Instanceof);
- KeywordsTable.Add("new", TokenType.New);
- KeywordsTable.Add("return", TokenType.Return);
- KeywordsTable.Add("super", TokenType.Super);
- KeywordsTable.Add("switch", TokenType.Switch);
- KeywordsTable.Add("this", TokenType.This);
- KeywordsTable.Add("throw", TokenType.Throw);
- KeywordsTable.Add("try", TokenType.Try);
- KeywordsTable.Add("typeof", TokenType.Typeof);
- KeywordsTable.Add("var", TokenType.Var);
- KeywordsTable.Add("void", TokenType.Void);
- KeywordsTable.Add("while", TokenType.While);
- KeywordsTable.Add("with", TokenType.With);
- KeywordsTable.Add("yield", TokenType.Yield);
- KeywordsTable.Add("null", TokenType.Null);
- KeywordsTable.Add("undefined", TokenType.Undefined);
- KeywordsTable.Add("true", TokenType.True);
- KeywordsTable.Add("false", TokenType.False);
-
- Current = 0;
- Line = 1;
- Code = code;
- }
-
- public IEnumerable<Token> Tokenize()
- {
- List<Token> tokens = new List<Token>();
- do
- {
- tokens.Add(GetNextToken());
- } while (tokens[tokens.Count - 1].TokenType != TokenType.Eof);
- return tokens;
- }
-
- private Token ProduceWhitespaceToken()
- {
- var lexeme = new StringBuilder();
- while(string.IsNullOrWhiteSpace(Code[Current].ToString()))
- {
- lexeme.Append(Code[Current]);
- if (Code[Current] == '\n')
- {
- Current++;
- return new Token(TokenType.Whitespace, Line++, lexeme.ToString());
- }
- Current++;
- }
- return new Token(TokenType.Whitespace, Line, lexeme.ToString());
- }
-
- private string ReadString()
- {
- var opening = Code[Current++];
- var lexeme = new StringBuilder(opening);
- while (!Match(opening))
- {
- lexeme.Append(Code[Current]);
- Current++;
- }
- lexeme.Append(opening);
- return lexeme.ToString();
- }
-
- private string ReadNumber()
- {
- var lexeme = new StringBuilder();
- while(Code[Current] >= '0' && Code[Current] <= '9')
- {
- lexeme.Append(Code[Current]);
- Current++;
- }
- return lexeme.ToString();
- }
-
- private string ReadKeyword()
- {
- var lexeme = new StringBuilder();
- while (Code[Current] >= 'a' && Code[Current] <= 'z')
- {
- lexeme.Append(Code[Current]);
- Current++;
- }
- return lexeme.ToString();
- }
-
- private string ReadIdentifier()
- {
- var lexeme = new StringBuilder();
- while (IsValidIdentifierChar())
- {
- lexeme.Append(Code[Current]);
- Current++;
- }
- return lexeme.ToString();
- }
-
- public Token GetNextToken()
- {
- if (Current == Code.Length)
- {
- return new Token(TokenType.Eof, Line);
- }
- if (Code[Current] == '\0')
- {
- return new Token(TokenType.Eof, Line);
- }
-
-
- if (string.IsNullOrWhiteSpace(Code[Current].ToString())) return ProduceWhitespaceToken();
-
- switch (Code[Current])
- {
- case '(': Current++; return new Token(TokenType.LeftParen, Line, "(");
- case ')': Current++; return new Token(TokenType.RightParen, Line, ")");
- case '{': Current++; return new Token(TokenType.LeftBrace, Line, "{");
- case '}': Current++; return new Token(TokenType.RightBrace, Line, "}");
- case ',': Current++; return new Token(TokenType.Comma, Line, ",");
- case '.': Current++; return new Token(TokenType.Dot, Line, ".");
- case '-':
- Current++;
- if (Match('-'))
- return new Token(TokenType.MinusMinus, Line, "--");
- else if (Match('='))
- return new Token(TokenType.MinusEqual, Line, "-=" );
- else
- return new Token(TokenType.Minus, Line, "-");
- case '+':
- Current++;
- if (Match('+'))
- return new Token(TokenType.PlusPlus, Line, "++");
- else if (Match('='))
- return new Token(TokenType.PlusEqual, Line, "+=");
- else
- return new Token(TokenType.Plus, Line, "+");
- case ';': Current++; return new Token(TokenType.Semicolon, Line, ";");
- case '*': Current++; return new Token(TokenType.Star, Line, "*");
- case '/': Current++; return new Token(TokenType.Division, Line, "/");
- case '%': Current++; return new Token(TokenType.Modulo, Line, "%");
- case '~': Current++; return new Token(TokenType.BitwiseNot, Line, "~");
- case '=':
- Current++;
- if (Match('='))
- {
- if (Match('='))
- return new Token(TokenType.StrictEqual, Line, "===");
- else
- return new Token(TokenType.EqualEqual, Line, "==");
- }
- else
- return new Token(TokenType.Equal, Line, "=");
- case '!':
- Current++;
- if (Match('='))
- {
- if (Match('='))
- return new Token(TokenType.StrictNotEqual, Line, "!==");
- else
- return new Token(TokenType.BangEqual, Line, "!!");
- }
- else
- return new Token(TokenType.Bang, Line, "!");
- case '>':
- Current++;
- if (Match('='))
- return new Token(TokenType.GreaterEqual, Line, ">=");
- else if (Match('>'))
- return new Token(TokenType.RightShift, Line, ">>");
- else
- return new Token(TokenType.Greater, Line, ">");
- case '<':
- Current++;
- if (Match('='))
- return new Token(TokenType.LessEqual, Line, "<=");
- else if (Match('<'))
- return new Token(TokenType.LeftShift, Line, "<<");
- else
- return new Token(TokenType.Less, Line, "<");
- case '&':
- Current++;
- if (Match('&')) return new Token(TokenType.LogicalAnd, Line, "&&");
- else return new Token(TokenType.BitwiseAnd, Line, "&");
- case '|':
- Current++;
- if (Match('|')) return new Token(TokenType.LogicalOr, Line,"||");
- else return new Token(TokenType.BitwiseOr, Line, "|");
- case '^': Current++; return new Token(TokenType.BitwiseXor, Line, "^");
- case '?': Current++; return new Token(TokenType.QuestionMark, Line, "?");
- case ':': Current++; return new Token(TokenType.Colon, Line, ":");
- case '[': Current++; return new Token(TokenType.LeftSquareBracket, Line, "[");
- case ']': Current++; return new Token(TokenType.RightSquareBracket, Line, "]");
- default:
- break;
- }
-
- if(Code[Current] == '\'' || Code[Current] == '"')
- {
- var lexeme = ReadString();
- return new Token(TokenType.String, Line, lexeme);
- }
-
- if(Code[Current] >= '0' && Code[Current] <= '9')
- {
- var lexeme = ReadNumber();
- return new Token(TokenType.Number, Line, lexeme, double.Parse(lexeme));
- }
-
- if(Code[Current] >= 'a' && Code[Current] <= 'z')
- {
- var start = Current;
- var lexeme = ReadKeyword();
- TokenType type = TokenType.Eof;
- if(KeywordsTable.TryGetValue(lexeme, out type))
- {
- return new Token(type, Line, lexeme);
- }
- else
- {
- Current = start;
- }
- }
-
- if(IsValidIdentifierStarting())
- {
- var lexeme = ReadIdentifier();
- return new Token(TokenType.Identifier, Line, lexeme);
- }
-
-
- return new Token(TokenType.Eof, Line);
- }
-
- private bool IsValidIdentifierStarting()
- {
- return (Code[Current] >= 'A' && Code[Current] <= 'z') || Code[Current] == '_';
- }
-
- private bool IsValidIdentifierChar()
- {
- return IsValidIdentifierStarting() || (Code[Current] >= '0' && Code[Current] <= '9');
- }
-
- private bool Match(char c)
- {
- if (c == Code[Current])
- {
- ++Current;
- return true;
- }
- return false;
- }
- }
-}
diff --git a/homework/45278/js2html/js2html/hello.html b/homework/45278/js2html/js2html/hello.html
deleted file mode 100644
index 2c8f911..0000000
--- a/homework/45278/js2html/js2html/hello.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-</head>
-<body>
-<span class="keyword" style="color:blue">function</span><span class="identifier">&nbsp;answer</span><span class="operator">(</span><span class="operator">)</span><span class="operator">&nbsp;{</span><span class="keyword" style="color:blue"><br>&nbsp;&nbsp;&nbsp;&nbsp;return</span><span class="number">&nbsp;42</span><span class="operator">;</span><span class="operator"><br>}</span><span class="identifier"><br>console</span><span class="operator">.</span><span class="identifier">log</span><span class="operator">(</span><span class="string" style="color:indianred">The "Answer" is: '</span><span class="operator">&nbsp;+</span><span class="identifier">&nbsp;answer</span><span class="operator">(</span><span class="operator">)</span><span class="operator">)</span><span class="operator">;</span><br></body>
-</html> \ No newline at end of file
diff --git a/homework/45278/js2html/js2html/hello.js b/homework/45278/js2html/js2html/hello.js
deleted file mode 100644
index ab5524a..0000000
--- a/homework/45278/js2html/js2html/hello.js
+++ /dev/null
@@ -1,4 +0,0 @@
-function answer() {
- return 42;
-}
-console.log('The "Answer" is: ' + answer());
diff --git a/homework/45278/js2html/js2html/js2html.csproj b/homework/45278/js2html/js2html/js2html.csproj
deleted file mode 100644
index b5c27ba..0000000
--- a/homework/45278/js2html/js2html/js2html.csproj
+++ /dev/null
@@ -1,14 +0,0 @@
-<Project Sdk="Microsoft.NET.Sdk">
-
- <PropertyGroup>
- <OutputType>Exe</OutputType>
- <TargetFramework>netcoreapp2.1</TargetFramework>
- <GeneratePackageOnBuild>false</GeneratePackageOnBuild>
- <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
- </PropertyGroup>
-
- <ItemGroup>
- <PackageReference Include="Sprache" Version="2.2.0" />
- </ItemGroup>
-
-</Project>
diff --git a/homework/61984/HW3/main.cpp b/homework/61984/HW3/main.cpp
deleted file mode 100644
index 7696fe7..0000000
--- a/homework/61984/HW3/main.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <iostream>
-int gcd(int a, int b)
-{
- __asm
- {
- mov eax, a
- mov ecx, b
- loop1:
- cmp eax, ecx
- je end
- jg suba
- jmp subb
-
- suba:
- sub eax, ecx;
- jmp loop1;
-
- subb:
- sub ecx, eax
- jmp loop1
-
- end:
- }
-}
-
-int main()
-{
- std::cout << gcd(21, 5);
- return 0;
-}
diff --git a/homework/81013/README.md b/homework/81013/README.md
deleted file mode 100644
index b05d85f..0000000
--- a/homework/81013/README.md
+++ /dev/null
@@ -1 +0,0 @@
-Some Homeworks might live here.
diff --git a/homework/81013/go2html/CommonTypes.h b/homework/81013/go2html/CommonTypes.h
deleted file mode 100644
index f279e34..0000000
--- a/homework/81013/go2html/CommonTypes.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#pragma once
-#include <string>
-#include <vector>
-#include <unordered_map>
-#include <memory>
-
-template<typename T>
-using IPLVector = std::vector<T>;
-using IPLString = std::string;
-
-template <typename Key, typename T>
-using IPLUnorderedMap = std::unordered_map<Key, T>;
-
-template <typename T>
-using IPLSharedPtr = std::shared_ptr<T>;
-
-template <typename T, class... Args>
-inline IPLSharedPtr<T> IPLMakeSharePtr(Args&&... args) {
- return std::make_shared<T, Args...>(args...);
-};
-
-template< typename T>
-using IPLEnableShared = std::enable_shared_from_this<T>;
-
-struct IPLError
-{
- unsigned Row;
- unsigned Column;
- IPLString File;
- IPLString What;
-};
-
-struct IPLResult
-{
- bool IsSuccessful;
- IPLError Error;
-}; \ No newline at end of file
diff --git a/homework/81013/go2html/Highlighter.cpp b/homework/81013/go2html/Highlighter.cpp
deleted file mode 100644
index 8295610..0000000
--- a/homework/81013/go2html/Highlighter.cpp
+++ /dev/null
@@ -1,219 +0,0 @@
-#include <iostream>
-#include <fstream>
-
-#include "CommonTypes.h"
-#include "Lexer.h"
-#include "Highlighter.h"
-
-#define KEYWORD_COLOR "#ad42f4"
-#define IDENTIFIER_COLOR "#41c4f4"
-#define OPERATOR_COLOR "#f49541"
-#define NUMBER_COLOR "#bab103"
-#define STRING_COLOR "#ff11bf"
-#define RUNE_COLOR "#5abc00"
-#define CONST_COLOR "#f94040"
-#define COMMENT_COLOR "#0b8700"
-
-namespace
-{
- void PrintToken(
- const Token& token,
- const IPLString& className,
- std::ostream& out)
- {
- switch (token.Type)
- {
- case TokenType::Whitespace:
- out << token.Lexeme;
- break;
- case TokenType::Float:
- case TokenType::DecimalInteger:
- case TokenType::ImaginaryNum:
- out << "<span class=\"" << className << "\">" << token.Number << "</span>";
- default:
- out << "<span class=\"" << className << "\">" << token.Lexeme << "</span>";
- break;
- }
- }
-}
-
-IPLResult Highlight(std::ifstream& infile, std::ofstream& out)
-{
- out <<
- "<html>\n"
- "<head>\n"
- "<style>\n"
- ".keyword {\n"
- "color: " << KEYWORD_COLOR << ";\n"
- "}\n"
- "\n"
- ".identifier {\n"
- "color: " << IDENTIFIER_COLOR << ";\n"
- "}\n"
- "\n"
- ".operator {\n"
- "color: " << OPERATOR_COLOR << ";\n"
- "}\n"
- "\n"
- ".number {\n"
- "color: " << NUMBER_COLOR << ";\n"
- "}\n"
- "\n"
- ".string {\n"
- "color: " << STRING_COLOR << ";\n"
- "}\n"
- "\n"
- ".rune {\n"
- "color: " << RUNE_COLOR << ";\n"
- "}\n"
- "\n"
- ".const {\n"
- "color: " << CONST_COLOR << ";\n"
- "}\n"
- "\n"
- ".comment {\n"
- "color: " << COMMENT_COLOR << ";\n"
- "}\n"
- "</style>\n"
- "</head>\n"
- "<body><pre>\n" << std::endl;
-
- std::string line;
- std::vector<Token> tokens;
-
- while (std::getline(infile, line))
- {
- IPLResult result = Tokenize(line.c_str(), tokens, {true, true});
- if (!result.IsSuccessful)
- {
- return result;
- }
-
- for (auto& token : tokens)
- {
- switch (token.Type)
- {
- case TokenType::Break:
- case TokenType::Default:
- case TokenType::Func:
- case TokenType::Interface:
- case TokenType::Select:
- case TokenType::Case:
- case TokenType::Defer:
- case TokenType::Go:
- case TokenType::Map:
- case TokenType::Struct:
- case TokenType::Chan:
- case TokenType::Else:
- case TokenType::Goto:
- case TokenType::Package:
- case TokenType::Switch:
- case TokenType::Const:
- case TokenType::Fallthrough:
- case TokenType::If:
- case TokenType::Range:
- case TokenType::Type:
- case TokenType::Continue:
- case TokenType::For:
- case TokenType::Import:
- case TokenType::Return:
- case TokenType::Var:
-
- PrintToken(token, "keyword", out);
- break;
-
- case TokenType::Plus:
- case TokenType::Minus:
- case TokenType::Star:
- case TokenType::Division:
- case TokenType::Modulo:
-
- case TokenType::NOT:
- case TokenType::BitwiseAND:
- case TokenType::BitwiseOR:
- case TokenType::BitwiseXOR:
- case TokenType::BitClear:
- case TokenType::ShiftLeft:
- case TokenType::ShiftRight:
-
- case TokenType::PlusEqual:
- case TokenType::MinusEqual:
- case TokenType::MultEqual:
- case TokenType::DivEqual:
- case TokenType::ModuloEqual:
-
- case TokenType::ConditionalAND:
- case TokenType::ConditionalOR:
- case TokenType::ReceiveOperator:
- case TokenType::PlusPlus:
- case TokenType::MinusMinus:
-
- case TokenType::Equal:
- case TokenType::Less:
- case TokenType::Greater:
-
- case TokenType::NOTEqual:
- case TokenType::LessEqual:
- case TokenType::GreaterEqual:
-
- case TokenType::Assignment:
- case TokenType::ShortAssignment:
-
- case TokenType::Variadic:
-
- case TokenType::LeftParen:
- case TokenType::RightParen:
- case TokenType::LeftSquareBracket:
- case TokenType::RightSquareBracket:
- case TokenType::LeftBrace:
- case TokenType::RightBrace:
-
- case TokenType::Comma:
- case TokenType::Dot:
-
- case TokenType::Semicolon:
- case TokenType::Colon:
-
- PrintToken(token, "operator", out);
- break;
-
- case TokenType::Float:
- case TokenType::DecimalInteger:
- case TokenType::ImaginaryNum:
-
- PrintToken(token, "number", out);
- break;
-
- case TokenType::String:
-
- PrintToken(token, "string", out);
- break;
-
- case TokenType::True:
- case TokenType::False:
- case TokenType::Nil:
-
- PrintToken(token, "const", out);
- break;
-
- case TokenType::Comment:
-
- PrintToken(token, "comment", out);
- break;
-
- default:
- PrintToken(token, "", out);
- break;
- }
- }
-
- out << std::endl;
- tokens.clear();
- }
-
- out <<
- "</pre></body>\n"
- "</html>" << std::endl;
-
- return {true, IPLError() };
-} \ No newline at end of file
diff --git a/homework/81013/go2html/Highlighter.h b/homework/81013/go2html/Highlighter.h
deleted file mode 100644
index a40f5d0..0000000
--- a/homework/81013/go2html/Highlighter.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma once
-
-#include <fstream>
-
-#include "CommonTypes.h"
-#include "Lexer.h"
-
-IPLResult Highlight(std::ifstream& in, std::ofstream& out);
diff --git a/homework/81013/go2html/Lexer.cpp b/homework/81013/go2html/Lexer.cpp
deleted file mode 100644
index fb53f89..0000000
--- a/homework/81013/go2html/Lexer.cpp
+++ /dev/null
@@ -1,668 +0,0 @@
-#include "Lexer.h"
-#include <utility>
-
-namespace
-{
- inline bool IsUpperCase(char c)
- {
- return c >= 'A' && c <= 'Z';
- }
-
- inline bool IsLowerCase(char c)
- {
- return c >= 'a' && c <= 'z';
- }
-
- inline bool IsDigit(char c)
- {
- return c >= '0' && c <= '9';
- }
-
- inline bool IsValidIdentifierStartingChar(char c)
- {
- return IsUpperCase(c) || IsLowerCase(c) || c == '_';
- }
-
- inline bool IsValidIdentifierChar(char c)
- {
- return IsValidIdentifierStartingChar(c) || IsDigit(c);
- }
-
- inline bool IsStringBound(char c)
- {
- return c == '\'' || c == '"' || c == '`';
- }
-
- inline bool IsWhiteSpace(char c)
- {
- return c == ' ' || c == '\t';
- }
-
- inline bool IsNewLine(char c)
- {
- return c == '\n';
- }
-
- inline bool IsEnd(char c)
- {
- return c == '\0';
- }
-}
-
-struct Keyword
-{
- TokenType Type;
- IPLString Content;
-};
-
-using Identifier = Keyword;
-
-enum class State : unsigned char
-{
- Success,
- Fail,
- Error
-};
-
-#define RETURN_SUCCESS(ret) m_GenerationState = State::Success; return ret;
-#define RETURN_FAIL(ret) m_GenerationState = State::Fail; return ret;
-#define RETURN_ERROR(ret) m_GenerationState = State::Error; return ret;
-
-class Tokenizer
-{
-public:
- Tokenizer(const char* code, const LexerSettings& settings);
- IPLResult Tokenize(IPLVector<Token>& tokens);
-
-private:
- Token NextToken();
-
- inline Token ProduceSkipToken();
- inline Token ProduceToken(TokenType type);
- inline Token ProduceToken(TokenType type, IPLString lexeme, double number);
- inline Token ProduceErrorToken();
-
- IPLString ParseComment();
- IPLString ParseWhitespaces();
- double ParseNumber();
- IPLString ParseString();
- Keyword ParseKeyword();
- Identifier ParseIdentifier();
-
- inline bool IsStateSuccess() const;
- inline bool IsStateError() const;
-
- void SetError(const IPLString& what);
-
- bool SkipWhiteSpaces();
- bool SkipNewLine();
- bool Match(const char c);
-
- inline void NextSymbol();
- inline void PreviousSymbol();
- inline void NextLine();
-
- unsigned m_Line;
- unsigned m_Column;
- unsigned m_Current;
- const char* m_Code;
-
- IPLError m_Error;
- State m_GenerationState;
-
- LexerSettings m_Settings;
- bool m_SkipNextToken;
-
- IPLUnorderedMap<IPLString, TokenType> m_KeyWordsTable;
-};
-
-IPLResult Tokenize(const char* code, IPLVector<Token>& tokens, const LexerSettings& settings)
-{
- Tokenizer tokenizer(code, settings);
-
- return tokenizer.Tokenize(tokens);
-}
-
-IPLResult Tokenize(const char* code, IPLVector<Token>& tokens)
-{
- return Tokenize(code, tokens, { false, false });
-}
-
-Tokenizer::Tokenizer(const char* code, const LexerSettings& settings)
- : m_Line(0)
- , m_Column(0)
- , m_Current(0)
- , m_Code(code)
- , m_Error()
- , m_GenerationState(State::Success)
- , m_Settings(settings)
- , m_SkipNextToken(false)
-{
- m_KeyWordsTable["break"] = TokenType::Break;
- m_KeyWordsTable["default"] = TokenType::Default;
- m_KeyWordsTable["func"] = TokenType::Func;
- m_KeyWordsTable["interface"] = TokenType::Interface;
- m_KeyWordsTable["select"] = TokenType::Select;
- m_KeyWordsTable["case"] = TokenType::Case;
- m_KeyWordsTable["defer"] = TokenType::Defer;
- m_KeyWordsTable["go"] = TokenType::Go;
- m_KeyWordsTable["map"] = TokenType::Map;
- m_KeyWordsTable["struct"] = TokenType::Struct;
- m_KeyWordsTable["chan"] = TokenType::Chan;
- m_KeyWordsTable["else"] = TokenType::Else;
- m_KeyWordsTable["goto"] = TokenType::Goto;
- m_KeyWordsTable["package"] = TokenType::Package;
- m_KeyWordsTable["switch"] = TokenType::Switch;
- m_KeyWordsTable["const"] = TokenType::Const;
- m_KeyWordsTable["fallthrough"] = TokenType::Fallthrough;
- m_KeyWordsTable["if"] = TokenType::If;
- m_KeyWordsTable["range"] = TokenType::Range;
- m_KeyWordsTable["type"] = TokenType::Type;
- m_KeyWordsTable["continue"] = TokenType::Continue;
- m_KeyWordsTable["for"] = TokenType::For;
- m_KeyWordsTable["import"] = TokenType::Import;
- m_KeyWordsTable["return"] = TokenType::Return;
- m_KeyWordsTable["var"] = TokenType::Var;
-
- m_KeyWordsTable["true"] = TokenType::True;
- m_KeyWordsTable["false"] = TokenType::False;
-
- m_KeyWordsTable["nil"] = TokenType::Nil;
-}
-
-IPLResult Tokenizer::Tokenize(IPLVector<Token>& tokens)
-{
- do
- {
- Token token;
- do
- {
- token = NextToken();
- } while (m_SkipNextToken);
-
- if (m_GenerationState == State::Error)
- {
- return IPLResult{ false, IPLError(m_Error) };
- }
-
- tokens.emplace_back(token);
- } while (tokens.back().Type != TokenType::Eof);
-
- return IPLResult{ true, IPLError() };
-}
-
-bool Tokenizer::SkipWhiteSpaces()
-{
- const auto old = m_Current;
- while (IsWhiteSpace(m_Code[m_Current]))
- {
- NextSymbol();
- }
- return old != m_Current;
-}
-
-bool Tokenizer::SkipNewLine()
-{
- const auto old = m_Current;
- while (IsNewLine(m_Code[m_Current]))
- {
- NextLine();
- }
- return old != m_Current;
-}
-
-bool Tokenizer::Match(const char c)
-{
- if (c == m_Code[m_Current])
- {
- if (!IsNewLine(m_Code[m_Current]))
- {
- NextSymbol();
- }
- else
- {
- NextLine();
- }
-
- return true;
- }
- return false;
-}
-
-inline void Tokenizer::NextSymbol()
-{
- ++m_Current;
- ++m_Column;
-}
-
-inline void Tokenizer::PreviousSymbol()
-{
- --m_Current;
- --m_Column;
-}
-
-inline void Tokenizer::NextLine()
-{
- ++m_Current;
- ++m_Line;
- m_Column = 0;
-}
-
-inline Token Tokenizer::ProduceToken(TokenType type, IPLString lexeme, double number = 0.0)
-{
- return Token{ type, m_Line, std::move(lexeme), number };
-}
-
-inline Token Tokenizer::ProduceSkipToken()
-{
- return ProduceToken(TokenType::Invalid, "");
-}
-
-inline Token Tokenizer::ProduceToken(TokenType type)
-{
- switch (type)
- {
- case TokenType::Plus:
- return ProduceToken(type, "+");
- case TokenType::Minus:
- return ProduceToken(type, "-");
- case TokenType::Star:
- return ProduceToken(type, "*");
- case TokenType::Division:
- return ProduceToken(type, "/");
- case TokenType::Modulo:
- return ProduceToken(type, "%");
-
- case TokenType::PlusEqual:
- return ProduceToken(type, "+=");
- case TokenType::MinusEqual:
- return ProduceToken(type, "-=");
- case TokenType::MultEqual:
- return ProduceToken(type, "*=");
- case TokenType::DivEqual:
- return ProduceToken(type, "/=");
- case TokenType::ModuloEqual:
- return ProduceToken(type, "%=");
-
- case TokenType::NOT:
- return ProduceToken(type, "!");
- case TokenType::BitwiseAND:
- return ProduceToken(type, "&");
- case TokenType::BitwiseOR:
- return ProduceToken(type, "|");
- case TokenType::BitwiseXOR:
- return ProduceToken(type, "^");
- case TokenType::BitClear:
- return ProduceToken(type, "^&");
- case TokenType::ShiftLeft:
- return ProduceToken(type, "<<");
- case TokenType::ShiftRight:
- return ProduceToken(type, ">>");
-
- case TokenType::ConditionalAND:
- return ProduceToken(type, "&&");
- case TokenType::ConditionalOR:
- return ProduceToken(type, "||");
-
- case TokenType::ReceiveOperator:
- return ProduceToken(type, "<-");
-
- case TokenType::PlusPlus:
- return ProduceToken(type, "++");
- case TokenType::MinusMinus:
- return ProduceToken(type, "--");
-
- case TokenType::Equal:
- return ProduceToken(type, "==");
- case TokenType::Less:
- return ProduceToken(type, "<");
- case TokenType::Greater:
- return ProduceToken(type, ">");
-
- case TokenType::NOTEqual:
- return ProduceToken(type, "!=");
- case TokenType::LessEqual:
- return ProduceToken(type, "<=");
- case TokenType::GreaterEqual:
- return ProduceToken(type, ">=");
-
- case TokenType::Assignment:
- return ProduceToken(type, "=");
- case TokenType::ShortAssignment:
- return ProduceToken(type, ":=");
-
- case TokenType::Variadic:
- return ProduceToken(type, "...");
-
- case TokenType::LeftBrace:
- return ProduceToken(type, "{");
- case TokenType::RightBrace:
- return ProduceToken(type, "}");
- case TokenType::RightSquareBracket:
- return ProduceToken(type, "]");
- case TokenType::LeftSquareBracket:
- return ProduceToken(type, "[");
- case TokenType::LeftParen:
- return ProduceToken(type, "(");
- case TokenType::RightParen:
- return ProduceToken(type, ")");
-
- case TokenType::Comma:
- return ProduceToken(type, ",");
- case TokenType::Dot:
- return ProduceToken(type, ".");
-
- default: // EoF Invalid
- break;
- }
- return ProduceToken(type, "");
-}
-
-inline Token Tokenizer::ProduceErrorToken()
-{
- return ProduceToken(TokenType::Invalid, "");
-}
-
-IPLString Tokenizer::ParseComment()
-{
- auto start = m_Current;
-
- if (!Match('/'))
- {
- RETURN_FAIL(IPLString());
- }
-
- if (Match('/'))
- {
- while (!IsEnd(m_Code[m_Current]) && !IsNewLine(m_Code[m_Current]))
- {
- NextSymbol();
- }
- RETURN_SUCCESS(IPLString(m_Code + start, m_Code + m_Current))
- }
- else if (!Match('*'))
- {
- PreviousSymbol();
- RETURN_FAIL(IPLString());
- }
-
- while (!IsEnd(m_Code[m_Current]))
- {
- if (Match('*') && Match('/'))
- {
- RETURN_SUCCESS(IPLString(m_Code + start, m_Code + m_Current));
- }
- NextSymbol();
- }
-
- SetError("unterminated comment");
- RETURN_ERROR(IPLString());
-}
-
-IPLString Tokenizer::ParseWhitespaces()
-{
- if (!IsWhiteSpace(m_Code[m_Current]) && !IsNewLine(m_Code[m_Current]))
- {
- RETURN_FAIL(IPLString());
- }
-
- auto start = m_Current;
- while (true)
- {
- if (IsWhiteSpace(m_Code[m_Current]))
- {
- NextSymbol();
- }
- else if (IsNewLine(m_Code[m_Current]))
- {
- NextLine();
- }
- else
- {
- break;
- }
- }
-
- RETURN_SUCCESS(IPLString(m_Code + start, m_Code + m_Current));
-}
-
-// todo - many Go numbers, much refactoring
-double Tokenizer::ParseNumber()
-{
- if (!IsDigit(m_Code[m_Current]))
- {
- RETURN_FAIL(0.0);
- }
-
- size_t parsedBytes = 0;
- double number = std::stod(m_Code + m_Current, &parsedBytes);
- m_Current += static_cast<unsigned>(parsedBytes);
- m_Column += static_cast<unsigned>(parsedBytes);
-
- RETURN_SUCCESS(number);
-}
-
-IPLString Tokenizer::ParseString()
-{
- if (!IsStringBound(m_Code[m_Current]))
- {
- RETURN_FAIL(IPLString());
- }
-
- char bound = m_Code[m_Current];
- auto start = m_Current;
-
- // skip first " or ', or `
- NextSymbol();
- while (m_Code[m_Current] != bound && !IsEnd(m_Code[m_Current]) && !IsNewLine(m_Code[m_Current]))
- {
- NextSymbol();
- }
-
- if (IsEnd(m_Code[m_Current]) || IsNewLine(m_Code[m_Current]))
- {
- SetError("\"\" string literal contains an unescaped line break");
- RETURN_ERROR(IPLString());
- }
-
- // skip second " or ', or `
- NextSymbol();
-
- RETURN_SUCCESS(IPLString(m_Code + start, m_Code + m_Current));
-}
-
-Keyword Tokenizer::ParseKeyword()
-{
- if (!IsLowerCase(m_Code[m_Current]))
- {
- RETURN_FAIL(Keyword());
- }
-
- auto start = m_Current;
-
- NextSymbol();
- while (IsLowerCase(m_Code[m_Current]))
- {
- NextSymbol();
- }
-
- auto key = IPLString(m_Code + start, m_Code + m_Current);
- auto keyword = m_KeyWordsTable.find(key);
-
- if (keyword == m_KeyWordsTable.end())
- {
- // It's not a keyword so we must revert current counter
- m_Column = m_Column + start - m_Current;
- m_Current = start;
-
- RETURN_FAIL(Keyword());
- }
-
- RETURN_SUCCESS((Keyword{ keyword->second, keyword->first }));
-}
-
-Identifier Tokenizer::ParseIdentifier()
-{
- if (!IsValidIdentifierStartingChar(m_Code[m_Current]))
- {
- RETURN_FAIL(Identifier());
- }
-
- auto start = m_Current;
-
- NextSymbol();
- while (IsValidIdentifierChar(m_Code[m_Current]))
- {
- NextSymbol();
- }
-
- RETURN_SUCCESS((Identifier{ TokenType::Identifier, IPLString(m_Code + start, m_Code + m_Current) }));
-}
-
-inline bool Tokenizer::IsStateSuccess() const
-{
- return m_GenerationState == State::Success;
-}
-
-inline bool Tokenizer::IsStateError() const
-{
- return m_GenerationState == State::Error;
-}
-
-void Tokenizer::SetError(const IPLString& what)
-{
- m_Error = IPLError{ m_Line, m_Column, "", "Syntax error: " + what };
-}
-
-Token Tokenizer::NextToken()
-{
- m_SkipNextToken = false;
-
- if (IsEnd(m_Code[m_Current]))
- {
- return ProduceToken(TokenType::Eof);
- }
-
- const auto& comment = ParseComment();
- if (IsStateError())
- {
- return ProduceErrorToken();
- }
- if (IsStateSuccess())
- {
- if (!m_Settings.CreateCommentTokens)
- {
- m_SkipNextToken = true;
- return ProduceSkipToken();
- }
- return ProduceToken(TokenType::Comment, comment);
- }
-
- const auto& spaces = ParseWhitespaces();
- if (IsStateSuccess())
- {
- if (!m_Settings.CreateWhitespaceTokens)
- {
- m_SkipNextToken = true;
- return ProduceSkipToken();
- }
- return ProduceToken(TokenType::Whitespace, spaces);
- }
-
- // Single Char
- switch (m_Code[m_Current])
- {
- case '-': NextSymbol(); return Match('-') ? ProduceToken(TokenType::MinusMinus) :
- Match('=') ? ProduceToken(TokenType::MinusEqual) :
- ProduceToken(TokenType::Minus);
- case '+': NextSymbol(); return Match('+') ? ProduceToken(TokenType::PlusPlus) :
- Match('=') ? ProduceToken(TokenType::PlusEqual) :
- ProduceToken(TokenType::Plus);
-
- case '*': NextSymbol(); return Match('=') ? ProduceToken(TokenType::MultEqual) :
- ProduceToken(TokenType::Star);
- case '/': NextSymbol(); return Match('=') ? ProduceToken(TokenType::DivEqual) :
- ProduceToken(TokenType::Division);
- case '%': NextSymbol(); return Match('=') ? ProduceToken(TokenType::ModuloEqual) :
- ProduceToken(TokenType::Modulo);
-
- case '&': NextSymbol(); return Match('&') ? ProduceToken(TokenType::ConditionalAND) :
- ProduceToken(TokenType::BitwiseAND);
-
- case '|': NextSymbol(); return Match('|') ? ProduceToken(TokenType::ConditionalOR) :
- ProduceToken(TokenType::BitwiseOR);
-
- case '^': NextSymbol(); return Match('&') ? ProduceToken(TokenType::BitClear) :
- ProduceToken(TokenType::BitwiseXOR);
-
- case '=': NextSymbol(); return Match('=') ? ProduceToken(TokenType::Equal) :
- ProduceToken(TokenType::Assignment);
-
- case '>': NextSymbol(); return Match('=') ? ProduceToken(TokenType::GreaterEqual) :
- Match('>') ? ProduceToken(TokenType::ShiftRight) :
- ProduceToken(TokenType::Greater);
-
- case '<': NextSymbol(); return Match('=') ? ProduceToken(TokenType::LessEqual) :
- Match('<') ? ProduceToken(TokenType::ShiftLeft) :
- Match('-') ? ProduceToken(TokenType::ReceiveOperator) :
- ProduceToken(TokenType::Less);
-
- case '!': NextSymbol(); return Match('=') ? ProduceToken(TokenType::NOTEqual) : ProduceToken(TokenType::NOT);
-
- case '(': NextSymbol(); return ProduceToken(TokenType::LeftParen);
- case ')': NextSymbol(); return ProduceToken(TokenType::RightParen);
- case '[': NextSymbol(); return ProduceToken(TokenType::LeftSquareBracket);
- case ']': NextSymbol(); return ProduceToken(TokenType::RightSquareBracket);
- case '{': NextSymbol(); return ProduceToken(TokenType::LeftBrace);
- case '}': NextSymbol(); return ProduceToken(TokenType::RightBrace);
-
- case ',': NextSymbol(); return ProduceToken(TokenType::Comma);
- case '.': NextSymbol(); return Match('.') ? Match('.') ? ProduceToken(TokenType::Variadic) :
- ProduceToken(TokenType::Invalid, "") :
- ProduceToken(TokenType::Dot);
-
- case ';': NextSymbol(); return ProduceToken(TokenType::Semicolon);
- case ':': NextSymbol(); return Match('=') ? ProduceToken(TokenType::ShortAssignment) :
- ProduceToken(TokenType::Colon);
-
- // todo: see if I've left some go-specific single chars out
-
- default:
- break;
- }
-
- const auto& number = ParseNumber();
- if (IsStateSuccess())
- {
- // todo - add integers and perhaps imaginary numbers
- return ProduceToken(TokenType::Float, "", number);
- }
-
- const auto& string = ParseString();
- if (IsStateSuccess())
- {
- if (string.length() != 1)
- {
- return ProduceToken(TokenType::String, string);
- }
- return ProduceToken(TokenType::Rune, string);
- }
- else if (IsStateError())
- {
- return ProduceErrorToken();
- }
-
- const auto& keyword = ParseKeyword();
- if (IsStateSuccess())
- {
- return ProduceToken(keyword.Type, keyword.Content);
- }
-
- const auto& identifier = ParseIdentifier();
- if (IsStateSuccess())
- {
- return ProduceToken(identifier.Type, identifier.Content);
- }
-
- return ProduceErrorToken();
-}
diff --git a/homework/81013/go2html/Lexer.h b/homework/81013/go2html/Lexer.h
deleted file mode 100644
index d1b5ae6..0000000
--- a/homework/81013/go2html/Lexer.h
+++ /dev/null
@@ -1,125 +0,0 @@
-#pragma once
-
-#include "CommonTypes.h"
-
-enum class TokenType
-{
- // Keywords
- Break,
- Default,
- Func,
- Interface,
- Select,
- Case,
- Defer,
- Go,
- Map,
- Struct,
- Chan,
- Else,
- Goto,
- Package,
- Switch,
- Const,
- Fallthrough,
- If,
- Range,
- Type,
- Continue,
- For,
- Import,
- Return,
- Var,
-
- // Operators & Punctuation
- Plus,
- Minus,
- Star,
- Division,
- Modulo,
-
- NOT,
- BitwiseAND,
- BitwiseOR,
- BitwiseXOR,
- BitClear,
- ShiftLeft,
- ShiftRight,
-
- PlusEqual,
- MinusEqual,
- MultEqual,
- DivEqual,
- ModuloEqual,
-
- // -> skipped bitwise + equal stuff
-
- ConditionalAND,
- ConditionalOR,
- ReceiveOperator,
- PlusPlus,
- MinusMinus,
-
- Equal,
- Less,
- Greater,
-
- NOTEqual,
- LessEqual,
- GreaterEqual,
-
- Assignment,
- ShortAssignment,
-
- Variadic,
-
- LeftParen,
- RightParen,
- LeftSquareBracket,
- RightSquareBracket,
- LeftBrace,
- RightBrace,
-
- Comma,
- Dot,
-
- Semicolon,
- Colon,
-
- // Identifier
- Identifier,
-
- // Types
- DecimalInteger, // not really supported ATM
- Float,
- ImaginaryNum, // not really supported ATM
- String,
- Rune,
-
- True,
- False,
- Nil,
-
- Whitespace,
- Comment,
-
- Eof,
- Invalid
-};
-
-struct Token
-{
- TokenType Type;
- unsigned Line;
- IPLString Lexeme;
- double Number;
-};
-
-struct LexerSettings
-{
- bool CreateWhitespaceTokens;
- bool CreateCommentTokens;
-};
-
-IPLResult Tokenize(const char* code, IPLVector<Token>& tokens, const LexerSettings& settings);
-IPLResult Tokenize(const char* code, IPLVector<Token>& tokens); \ No newline at end of file
diff --git a/homework/81013/go2html/README.md b/homework/81013/go2html/README.md
deleted file mode 100644
index 10e233f..0000000
--- a/homework/81013/go2html/README.md
+++ /dev/null
@@ -1,8 +0,0 @@
-Usage:
-
-Make solution via premake5
-> premake5 vs2015 premake5.lua
-
-Open the vs solution, add two command line arguments - the go file that you want to highlight and the html in which you would like to write
-
-example arguments: sample.go res.html
diff --git a/homework/81013/go2html/main.cpp b/homework/81013/go2html/main.cpp
deleted file mode 100644
index 4a8d65a..0000000
--- a/homework/81013/go2html/main.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <iostream>
-#include <string>
-#include <fstream>
-#include <sstream>
-
-#include "CommonTypes.h"
-#include "Lexer.h"
-#include "Highlighter.h"
-
-int main(int argc, char **argv)
-{
- // todo: WRITE PROPER TESTS
- std::ifstream infile(argv[1]);
- std::ofstream offile(argv[2]);
-
- Highlight(infile, offile);
-
- return 0;
-}
diff --git a/homework/81013/go2html/premake5.lua b/homework/81013/go2html/premake5.lua
deleted file mode 100644
index 17131f7..0000000
--- a/homework/81013/go2html/premake5.lua
+++ /dev/null
@@ -1,22 +0,0 @@
-solution 'HL'
- configurations {'debug', 'release'}
- flags {
- 'FatalWarnings'
- }
-
- local root = 'build/'
-
- configuration 'debug'
- targetdir(root .. 'bin/debug')
- objdir(root .. 'obj/debug')
-
- configuration 'release'
- targetdir(root .. 'bin/release')
- objdir(root .. 'obj/release')
- configuration '*'
-
- project 'HL'
- kind 'ConsoleApp'
- language 'C++'
- files '*.cpp'
- files '*.h'
diff --git a/homework/81013/go2html/sample.go b/homework/81013/go2html/sample.go
deleted file mode 100644
index 9c76ea2..0000000
--- a/homework/81013/go2html/sample.go
+++ /dev/null
@@ -1,308 +0,0 @@
-package main
-
-import (
- "encoding/json"
- "errors"
- "io/ioutil"
- "net/http"
- "net/url"
- "regexp"
- "strconv"
- "sync"
- //"fmt"
-)
-
-type Cell struct {
- X int64 `json:"x"`
- Y int64 `json:"y"`
-}
-
-type GameOfLifeHandler struct {
- Generation int
- Board map[Cell]bool
- Neighbours map[Cell]int
- RespWriter http.ResponseWriter
- BoardMutex sync.Mutex
- NeighboursMutex sync.Mutex
- RequestMutex sync.RWMutex
-}
-
-/* util functions */
-func (g *GameOfLifeHandler) sendError(err error) {
- g.RespWriter.Header().Set("Error", err.Error())
- g.RespWriter.WriteHeader(http.StatusBadRequest)
-}
-
-func (g *GameOfLifeHandler) parseXYQuery(r *http.Request) (result Cell, err error) {
- values, err := url.ParseQuery(r.URL.RawQuery)
- if err != nil {
- g.sendError(err)
- return
- }
-
- // validate
- if len(values) != 2 {
- err = errors.New("Invalid parameters query - invalid number of query parameters")
- g.sendError(err)
- return
- }
-
- xString := values.Get("x")
- yString := values.Get("y")
-
- if xString == "" || yString == "" {
- err = errors.New("Invalid parameters query - x or y not set")
- g.sendError(err)
- return
- }
-
- x, err := strconv.ParseInt(xString, 10, 64)
- if err != nil {
- g.sendError(err)
- return
- }
- y, err := strconv.ParseInt(yString, 10, 64)
- if err != nil {
- g.sendError(err)
- return
- }
-
- result.X = x
- result.Y = y
-
- return
-}
-
-func updateNeighbours(cell Cell, neighbours *map[Cell]int) {
- var neighbour Cell
-
- for i := cell.X - 1; i <= cell.X+1; i++ {
- for j := cell.Y - 1; j <= cell.Y+1; j++ {
-
- if i == cell.X && j == cell.Y {
- continue
- }
-
- neighbour.X = i
- neighbour.Y = j
-
- (*neighbours)[neighbour]++
- }
- }
-}
-
-/* url handlers */
-func (g *GameOfLifeHandler) addNewCells(r *http.Request) (err error) {
- var cellSlice []Cell
- cellSlice = make([]Cell, 0, 2)
-
- jsonBytes, err := ioutil.ReadAll(r.Body)
- if err != nil {
- g.sendError(err)
- return
- }
-
- err = json.Unmarshal(jsonBytes, &cellSlice)
- if err != nil {
- g.sendError(err)
- return
- }
-
- for _, cell := range cellSlice {
- g.BoardMutex.Lock()
- g.Board[cell] = true
- g.BoardMutex.Unlock()
-
- g.NeighboursMutex.Lock()
- updateNeighbours(cell, &g.Neighbours)
- g.NeighboursMutex.Unlock()
- }
-
- return err
-}
-
-// writes json as a response
-func (g *GameOfLifeHandler) checkCell(w http.ResponseWriter, cell Cell) (err error) {
- alive := make(map[string]bool)
- alive["alive"] = g.Board[cell]
-
- output, err := json.Marshal(alive)
- if err != nil {
- g.sendError(err)
- return
- }
-
- w.WriteHeader(http.StatusOK)
- w.Write(output)
- return
-}
-
-// writes json as a response
-func (g *GameOfLifeHandler) generation(w http.ResponseWriter) {
- generation := make([]Cell, 0, len(g.Board))
-
- for cell := range g.Board {
- generation = append(generation, cell)
- }
-
- currentGeneration := make(map[string]interface{})
- currentGeneration["generation"] = strconv.Itoa(g.Generation)
- currentGeneration["living"] = generation
-
- output, err := json.Marshal(currentGeneration)
- if err != nil {
- g.sendError(err)
- return
- }
-
- w.WriteHeader(http.StatusOK)
- w.Write(output)
-}
-
-func (g *GameOfLifeHandler) evolve(w http.ResponseWriter) {
- newBoard := make(map[Cell]bool)
- newNeighbourBoard := make(map[Cell]int)
-
- for cell, neighbours := range g.Neighbours {
- if g.Board[cell] {
- if neighbours == 2 || neighbours == 3 {
- newBoard[cell] = true
-
- updateNeighbours(cell, &newNeighbourBoard)
- }
- } else {
- if neighbours == 3 {
- newBoard[cell] = true
-
- updateNeighbours(cell, &newNeighbourBoard)
- }
- }
- }
-
- g.BoardMutex.Lock()
- g.Board = newBoard
- g.BoardMutex.Unlock()
-
- g.NeighboursMutex.Lock()
- g.Neighbours = newNeighbourBoard
- g.NeighboursMutex.Unlock()
-
- g.Generation++
-
- w.WriteHeader(http.StatusNoContent)
-}
-
-func (g *GameOfLifeHandler) reset(w http.ResponseWriter) {
- g.Generation = 0
-
- g.BoardMutex.Lock()
- g.Board = make(map[Cell]bool)
- g.BoardMutex.Unlock()
-
- w.WriteHeader(http.StatusNoContent)
-}
-
-func (g *GameOfLifeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- path := r.URL.Path
-
- switch {
- case regexp.MustCompile(`/generation/evolve/`).MatchString(path):
- // POST
- if r.Method != "POST" {
- w.WriteHeader(http.StatusMethodNotAllowed)
- } else {
- g.RequestMutex.Lock()
-
- g.evolve(w)
-
- g.RequestMutex.Unlock()
- }
-
- case regexp.MustCompile(`/generation/`).MatchString(path):
- // GET
- if r.Method != "GET" {
- w.WriteHeader(http.StatusMethodNotAllowed)
- } else {
- g.RequestMutex.RLock()
-
- g.generation(w)
-
- g.RequestMutex.RUnlock()
- }
-
- case regexp.MustCompile(`/cell/status/`).MatchString(path):
- // GET
- if r.Method != "GET" {
- w.WriteHeader(http.StatusMethodNotAllowed)
- } else {
- g.RequestMutex.RLock()
-
- cell, err := g.parseXYQuery(r)
- if err == nil {
- g.checkCell(w, cell)
- }
-
- g.RequestMutex.RUnlock()
- }
-
- case regexp.MustCompile(`/cells/`).MatchString(path):
- // POST
- if r.Method != "POST" {
- w.WriteHeader(http.StatusMethodNotAllowed)
- } else {
- g.RequestMutex.Lock()
-
- if err := g.addNewCells(r); err == nil {
- w.WriteHeader(http.StatusCreated)
- }
-
- g.RequestMutex.Unlock()
- }
-
- case regexp.MustCompile(`/reset/`).MatchString(path):
- // POST
- if r.Method != "POST" {
- w.WriteHeader(http.StatusMethodNotAllowed)
- } else {
- g.RequestMutex.Lock()
-
- g.reset(w)
-
- g.RequestMutex.Unlock()
- }
-
- default:
- w.WriteHeader(http.StatusNotFound)
- }
-}
-
-func NewGameOfLifeHandler(cells [][2]int64) *GameOfLifeHandler {
- board := make(map[Cell]bool)
- neighbours := make(map[Cell]int)
-
- var newCell Cell
-
- for _, cell := range cells {
- newCell.X = cell[0]
- newCell.Y = cell[1]
-
- board[newCell] = true
-
- updateNeighbours(newCell, &neighbours)
- }
-
- gameOfLifeHandler := &GameOfLifeHandler{Generation: 0, Board: board, Neighbours: neighbours}
-
- return gameOfLifeHandler
-}
-
-func main() {
- gofh := NewGameOfLifeHandler([][2]int64{
- {2, 3},
- {2, 4},
- {-20, 4},
- {-42, 0},
- })
-
- http.ListenAndServe(":8080", gofh)
-}
diff --git a/homework/81030/1,2-rust2html/.gitignore b/homework/81030/1,2-rust2html/.gitignore
deleted file mode 100644
index 691e40c..0000000
--- a/homework/81030/1,2-rust2html/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-a.out
-lex.yy.c
-
-/rust2html
-/example.html
diff --git a/homework/81030/1,2-rust2html/Makefile b/homework/81030/1,2-rust2html/Makefile
deleted file mode 100644
index b6f2dde..0000000
--- a/homework/81030/1,2-rust2html/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-PROGRAM_NAMES := rust2html rust2html-prettyprint
-PROGRAM_SOURCE_FILENAMES := $(patsubst %,%.lex.yy.c,PROGRAM_NAMES)
-
-LEX := flex
-
-ifdef DEBUG
-LEX_FLAGS := -d
-endif
-
-.PHONY: all clean
-
-all: $(PROGRAM_NAMES)
-
-%: %.lex.yy.c
- $(CC) $(CFLAGS) -o $@ $<
-
-%.lex.yy.c: %.l
- $(LEX) $(LEX_FLAGS) -o $@ $<
-
-clean:
- $(RM) $(PROGRAM_NAMES) $(PROGRAM_SOURCE_FILENAMES) lex.yy.c example.html
diff --git a/homework/81030/1,2-rust2html/README.md b/homework/81030/1,2-rust2html/README.md
deleted file mode 100644
index 577a3d0..0000000
--- a/homework/81030/1,2-rust2html/README.md
+++ /dev/null
@@ -1,50 +0,0 @@
-# Rust syntax highlighter
-
-This is an implementation of a syntax highlighter for the Rust programming language. It takes a Rust program as input (or a Rust source file as an argument) and outputs a HTML page with a colorized version of the program. The C source for the highlighter is generated from a Flex-based scanner template (`rust2html.l`). (This is a solution to the first homework assignment.)
-
-There is also an extended and improved version of the highlighter which implements pretty-printing (`rust2html-prettyprint.l`). (This is a solution to the second homework assignment.)
-
-## Generating and building
-
-On Unix-like OS:
-
-* the regular highlighter:
-
- flex rust2html.l
- cc -o rust2html lex.yy.c
-
-* the extended (pretty-printing) highlighter:
-
- flex rust2html-prettyprint.l
- cc -o rust2html-prettyprint lex.yy.c
-
-Using the provided `Makefile`:
-
-* the regular highlighter:
-
- make rust2html
-
-* the extended (pretty-printing) highlighter:
-
- make rust2html-prettyprint
-
-## Usage
-
-This will generate a HTML document named `example.html` with a colorized version of the `example.rs` Rust program:
-
- ./rust2html example.rs > example.html
-
-This will generate a HTML document named `example.html` with a colorized and pretty-printed version of the `example.rs` Rust program:
-
- ./rust2html-prettyprint example.rs > example.html
-
-## Debugging
-
-If you want to be able to debug the `RUST2HTML` scanner (i.e. `rust2html` or `rust2html-prettyprint`), generate its code using the `-d` flag with Flex:
-
- flex -d RUST2HTML.l
- cc -o RUST2HTML lex.yy.c
-
-The following invocation of `RUST2HTML` will also write its standard error output to the `example.log` file (which is the main thing to look at when trying to debug the program):
-
- ./RUST2HTML example.rs > example.html 2> example.log \ No newline at end of file
diff --git a/homework/81030/1,2-rust2html/example-chains.rs b/homework/81030/1,2-rust2html/example-chains.rs
deleted file mode 100644
index be38300..0000000
--- a/homework/81030/1,2-rust2html/example-chains.rs
+++ /dev/null
@@ -1,871 +0,0 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Formatting of chained expressions, i.e. expressions which are chained by
-//! dots: struct and enum field access, method calls, and try shorthand (?).
-//!
-//! Instead of walking these subexpressions one-by-one, as is our usual strategy
-//! for expression formatting, we collect maximal sequences of these expressions
-//! and handle them simultaneously.
-//!
-//! Whenever possible, the entire chain is put on a single line. If that fails,
-//! we put each subexpression on a separate, much like the (default) function
-//! argument function argument strategy.
-//!
-//! Depends on config options: `chain_indent` is the indent to use for
-//! blocks in the parent/root/base of the chain (and the rest of the chain's
-//! alignment).
-//! E.g., `let foo = { aaaa; bbb; ccc }.bar.baz();`, we would layout for the
-//! following values of `chain_indent`:
-//! Block:
-//!
-//! ```ignore
-//! let foo = {
-//! aaaa;
-//! bbb;
-//! ccc
-//! }.bar
-//! .baz();
-//! ```
-//!
-//! Visual:
-//!
-//! ```ignore
-//! let foo = {
-//! aaaa;
-//! bbb;
-//! ccc
-//! }
-//! .bar
-//! .baz();
-//! ```
-//!
-//! If the first item in the chain is a block expression, we align the dots with
-//! the braces.
-//! Block:
-//!
-//! ```ignore
-//! let a = foo.bar
-//! .baz()
-//! .qux
-//! ```
-//!
-//! Visual:
-//!
-//! ```ignore
-//! let a = foo.bar
-//! .baz()
-//! .qux
-//! ```
-
-use comment::{rewrite_comment, CharClasses, FullCodeCharKind, RichChar};
-use config::IndentStyle;
-use expr::rewrite_call;
-use lists::extract_pre_comment;
-use macros::convert_try_mac;
-use rewrite::{Rewrite, RewriteContext};
-use shape::Shape;
-use source_map::SpanUtils;
-use utils::{
- self, first_line_width, last_line_extendable, last_line_width, mk_sp, rewrite_ident,
- trimmed_last_line_width, wrap_str,
-};
-
-use std::borrow::Cow;
-use std::cmp::min;
-
-use syntax::source_map::{BytePos, Span};
-use syntax::{ast, ptr};
-
-pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -> Option<String> {
- let chain = Chain::from_ast(expr, context);
- debug!("rewrite_chain {:?} {:?}", chain, shape);
-
- // If this is just an expression with some `?`s, then format it trivially and
- // return early.
- if chain.children.is_empty() {
- return chain.parent.rewrite(context, shape);
- }
-
- chain.rewrite(context, shape)
-}
-
-#[derive(Debug)]
-enum CommentPosition {
- Back,
- Top,
-}
-
-// An expression plus trailing `?`s to be formatted together.
-#[derive(Debug)]
-struct ChainItem {
- kind: ChainItemKind,
- tries: usize,
- span: Span,
-}
-
-// FIXME: we can't use a reference here because to convert `try!` to `?` we
-// synthesise the AST node. However, I think we could use `Cow` and that
-// would remove a lot of cloning.
-#[derive(Debug)]
-enum ChainItemKind {
- Parent(ast::Expr),
- MethodCall(
- ast::PathSegment,
- Vec<ast::GenericArg>,
- Vec<ptr::P<ast::Expr>>,
- ),
- StructField(ast::Ident),
- TupleField(ast::Ident, bool),
- Comment(String, CommentPosition),
-}
-
-impl ChainItemKind {
- fn is_block_like(&self, context: &RewriteContext, reps: &str) -> bool {
- match self {
- ChainItemKind::Parent(ref expr) => utils::is_block_expr(context, expr, reps),
- ChainItemKind::MethodCall(..)
- | ChainItemKind::StructField(..)
- | ChainItemKind::TupleField(..)
- | ChainItemKind::Comment(..) => false,
- }
- }
-
- fn is_tup_field_access(expr: &ast::Expr) -> bool {
- match expr.node {
- ast::ExprKind::Field(_, ref field) => {
- field.name.to_string().chars().all(|c| c.is_digit(10))
- }
- _ => false,
- }
- }
-
- fn from_ast(context: &RewriteContext, expr: &ast::Expr) -> (ChainItemKind, Span) {
- let (kind, span) = match expr.node {
- ast::ExprKind::MethodCall(ref segment, ref expressions) => {
- let types = if let Some(ref generic_args) = segment.args {
- if let ast::GenericArgs::AngleBracketed(ref data) = **generic_args {
- data.args.clone()
- } else {
- vec![]
- }
- } else {
- vec![]
- };
- let span = mk_sp(expressions[0].span.hi(), expr.span.hi());
- let kind = ChainItemKind::MethodCall(segment.clone(), types, expressions.clone());
- (kind, span)
- }
- ast::ExprKind::Field(ref nested, field) => {
- let kind = if Self::is_tup_field_access(expr) {
- ChainItemKind::TupleField(field, Self::is_tup_field_access(nested))
- } else {
- ChainItemKind::StructField(field)
- };
- let span = mk_sp(nested.span.hi(), field.span.hi());
- (kind, span)
- }
- _ => return (ChainItemKind::Parent(expr.clone()), expr.span),
- };
-
- // Remove comments from the span.
- let lo = context.snippet_provider.span_before(span, ".");
- (kind, mk_sp(lo, span.hi()))
- }
-}
-
-impl Rewrite for ChainItem {
- fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
- let shape = shape.sub_width(self.tries)?;
- let rewrite = match self.kind {
- ChainItemKind::Parent(ref expr) => expr.rewrite(context, shape)?,
- ChainItemKind::MethodCall(ref segment, ref types, ref exprs) => {
- Self::rewrite_method_call(segment.ident, types, exprs, self.span, context, shape)?
- }
- ChainItemKind::StructField(ident) => format!(".{}", rewrite_ident(context, ident)),
- ChainItemKind::TupleField(ident, nested) => format!(
- "{}.{}",
- if nested { " " } else { "" },
- rewrite_ident(context, ident)
- ),
- ChainItemKind::Comment(ref comment, _) => {
- rewrite_comment(comment, false, shape, context.config)?
- }
- };
- Some(format!("{}{}", rewrite, "?".repeat(self.tries)))
- }
-}
-
-impl ChainItem {
- fn new(context: &RewriteContext, expr: &ast::Expr, tries: usize) -> ChainItem {
- let (kind, span) = ChainItemKind::from_ast(context, expr);
- ChainItem { kind, tries, span }
- }
-
- fn comment(span: Span, comment: String, pos: CommentPosition) -> ChainItem {
- ChainItem {
- kind: ChainItemKind::Comment(comment, pos),
- tries: 0,
- span,
- }
- }
-
- fn is_comment(&self) -> bool {
- match self.kind {
- ChainItemKind::Comment(..) => true,
- _ => false,
- }
- }
-
- fn rewrite_method_call(
- method_name: ast::Ident,
- types: &[ast::GenericArg],
- args: &[ptr::P<ast::Expr>],
- span: Span,
- context: &RewriteContext,
- shape: Shape,
- ) -> Option<String> {
- let type_str = if types.is_empty() {
- String::new()
- } else {
- let type_list = types
- .iter()
- .map(|ty| ty.rewrite(context, shape))
- .collect::<Option<Vec<_>>>()?;
-
- format!("::<{}>", type_list.join(", "))
- };
- let callee_str = format!(".{}{}", rewrite_ident(context, method_name), type_str);
- rewrite_call(context, &callee_str, &args[1..], span, shape)
- }
-}
-
-#[derive(Debug)]
-struct Chain {
- parent: ChainItem,
- children: Vec<ChainItem>,
-}
-
-impl Chain {
- fn from_ast(expr: &ast::Expr, context: &RewriteContext) -> Chain {
- let subexpr_list = Self::make_subexpr_list(expr, context);
-
- // Un-parse the expression tree into ChainItems
- let mut rev_children = vec![];
- let mut sub_tries = 0;
- for subexpr in &subexpr_list {
- match subexpr.node {
- ast::ExprKind::Try(_) => sub_tries += 1,
- _ => {
- rev_children.push(ChainItem::new(context, subexpr, sub_tries));
- sub_tries = 0;
- }
- }
- }
-
- fn is_tries(s: &str) -> bool {
- s.chars().all(|c| c == '?')
- }
-
- fn is_post_comment(s: &str) -> bool {
- let comment_start_index = s.chars().position(|c| c == '/');
- if comment_start_index.is_none() {
- return false;
- }
-
- let newline_index = s.chars().position(|c| c == '\n');
- if newline_index.is_none() {
- return true;
- }
-
- comment_start_index.unwrap() < newline_index.unwrap()
- }
-
- fn handle_post_comment(
- post_comment_span: Span,
- post_comment_snippet: &str,
- prev_span_end: &mut BytePos,
- children: &mut Vec<ChainItem>,
- ) {
- let white_spaces: &[_] = &[' ', '\t'];
- if post_comment_snippet
- .trim_matches(white_spaces)
- .starts_with('\n')
- {
- // No post comment.
- return;
- }
- let trimmed_snippet = trim_tries(post_comment_snippet);
- if is_post_comment(&trimmed_snippet) {
- children.push(ChainItem::comment(
- post_comment_span,
- trimmed_snippet.trim().to_owned(),
- CommentPosition::Back,
- ));
- *prev_span_end = post_comment_span.hi();
- }
- }
-
- let parent = rev_children.pop().unwrap();
- let mut children = vec![];
- let mut prev_span_end = parent.span.hi();
- let mut iter = rev_children.into_iter().rev().peekable();
- if let Some(first_chain_item) = iter.peek() {
- let comment_span = mk_sp(prev_span_end, first_chain_item.span.lo());
- let comment_snippet = context.snippet(comment_span);
- if !is_tries(comment_snippet.trim()) {
- handle_post_comment(
- comment_span,
- comment_snippet,
- &mut prev_span_end,
- &mut children,
- );
- }
- }
- while let Some(chain_item) = iter.next() {
- let comment_snippet = context.snippet(chain_item.span);
- // FIXME: Figure out the way to get a correct span when converting `try!` to `?`.
- let handle_comment =
- !(context.config.use_try_shorthand() || is_tries(comment_snippet.trim()));
-
- // Pre-comment
- if handle_comment {
- let pre_comment_span = mk_sp(prev_span_end, chain_item.span.lo());
- let pre_comment_snippet = trim_tries(context.snippet(pre_comment_span));
- let (pre_comment, _) = extract_pre_comment(&pre_comment_snippet);
- match pre_comment {
- Some(ref comment) if !comment.is_empty() => {
- children.push(ChainItem::comment(
- pre_comment_span,
- comment.to_owned(),
- CommentPosition::Top,
- ));
- }
- _ => (),
- }
- }
-
- prev_span_end = chain_item.span.hi();
- children.push(chain_item);
-
- // Post-comment
- if !handle_comment || iter.peek().is_none() {
- continue;
- }
-
- let next_lo = iter.peek().unwrap().span.lo();
- let post_comment_span = mk_sp(prev_span_end, next_lo);
- let post_comment_snippet = context.snippet(post_comment_span);
- handle_post_comment(
- post_comment_span,
- post_comment_snippet,
- &mut prev_span_end,
- &mut children,
- );
- }
-
- Chain { parent, children }
- }
-
- // Returns a Vec of the prefixes of the chain.
- // E.g., for input `a.b.c` we return [`a.b.c`, `a.b`, 'a']
- fn make_subexpr_list(expr: &ast::Expr, context: &RewriteContext) -> Vec<ast::Expr> {
- let mut subexpr_list = vec![expr.clone()];
-
- while let Some(subexpr) = Self::pop_expr_chain(subexpr_list.last().unwrap(), context) {
- subexpr_list.push(subexpr.clone());
- }
-
- subexpr_list
- }
-
- // Returns the expression's subexpression, if it exists. When the subexpr
- // is a try! macro, we'll convert it to shorthand when the option is set.
- fn pop_expr_chain(expr: &ast::Expr, context: &RewriteContext) -> Option<ast::Expr> {
- match expr.node {
- ast::ExprKind::MethodCall(_, ref expressions) => {
- Some(Self::convert_try(&expressions[0], context))
- }
- ast::ExprKind::Field(ref subexpr, _) | ast::ExprKind::Try(ref subexpr) => {
- Some(Self::convert_try(subexpr, context))
- }
- _ => None,
- }
- }
-
- fn convert_try(expr: &ast::Expr, context: &RewriteContext) -> ast::Expr {
- match expr.node {
- ast::ExprKind::Mac(ref mac) if context.config.use_try_shorthand() => {
- if let Some(subexpr) = convert_try_mac(mac, context) {
- subexpr
- } else {
- expr.clone()
- }
- }
- _ => expr.clone(),
- }
- }
-}
-
-impl Rewrite for Chain {
- fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
- debug!("rewrite chain {:?} {:?}", self, shape);
-
- let mut formatter = match context.config.indent_style() {
- IndentStyle::Block => Box::new(ChainFormatterBlock::new(self)) as Box<ChainFormatter>,
- IndentStyle::Visual => Box::new(ChainFormatterVisual::new(self)) as Box<ChainFormatter>,
- };
-
- formatter.format_root(&self.parent, context, shape)?;
- if let Some(result) = formatter.pure_root() {
- return wrap_str(result, context.config.max_width(), shape);
- }
-
- // Decide how to layout the rest of the chain.
- let child_shape = formatter.child_shape(context, shape)?;
-
- formatter.format_children(context, child_shape)?;
- formatter.format_last_child(context, shape, child_shape)?;
-
- let result = formatter.join_rewrites(context, child_shape)?;
- wrap_str(result, context.config.max_width(), shape)
- }
-}
-
-// There are a few types for formatting chains. This is because there is a lot
-// in common between formatting with block vs visual indent, but they are
-// different enough that branching on the indent all over the place gets ugly.
-// Anything that can format a chain is a ChainFormatter.
-trait ChainFormatter {
- // Parent is the first item in the chain, e.g., `foo` in `foo.bar.baz()`.
- // Root is the parent plus any other chain items placed on the first line to
- // avoid an orphan. E.g.,
- // ```ignore
- // foo.bar
- // .baz()
- // ```
- // If `bar` were not part of the root, then foo would be orphaned and 'float'.
- fn format_root(
- &mut self,
- parent: &ChainItem,
- context: &RewriteContext,
- shape: Shape,
- ) -> Option<()>;
- fn child_shape(&self, context: &RewriteContext, shape: Shape) -> Option<Shape>;
- fn format_children(&mut self, context: &RewriteContext, child_shape: Shape) -> Option<()>;
- fn format_last_child(
- &mut self,
- context: &RewriteContext,
- shape: Shape,
- child_shape: Shape,
- ) -> Option<()>;
- fn join_rewrites(&self, context: &RewriteContext, child_shape: Shape) -> Option<String>;
- // Returns `Some` if the chain is only a root, None otherwise.
- fn pure_root(&mut self) -> Option<String>;
-}
-
-// Data and behaviour that is shared by both chain formatters. The concrete
-// formatters can delegate much behaviour to `ChainFormatterShared`.
-struct ChainFormatterShared<'a> {
- // The current working set of child items.
- children: &'a [ChainItem],
- // The current rewrites of items (includes trailing `?`s, but not any way to
- // connect the rewrites together).
- rewrites: Vec<String>,
- // Whether the chain can fit on one line.
- fits_single_line: bool,
- // The number of children in the chain. This is not equal to `self.children.len()`
- // because `self.children` will change size as we process the chain.
- child_count: usize,
-}
-
-impl<'a> ChainFormatterShared<'a> {
- fn new(chain: &'a Chain) -> ChainFormatterShared<'a> {
- ChainFormatterShared {
- children: &chain.children,
- rewrites: Vec::with_capacity(chain.children.len() + 1),
- fits_single_line: false,
- child_count: chain.children.len(),
- }
- }
-
- fn pure_root(&mut self) -> Option<String> {
- if self.children.is_empty() {
- assert_eq!(self.rewrites.len(), 1);
- Some(self.rewrites.pop().unwrap())
- } else {
- None
- }
- }
-
- // Rewrite the last child. The last child of a chain requires special treatment. We need to
- // know whether 'overflowing' the last child make a better formatting:
- //
- // A chain with overflowing the last child:
- // ```ignore
- // parent.child1.child2.last_child(
- // a,
- // b,
- // c,
- // )
- // ```
- //
- // A chain without overflowing the last child (in vertical layout):
- // ```ignore
- // parent
- // .child1
- // .child2
- // .last_child(a, b, c)
- // ```
- //
- // In particular, overflowing is effective when the last child is a method with a multi-lined
- // block-like argument (e.g. closure):
- // ```ignore
- // parent.child1.child2.last_child(|a, b, c| {
- // let x = foo(a, b, c);
- // let y = bar(a, b, c);
- //
- // // ...
- //
- // result
- // })
- // ```
- fn format_last_child(
- &mut self,
- may_extend: bool,
- context: &RewriteContext,
- shape: Shape,
- child_shape: Shape,
- ) -> Option<()> {
- let last = self.children.last()?;
- let extendable = may_extend && last_line_extendable(&self.rewrites[0]);
- let prev_last_line_width = last_line_width(&self.rewrites[0]);
-
- // Total of all items excluding the last.
- let almost_total = if extendable {
- prev_last_line_width
- } else {
- self.rewrites.iter().fold(0, |a, b| a + b.len())
- } + last.tries;
- let one_line_budget = if self.child_count == 1 {
- shape.width
- } else {
- min(shape.width, context.config.width_heuristics().chain_width)
- }
- .saturating_sub(almost_total);
-
- let all_in_one_line = !self.children.iter().any(ChainItem::is_comment)
- && self.rewrites.iter().all(|s| !s.contains('\n'))
- && one_line_budget > 0;
- let last_shape = if all_in_one_line {
- shape.sub_width(last.tries)?
- } else if extendable {
- child_shape.sub_width(last.tries)?
- } else {
- child_shape.sub_width(shape.rhs_overhead(context.config) + last.tries)?
- };
-
- let mut last_subexpr_str = None;
- if all_in_one_line || extendable {
- // First we try to 'overflow' the last child and see if it looks better than using
- // vertical layout.
- let one_line_shape = if context.use_block_indent() {
- last_shape.offset_left(almost_total)
- } else {
- last_shape
- .visual_indent(almost_total)
- .sub_width(almost_total)
- };
-
- if let Some(one_line_shape) = one_line_shape {
- if let Some(rw) = last.rewrite(context, one_line_shape) {
- // We allow overflowing here only if both of the following conditions match:
- // 1. The entire chain fits in a single line except the last child.
- // 2. `last_child_str.lines().count() >= 5`.
- let line_count = rw.lines().count();
- let could_fit_single_line = first_line_width(&rw) <= one_line_budget;
- if could_fit_single_line && line_count >= 5 {
- last_subexpr_str = Some(rw);
- self.fits_single_line = all_in_one_line;
- } else {
- // We could not know whether overflowing is better than using vertical
- // layout, just by looking at the overflowed rewrite. Now we rewrite the
- // last child on its own line, and compare two rewrites to choose which is
- // better.
- let last_shape = child_shape
- .sub_width(shape.rhs_overhead(context.config) + last.tries)?;
- match last.rewrite(context, last_shape) {
- Some(ref new_rw) if !could_fit_single_line => {
- last_subexpr_str = Some(new_rw.clone());
- }
- Some(ref new_rw) if new_rw.lines().count() >= line_count => {
- last_subexpr_str = Some(rw);
- self.fits_single_line = could_fit_single_line && all_in_one_line;
- }
- new_rw @ Some(..) => {
- last_subexpr_str = new_rw;
- }
- _ => {
- last_subexpr_str = Some(rw);
- self.fits_single_line = could_fit_single_line && all_in_one_line;
- }
- }
- }
- }
- }
- }
-
- let last_shape = if context.use_block_indent() {
- last_shape
- } else {
- child_shape.sub_width(shape.rhs_overhead(context.config) + last.tries)?
- };
-
- last_subexpr_str = last_subexpr_str.or_else(|| last.rewrite(context, last_shape));
- self.rewrites.push(last_subexpr_str?);
- Some(())
- }
-
- fn join_rewrites(&self, context: &RewriteContext, child_shape: Shape) -> Option<String> {
- let connector = if self.fits_single_line {
- // Yay, we can put everything on one line.
- Cow::from("")
- } else {
- // Use new lines.
- if *context.force_one_line_chain.borrow() {
- return None;
- }
- child_shape.to_string_with_newline(context.config)
- };
-
- let mut rewrite_iter = self.rewrites.iter();
- let mut result = rewrite_iter.next().unwrap().clone();
- let children_iter = self.children.iter();
- let iter = rewrite_iter.zip(children_iter);
-
- for (rewrite, chain_item) in iter {
- match chain_item.kind {
- ChainItemKind::Comment(_, CommentPosition::Back) => result.push(' '),
- ChainItemKind::Comment(_, CommentPosition::Top) => result.push_str(&connector),
- _ => result.push_str(&connector),
- }
- result.push_str(&rewrite);
- }
-
- Some(result)
- }
-}
-
-// Formats a chain using block indent.
-struct ChainFormatterBlock<'a> {
- shared: ChainFormatterShared<'a>,
- root_ends_with_block: bool,
-}
-
-impl<'a> ChainFormatterBlock<'a> {
- fn new(chain: &'a Chain) -> ChainFormatterBlock<'a> {
- ChainFormatterBlock {
- shared: ChainFormatterShared::new(chain),
- root_ends_with_block: false,
- }
- }
-}
-
-impl<'a> ChainFormatter for ChainFormatterBlock<'a> {
- fn format_root(
- &mut self,
- parent: &ChainItem,
- context: &RewriteContext,
- shape: Shape,
- ) -> Option<()> {
- let mut root_rewrite: String = parent.rewrite(context, shape)?;
-
- let mut root_ends_with_block = parent.kind.is_block_like(context, &root_rewrite);
- let tab_width = context.config.tab_spaces().saturating_sub(shape.offset);
-
- while root_rewrite.len() <= tab_width && !root_rewrite.contains('\n') {
- let item = &self.shared.children[0];
- if let ChainItemKind::Comment(..) = item.kind {
- break;
- }
- let shape = shape.offset_left(root_rewrite.len())?;
- match &item.rewrite(context, shape) {
- Some(rewrite) => root_rewrite.push_str(rewrite),
- None => break,
- }
-
- root_ends_with_block = last_line_extendable(&root_rewrite);
-
- self.shared.children = &self.shared.children[1..];
- if self.shared.children.is_empty() {
- break;
- }
- }
- self.shared.rewrites.push(root_rewrite);
- self.root_ends_with_block = root_ends_with_block;
- Some(())
- }
-
- fn child_shape(&self, context: &RewriteContext, shape: Shape) -> Option<Shape> {
- Some(
- if self.root_ends_with_block {
- shape.block_indent(0)
- } else {
- shape.block_indent(context.config.tab_spaces())
- }
- .with_max_width(context.config),
- )
- }
-
- fn format_children(&mut self, context: &RewriteContext, child_shape: Shape) -> Option<()> {
- for item in &self.shared.children[..self.shared.children.len() - 1] {
- let rewrite = item.rewrite(context, child_shape)?;
- self.shared.rewrites.push(rewrite);
- }
- Some(())
- }
-
- fn format_last_child(
- &mut self,
- context: &RewriteContext,
- shape: Shape,
- child_shape: Shape,
- ) -> Option<()> {
- self.shared
- .format_last_child(true, context, shape, child_shape)
- }
-
- fn join_rewrites(&self, context: &RewriteContext, child_shape: Shape) -> Option<String> {
- self.shared.join_rewrites(context, child_shape)
- }
-
- fn pure_root(&mut self) -> Option<String> {
- self.shared.pure_root()
- }
-}
-
-// Format a chain using visual indent.
-struct ChainFormatterVisual<'a> {
- shared: ChainFormatterShared<'a>,
- // The extra offset from the chain's shape to the position of the `.`
- offset: usize,
-}
-
-impl<'a> ChainFormatterVisual<'a> {
- fn new(chain: &'a Chain) -> ChainFormatterVisual<'a> {
- ChainFormatterVisual {
- shared: ChainFormatterShared::new(chain),
- offset: 0,
- }
- }
-}
-
-impl<'a> ChainFormatter for ChainFormatterVisual<'a> {
- fn format_root(
- &mut self,
- parent: &ChainItem,
- context: &RewriteContext,
- shape: Shape,
- ) -> Option<()> {
- let parent_shape = shape.visual_indent(0);
- let mut root_rewrite = parent.rewrite(context, parent_shape)?;
- let multiline = root_rewrite.contains('\n');
- self.offset = if multiline {
- last_line_width(&root_rewrite).saturating_sub(shape.used_width())
- } else {
- trimmed_last_line_width(&root_rewrite)
- };
-
- if !multiline || parent.kind.is_block_like(context, &root_rewrite) {
- let item = &self.shared.children[0];
- if let ChainItemKind::Comment(..) = item.kind {
- self.shared.rewrites.push(root_rewrite);
- return Some(());
- }
- let child_shape = parent_shape
- .visual_indent(self.offset)
- .sub_width(self.offset)?;
- let rewrite = item.rewrite(context, child_shape)?;
- match wrap_str(rewrite, context.config.max_width(), shape) {
- Some(rewrite) => root_rewrite.push_str(&rewrite),
- None => {
- // We couldn't fit in at the visual indent, try the last
- // indent.
- let rewrite = item.rewrite(context, parent_shape)?;
- root_rewrite.push_str(&rewrite);
- self.offset = 0;
- }
- }
-
- self.shared.children = &self.shared.children[1..];
- }
-
- self.shared.rewrites.push(root_rewrite);
- Some(())
- }
-
- fn child_shape(&self, context: &RewriteContext, shape: Shape) -> Option<Shape> {
- shape
- .with_max_width(context.config)
- .offset_left(self.offset)
- .map(|s| s.visual_indent(0))
- }
-
- fn format_children(&mut self, context: &RewriteContext, child_shape: Shape) -> Option<()> {
- for item in &self.shared.children[..self.shared.children.len() - 1] {
- let rewrite = item.rewrite(context, child_shape)?;
- self.shared.rewrites.push(rewrite);
- }
- Some(())
- }
-
- fn format_last_child(
- &mut self,
- context: &RewriteContext,
- shape: Shape,
- child_shape: Shape,
- ) -> Option<()> {
- self.shared
- .format_last_child(false, context, shape, child_shape)
- }
-
- fn join_rewrites(&self, context: &RewriteContext, child_shape: Shape) -> Option<String> {
- self.shared.join_rewrites(context, child_shape)
- }
-
- fn pure_root(&mut self) -> Option<String> {
- self.shared.pure_root()
- }
-}
-
-/// Remove try operators (`?`s) that appear in the given string. If removing
-/// them leaves an empty line, remove that line as well unless it is the first
-/// line (we need the first newline for detecting pre/post comment).
-fn trim_tries(s: &str) -> String {
- let mut result = String::with_capacity(s.len());
- let mut line_buffer = String::with_capacity(s.len());
- for (kind, rich_char) in CharClasses::new(s.chars()) {
- match rich_char.get_char() {
- '\n' => {
- if result.is_empty() || !line_buffer.trim().is_empty() {
- result.push_str(&line_buffer);
- result.push('\n')
- }
- line_buffer.clear();
- }
- '?' if kind == FullCodeCharKind::Normal => continue,
- c => line_buffer.push(c),
- }
- }
- if !line_buffer.trim().is_empty() {
- result.push_str(&line_buffer);
- }
- result
-}
diff --git a/homework/81030/1,2-rust2html/example-ugly.rs b/homework/81030/1,2-rust2html/example-ugly.rs
deleted file mode 100644
index 2b17e2f..0000000
--- a/homework/81030/1,2-rust2html/example-ugly.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * The following function returns the first answer.
- * It takes no arguments and returns an unsigned integer.
- */
-fn answer1 () -> usize {
- return 42; // answer to the Ultimate Question of Life, the Universe, and Everything
-}
-/*
- * The following function returns the second answer.
- * It takes no arguments and returns a floating-point number.
- */
-fn answer2( ) -> f64
-{
- return -4.2;
-}
-
-/*
- * The following function returns the third answer.
- * It takes no arguments and returns a single character.
- */
-fn answer3() -> char {
- return 'E' ; }
-
-
-fn main( ) {
- println! ("The \"First Answer\" is: '{}'", answer1( ) );
- println!("The \"Second Answer\" is: '{}'" , answer2()) ;
- println!( "The \"Third Answer\" is: '{}'" , answer3 () );
-}
diff --git a/homework/81030/1,2-rust2html/example.rs b/homework/81030/1,2-rust2html/example.rs
deleted file mode 100644
index 396aa0c..0000000
--- a/homework/81030/1,2-rust2html/example.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * The following function returns the first answer.
- * It takes no arguments and returns an unsigned integer.
- */
-fn answer1() -> usize {
- return 42; // answer to the Ultimate Question of Life, the Universe, and Everything
-}
-
-/*
- * The following function returns the second answer.
- * It takes no arguments and returns a floating-point number.
- */
-fn answer2() -> f64 {
- return -4.2;
-}
-
-/*
- * The following function returns the third answer.
- * It takes no arguments and returns a single character.
- */
-fn answer3() -> char {
- return 'E';
-}
-
-fn main() {
- println!("The \"First Answer\" is: '{}'", answer1());
- println!("The \"Second Answer\" is: '{}'", answer2());
- println!("The \"Third Answer\" is: '{}'", answer3());
-}
diff --git a/homework/81030/1,2-rust2html/rust2html-prettyprint.l b/homework/81030/1,2-rust2html/rust2html-prettyprint.l
deleted file mode 100644
index 2d90931..0000000
--- a/homework/81030/1,2-rust2html/rust2html-prettyprint.l
+++ /dev/null
@@ -1,344 +0,0 @@
-%option nounistd
-%option noyywrap
-%option stack
-
-%{
-#include <stdbool.h>
-
-#define INDENTATION " "
-#define SPACE " "
-#define HIGHLIGHT_TERMINATOR "</span>"
-
-#define PRINT_HIGHLIGHTED_TOKEN_INITIATOR(type) \
- printf("<span class=\"" #type "\">%s", yytext)
-
-#define PRINT_HIGHLIGHTED_TOKEN_TERMINATOR \
- printf("%s" HIGHLIGHT_TERMINATOR, yytext)
-
-#define PRINT_HIGHLIGHTED_TOKEN(type) \
- printf("<span class=\"" #type "\">%s</span>", yytext)
-
-#define PRINT_TOKEN \
- printf("%s", yytext)
-
-#define PRINT_INDENTED_NEWLINE \
- printf("\n"); \
- for (int i = 0; i < indentation_level; i++) \
- printf(INDENTATION)
-
-#define CLEAR_MODES \
- require_space_mode = false; \
- adjacent_parenthesis_mode = false
-
-#define HANDLE_COMMENT_INITIATOR(type) \
- PRINT_HIGHLIGHTED_TOKEN_INITIATOR(comment); \
- yy_push_state(type); \
- CLEAR_MODES
-
-#define HANDLE_LITERAL(type) \
- if (require_space_mode) \
- printf(SPACE); \
- PRINT_HIGHLIGHTED_TOKEN(type); \
- require_space_mode = true; \
- adjacent_parenthesis_mode = false
-
-#define HANDLE_IDENTIFIER \
- if (require_space_mode) \
- printf(SPACE); \
- PRINT_HIGHLIGHTED_TOKEN(identifier); \
- require_space_mode = true; \
- adjacent_parenthesis_mode = true
-
-#define HANDLE_EOL \
- yy_pop_state(); \
- adjacent_parenthesis_mode = true; \
- yyless(0)
-
-static int indentation_level = 0;
-static bool require_space_mode = false;
-static bool adjacent_parenthesis_mode = false;
-%}
-
-%s multiline_list
-%s path
-%s directive
-
-%x line_comment
-%x block_comment
-%x eol
-
-NONEOL_CHAR .
-DEC_DIGIT 0|{NONZERO_DEC_DIGIT}
-NONZERO_DEC_DIGIT [1-9]
-OCT_DIGIT [0-7]
-HEX_DIGIT {DEC_DIGIT}|[a-fA-F]
-
-IDENTIFIER {IDENTIFIER_FIRST_CHAR}({DEC_DIGIT}|{IDENTIFIER_FIRST_CHAR})*
-IDENTIFIER_FIRST_CHAR [A-Za-z_]
-
-LINE_COMMENT_BEGIN "//"
-BLOCK_COMMENT_INITIATOR "/*"
-BLOCK_COMMENT_TERMINATOR "*/"
-
-KEYWORD _|abstract|alignof|as|become|box|break|const|continue|crate|do|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|offsetof|override|priv|proc|pub|pure|ref|return|Self|self|sizeof|static|struct|super|trait|true|type|typeof|unsafe|unsized|use|virtual|where|while|yield
-
-ESCAPE {COMMON_ESCAPE}|{UNICODE_ESCAPE}
-COMMON_ESCAPE \\|n|r|t|0|x{HEX_DIGIT}{2}
-UNICODE_ESCAPE "u{"{HEX_DIGIT}{6}"}"
-
-CHAR_LITERAL '{CHAR_BODY}'
-CHAR_BODY [^']|(\\('|{ESCAPE}))
-STRING_LITERAL \"{STRING_BODY}*\"
-STRING_BODY [^\"]|(\\(\"|{ESCAPE}))
-BYTE_CHAR_LITERAL b'{BYTE_CHAR_BODY}'
-BYTE_CHAR_BODY [^']|(\\('|{COMMON_ESCAPE}))
-BYTE_STRING_LITERAL b\"{BYTE_STRING_BODY}*\"
-BYTE_STRING_BODY [^\"]|(\\(\"|{ESCAPE}))
-
-NUMBER_LITERAL {NONZERO_DEC_DIGIT}{DEC_DIGIT}*{FLOAT_SUFFIX}?|(0{DEC_DIGIT_LITERAL}*{FLOAT_SUFFIX}?|b[10_]+|o{OCT_DIGIT_LITERAL}+|x{HEX_DIGIT_LITERAL}+)
-FLOAT_SUFFIX {EXPONENT}|"."{DEC_DIGIT_LITERAL}+{EXPONENT}?
-EXPONENT [Ee][-+]?{DEC_DIGIT_LITERAL}+
-DEC_DIGIT_LITERAL {DEC_DIGIT}|_
-HEX_DIGIT_LITERAL {HEX_DIGIT}|_
-OCT_DIGIT_LITERAL {OCT_DIGIT}|_
-
-%%
-
-<eol>[[:space:]]+
-
-<eol>";"|"}" {
- HANDLE_EOL;
-}
-
-<eol>"else" {
- HANDLE_EOL;
- printf(SPACE);
-}
-
-<eol>. {
- HANDLE_EOL;
- PRINT_INDENTED_NEWLINE;
-}
-
-<line_comment>[[:blank:]]*\n {
- yy_pop_state();
- printf(HIGHLIGHT_TERMINATOR);
- yy_push_state(eol);
-}
-
-<block_comment>{BLOCK_COMMENT_TERMINATOR} {
- yy_pop_state();
- PRINT_HIGHLIGHTED_TOKEN_TERMINATOR;
- yy_push_state(eol);
-}
-
-<line_comment>. {
- PRINT_TOKEN;
-}
-
-<block_comment>(.|\n) {
- PRINT_TOKEN;
-}
-
-[[:space:]]+
-
-"use" {
- HANDLE_LITERAL(keyword);
- yy_push_state(path);
-}
-
-{KEYWORD} {
- HANDLE_LITERAL(keyword);
-}
-
-{IDENTIFIER} {
- HANDLE_IDENTIFIER;
-}
-
-{NUMBER_LITERAL} {
- HANDLE_LITERAL(number);
-}
-
-{CHAR_LITERAL}|{STRING_LITERAL}|{BYTE_CHAR_LITERAL}|{BYTE_STRING_LITERAL} {
- HANDLE_LITERAL(string);
-}
-
-{LINE_COMMENT_BEGIN} {
- HANDLE_COMMENT_INITIATOR(line_comment);
-}
-
-{BLOCK_COMMENT_INITIATOR} {
- HANDLE_COMMENT_INITIATOR(block_comment);
-}
-
-<multiline_list>"," {
- PRINT_HIGHLIGHTED_TOKEN(symbol);
- CLEAR_MODES;
- yy_push_state(eol);
-}
-
-","|":" {
- PRINT_HIGHLIGHTED_TOKEN(symbol);
- require_space_mode = true;
- adjacent_parenthesis_mode = false;
-}
-
-<path>";" {
- yy_pop_state();
- PRINT_HIGHLIGHTED_TOKEN(symbol);
- CLEAR_MODES;
- yy_push_state(eol);
-}
-
-";" {
- PRINT_HIGHLIGHTED_TOKEN(symbol);
- CLEAR_MODES;
- yy_push_state(eol);
-}
-
-"#" {
- PRINT_HIGHLIGHTED_TOKEN(symbol);
- CLEAR_MODES;
- yy_push_state(directive);
-}
-
-"?" {
- PRINT_HIGHLIGHTED_TOKEN(symbol);
- require_space_mode = true;
- adjacent_parenthesis_mode = false;
-}
-
-"!" {
- PRINT_HIGHLIGHTED_TOKEN(symbol);
- require_space_mode = false;
- adjacent_parenthesis_mode = true;
-}
-
-"."|"::"|"'"|"$"|"@"|"~" {
- PRINT_HIGHLIGHTED_TOKEN(symbol);
- CLEAR_MODES;
-}
-
-"=="|"=>"|"="|"!="|"<="|"<<"|"<<="|"<"|">="|">>"|">>="|">"|"<-"|"->"|"-"|"-="|"&&"|"&"|"&="|"||"|"|"|"|="|"+"|"+="|"*"|"*="|"/"|"/="|"^"|"^="|"%"|"%="|".."|"..." {
- printf(SPACE);
- PRINT_HIGHLIGHTED_TOKEN(symbol);
- require_space_mode = true;
- adjacent_parenthesis_mode = false;
-}
-
-"(" {
- if (!adjacent_parenthesis_mode)
- printf(SPACE);
- PRINT_HIGHLIGHTED_TOKEN(symbol);
- CLEAR_MODES;
- yy_push_state(INITIAL);
-}
-
-<directive>"[" {
- PRINT_HIGHLIGHTED_TOKEN(symbol);
- CLEAR_MODES;
-}
-
-"[" {
- PRINT_HIGHLIGHTED_TOKEN(symbol);
- CLEAR_MODES;
- yy_push_state(INITIAL);
-}
-
-<directive>"]" {
- yy_pop_state();
- PRINT_HIGHLIGHTED_TOKEN(symbol);
- CLEAR_MODES;
- yy_push_state(eol);
-}
-
-")"|"]" {
- yy_pop_state();
- PRINT_HIGHLIGHTED_TOKEN(symbol);
- require_space_mode = true;
- adjacent_parenthesis_mode = false;
-}
-
-<path>"{" {
- PRINT_HIGHLIGHTED_TOKEN(symbol);
- CLEAR_MODES;
-}
-
-"{" {
- if (require_space_mode)
- printf(SPACE);
- indentation_level++;
- PRINT_HIGHLIGHTED_TOKEN(symbol);
- CLEAR_MODES;
- yy_push_state(multiline_list);
- yy_push_state(eol);
-}
-
-<path>"}" {
- yy_pop_state();
- PRINT_HIGHLIGHTED_TOKEN(symbol);
- CLEAR_MODES;
-}
-
-"}" {
- yy_pop_state();
- indentation_level--;
- PRINT_INDENTED_NEWLINE;
- PRINT_HIGHLIGHTED_TOKEN(symbol);
- if (0 == indentation_level)
- printf("\n");
- CLEAR_MODES;
- yy_push_state(eol);
-}
-
-. {
- PRINT_TOKEN; /* echo the rest */
-}
-
-%%
-
-int main(int argc, const char* const argv[]) {
- yyin = argc > 1 ? fopen(argv[1], "r") : stdin;
-
- printf(
- "<!DOCTYPE html>\n"
- "<html>\n"
- "\n"
- "<head>\n"
- " <style>\n"
- " .comment {\n"
- " color: gray;\n"
- " }\n"
- "\n"
- " .keyword {\n"
- " color: red;\n"
- " }\n"
- "\n"
- " .string {\n"
- " color: green;\n"
- " }\n"
- "\n"
- " .number {\n"
- " color: blue;\n"
- " }\n"
- "\n"
- " .symbol {\n"
- " font-weight: bold;\n"
- " }\n"
- " </style>\n"
- "</head>\n"
- "\n"
- "<body>\n"
- " <pre class=\"code\">\n"
- );
- yylex();
- printf(
- "\n"
- " </pre>\n"
- "</body>\n"
- "\n"
- "</html>"
- );
-
- return 0;
-}
diff --git a/homework/81030/1,2-rust2html/rust2html.l b/homework/81030/1,2-rust2html/rust2html.l
deleted file mode 100644
index de49285..0000000
--- a/homework/81030/1,2-rust2html/rust2html.l
+++ /dev/null
@@ -1,130 +0,0 @@
-%option nounistd
-%option noyywrap
-
-%{
-#define PRINT_HIGHLIGHTED_TOKEN(type) \
- printf("<span class=\"" #type "\">%s</span>", yytext)
-%}
-
-NONEOL_CHAR .
-DEC_DIGIT 0|{NONZERO_DEC_DIGIT}
-NONZERO_DEC_DIGIT [1-9]
-OCT_DIGIT [0-7]
-HEX_DIGIT {DEC_DIGIT}|[a-fA-F]
-
-IDENTIFIER {IDENTIFIER_FIRST_CHAR}({DEC_DIGIT}|{IDENTIFIER_FIRST_CHAR})*
-IDENTIFIER_FIRST_CHAR [A-Za-z_]
-
-LINE_COMMENT "//"{NONEOL_CHAR}*
-BLOCK_COMMENT_INITIATOR "/*"
-BLOCK_COMMENT_TERMINATOR "*/"
-
-KEYWORD _|abstract|alignof|as|become|box|break|const|continue|crate|do|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|offsetof|override|priv|proc|pub|pure|ref|return|Self|self|sizeof|static|struct|super|trait|true|type|typeof|unsafe|unsized|use|virtual|where|while|yield
-
-ESCAPE {COMMON_ESCAPE}|{UNICODE_ESCAPE}
-COMMON_ESCAPE \\|n|r|t|0|x{HEX_DIGIT}{2}
-UNICODE_ESCAPE "u{"{HEX_DIGIT}{6}"}"
-
-CHAR_LITERAL '{CHAR_BODY}'
-CHAR_BODY [^']|(\\('|{ESCAPE}))
-STRING_LITERAL \"{STRING_BODY}*\"
-STRING_BODY [^\"]|(\\(\"|{ESCAPE}))
-BYTE_CHAR_LITERAL b'{BYTE_CHAR_BODY}'
-BYTE_CHAR_BODY [^']|(\\('|{COMMON_ESCAPE}))
-BYTE_STRING_LITERAL b\"{BYTE_STRING_BODY}*\"
-BYTE_STRING_BODY [^\"]|(\\(\"|{ESCAPE}))
-
-NUMBER_LITERAL {NONZERO_DEC_DIGIT}{DEC_DIGIT}*{FLOAT_SUFFIX}?|(0{DEC_DIGIT_LITERAL}*{FLOAT_SUFFIX}?|b[10_]+|o{OCT_DIGIT_LITERAL}+|x{HEX_DIGIT_LITERAL}+)
-FLOAT_SUFFIX {EXPONENT}|"."{DEC_DIGIT_LITERAL}+{EXPONENT}?
-EXPONENT [Ee][-+]?{DEC_DIGIT_LITERAL}+
-DEC_DIGIT_LITERAL {DEC_DIGIT}|_
-HEX_DIGIT_LITERAL {HEX_DIGIT}|_
-OCT_DIGIT_LITERAL {OCT_DIGIT}|_
-
-SYMBOL "::"|"->"|"#"|"["|"]"|"("|")"|"{"|"}"|","|";"|":"|"?"|"!"|"."|"'"|"$"|"@"|"~"|"=="|"=>"|"="|"!="|"<="|"<<"|"<<="|"<"|">="|">>"|">>="|">"|"<-"|"-"|"-="|"&&"|"&"|"&="|"||"|"|"|"|="|"+"|"+="|"*"|"*="|"/"|"/="|"^"|"^="|"%"|"%="|".."|"..."
-
-%%
-
-{SYMBOL} {
- PRINT_HIGHLIGHTED_TOKEN(symbol);
-}
-
-{KEYWORD} {
- PRINT_HIGHLIGHTED_TOKEN(keyword);
-}
-
-{IDENTIFIER} {
- PRINT_HIGHLIGHTED_TOKEN(identifier);
-}
-
-{NUMBER_LITERAL} {
- PRINT_HIGHLIGHTED_TOKEN(number);
-}
-
-{CHAR_LITERAL}|{STRING_LITERAL}|{BYTE_CHAR_LITERAL}|{BYTE_STRING_LITERAL} {
- PRINT_HIGHLIGHTED_TOKEN(string);
-}
-
-{LINE_COMMENT} {
- PRINT_HIGHLIGHTED_TOKEN(comment);
-}
-
-{BLOCK_COMMENT_INITIATOR} {
- printf("<span class=\"comment\">%s", yytext);
-}
-
-{BLOCK_COMMENT_TERMINATOR} {
- printf("%s</span>", yytext);
-}
-
-. {
- printf("%s", yytext); /* echo the rest */
-}
-
-%%
-
-int main(int argc, const char* const argv[]) {
- yyin = argc > 1 ? fopen(argv[1], "r") : stdin;
-
- printf(
- "<!DOCTYPE html>\n"
- "<html>\n"
- "\n"
- "<head>\n"
- " <style>\n"
- " .comment {\n"
- " color: gray;\n"
- " }\n"
- "\n"
- " .keyword {\n"
- " color: red;\n"
- " }\n"
- "\n"
- " .string {\n"
- " color: green;\n"
- " }\n"
- "\n"
- " .number {\n"
- " color: blue;\n"
- " }\n"
- "\n"
- " .symbol {\n"
- " font-weight: bold;\n"
- " }\n"
- " </style>\n"
- "</head>\n"
- "\n"
- "<body>\n"
- " <pre class=\"code\">\n"
- );
- yylex();
- printf(
- "\n"
- " </pre>\n"
- "</body>\n"
- "\n"
- "</html>"
- );
-
- return 0;
-}
diff --git a/homework/81248/.gitignore b/homework/81248/.gitignore
deleted file mode 100644
index 03c5d2f..0000000
--- a/homework/81248/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.stack-work/
-*~
-*.swp
diff --git a/homework/81248/README.md b/homework/81248/README.md
deleted file mode 100644
index 829ece8..0000000
--- a/homework/81248/README.md
+++ /dev/null
@@ -1,28 +0,0 @@
-# Георги Любенов – 81248
-
-## Stack
-За разработването на `Haskell` често се използва инструментът `Stack`.
-
-Той се опитва да предостави възпроизведимо компилиране и се грижи за всякакви зависимости.
-
-В общия случай ще гледам да наглася папките, така че да може да се влезе в корена (демек `81248`),
-и да се пусне `stack run X`, за да се пусне програмата `X`. От [тук][Stack] може да свалите инструмента.
-
-Например:
-```
-stack run cToHtml
-```
-
-Ще пусне `cToHtml` инструмента, който конвертира `C` файл към оцветен `HTML`.
-При пускане инструментите ще дават повече информация за тяхното ползване.
-
-Ако желаете, можете да "инсталирате" съответния инструмент във вашия `PATH`, използвайки `stack install`
-(просто го копира в някаква юзърска директория, която се намира в `PATH` стандартно).
-
-Първото пускане на инструмента/дадена програма ще отнеме повече време (~15m), защото трябва да свали компилатор
-и да компилира всичките библиотеки (и съответно програмата), които ще ползва.
-
-**N.B.** Ако ще инсталирате `Stack` от вашия пакетен мениджър, пуснете `stack upgrade`, защото версийте на
-`Stack` в повечето дистрибуции са много стари. (`Stack` поддържа `stack run` командата само от `1.9.1` - скорошна версия)
-
-[Stack]: https://docs.haskellstack.org/en/stable/README/
diff --git a/homework/81248/brainfsck/.gitignore b/homework/81248/brainfsck/.gitignore
deleted file mode 100644
index 0064636..0000000
--- a/homework/81248/brainfsck/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.stack-work/
-brainfsck.cabal
-*~
diff --git a/homework/81248/brainfsck/README.md b/homework/81248/brainfsck/README.md
deleted file mode 100644
index c6b1f9a..0000000
--- a/homework/81248/brainfsck/README.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# brainfsck
-
-To run the interpreter, start `brainfsck` with one argument - the path to a brainfuck script.
-
-i.e.
-```
-stack run brainfsck -- asdf.bf
-```
diff --git a/homework/81248/brainfsck/Setup.hs b/homework/81248/brainfsck/Setup.hs
deleted file mode 100644
index 9a994af..0000000
--- a/homework/81248/brainfsck/Setup.hs
+++ /dev/null
@@ -1,2 +0,0 @@
-import Distribution.Simple
-main = defaultMain
diff --git a/homework/81248/brainfsck/app/Main.hs b/homework/81248/brainfsck/app/Main.hs
deleted file mode 100644
index de56a4f..0000000
--- a/homework/81248/brainfsck/app/Main.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-module Main
- ( main
- ) where
-
-import qualified Data.ByteString as BS
-
-import System.Environment
-
-import Brainfsck.Eval (eval)
-import Brainfsck.Parse (parse)
-
-main :: IO ()
-main = do
- xs <- getArgs
- if length xs /= 1
- then putStrLn usage
- else either fail eval . parse =<< BS.readFile (head xs)
-
-usage :: String
-usage = "Usage: Start brainfsck with one argument - the path to a brainfuck script.\n\
- \> stack run brainfsck -- asdf.bf"
diff --git a/homework/81248/brainfsck/asdf.bf b/homework/81248/brainfsck/asdf.bf
deleted file mode 100644
index d71248a..0000000
--- a/homework/81248/brainfsck/asdf.bf
+++ /dev/null
@@ -1,2 +0,0 @@
->++++++++[-<+++++++++>]<.>>+>-[+]++>++>+++[>[->+++<<+++>]<<]>-----.>->
-+++..+++.>-.<<+[>[+>+]>>]<--------------.>>.+++.------.--------.>+.>+.
diff --git a/homework/81248/brainfsck/package.yaml b/homework/81248/brainfsck/package.yaml
deleted file mode 100644
index 1db06fd..0000000
--- a/homework/81248/brainfsck/package.yaml
+++ /dev/null
@@ -1,32 +0,0 @@
-name: brainfsck
-version: 0.0.0.1
-author: "Georgi Lyubenov"
-maintainer: "godzbanebane@gmail.com"
-
-extra-source-files:
-- README.md
-
-description: brainfsck!
-
-dependencies:
-- base >= 4.7 && < 5
-- attoparsec
-- bytestring
-
-ghc-options:
-- -Werror
-- -Wall
-
-library:
- source-dirs: src
-
-executables:
- brainfsck:
- main: Main.hs
- source-dirs: app
- ghc-options:
- - -threaded
- - -rtsopts
- - -with-rtsopts=-N
- dependencies:
- - brainfsck
diff --git a/homework/81248/brainfsck/src/Brainfsck/Eval.hs b/homework/81248/brainfsck/src/Brainfsck/Eval.hs
deleted file mode 100644
index 10ffb75..0000000
--- a/homework/81248/brainfsck/src/Brainfsck/Eval.hs
+++ /dev/null
@@ -1,35 +0,0 @@
-{-# OPTIONS -fno-warn-incomplete-patterns #-}
-
-module Brainfsck.Eval
- ( eval
- ) where
-
-import Control.Monad (void, foldM)
-
-import Data.Char (chr, ord)
-
-import Brainfsck.Types
-
-(?) :: (a -> b -> c) -> b -> a -> c
-(?) = flip
-
--- We know we never reach [], because we only call this with infinite tapes.
-operTape :: Expr -> Tape -> IO Tape
-operTape GoRight (Tape ls x (r:rs)) = pure $ Tape (x:ls) r rs
-operTape GoLeft (Tape (l:ls) x rs) = pure $ Tape ls l (x:rs)
-operTape Incr (Tape ls x rs) = pure $ Tape ls (succ x) rs
-operTape Decr (Tape ls x rs) = pure $ Tape ls (pred x) rs
-operTape Out t@(Tape _ x _) = t <$ do putChar $ chr x
-operTape In (Tape ls _ rs) = (Tape ls ? rs) . ord <$> getChar
-operTape l@(Loop xs) t@(Tape _ x _) =
- if x == 0 then pure t
- else do
- tn@(Tape _ x' _) <- evalTape xs t
- if x' /= 0 then operTape l tn
- else pure tn
-
-evalTape :: [Expr] -> Tape -> IO Tape
-evalTape xs t = foldM (flip operTape) t xs
-
-eval :: [Expr] -> IO ()
-eval xs = void $ evalTape xs initialTape
diff --git a/homework/81248/brainfsck/src/Brainfsck/Parse.hs b/homework/81248/brainfsck/src/Brainfsck/Parse.hs
deleted file mode 100644
index 1a9625d..0000000
--- a/homework/81248/brainfsck/src/Brainfsck/Parse.hs
+++ /dev/null
@@ -1,60 +0,0 @@
-module Brainfsck.Parse
- ( parse
- , ps
- ) where
-
-import Prelude hiding (takeWhile)
-
-import Data.Functor (($>))
-import Data.Either (fromRight)
-import Data.Foldable (asum)
-
-import Data.ByteString (ByteString)
-
-import Data.Attoparsec.ByteString.Char8 hiding (parse)
-
-import Brainfsck.Types
-expr :: Parser Expr
-expr = asum
- [ goRight
- , goLeft
- , incr
- , decr
- , out
- , inp
- , loop
- ]
-
-eatComments :: Parser ()
-eatComments = takeWhile (\x -> x `notElem` ("><+-,.[]" :: String)) $> ()
-
-comments :: Parser a -> Parser a
-comments p = eatComments *> p <* eatComments
-
-goRight :: Parser Expr
-goRight = comments $ char '>' $> GoRight
-
-goLeft :: Parser Expr
-goLeft = comments $ char '<' $> GoLeft
-
-incr :: Parser Expr
-incr = comments $ char '+' $> Incr
-
-decr :: Parser Expr
-decr = comments $ char '-' $> Decr
-
-out :: Parser Expr
-out = comments $ char '.' $> Out
-
-inp :: Parser Expr
-inp = comments $ char ',' $> In
-
-loop :: Parser Expr
-loop = comments $ Loop <$>
- (char '[' *> comments (many' expr) <* char ']')
-
-parse :: ByteString -> Either String [Expr]
-parse = parseOnly (many' expr <* endOfInput)
-
-ps :: ByteString -> [Expr]
-ps = fromRight [] . parse
diff --git a/homework/81248/brainfsck/src/Brainfsck/Types.hs b/homework/81248/brainfsck/src/Brainfsck/Types.hs
deleted file mode 100644
index 6195a24..0000000
--- a/homework/81248/brainfsck/src/Brainfsck/Types.hs
+++ /dev/null
@@ -1,28 +0,0 @@
-module Brainfsck.Types
- ( Expr(..)
- , Tape(..)
- , initialTape
- ) where
-
-data Expr
- = GoRight -- increment the data pointer (to point to the next cell to the right).
- | GoLeft -- decrement the data pointer (to point to the next cell to the left).
- | Incr -- increment (increase by one) the byte at the data pointer.
- | Decr -- decrement (decrease by one) the byte at the data pointer.
- | Out -- output the byte at the data pointer.
- | In -- accept one byte of input, storing its value in the byte at the data pointer.
- | Loop [Expr]
- deriving (Show, Eq)
-
--- if the byte at the data pointer is zero, then instead of moving the instruction pointer forward to the next command, jump it forward to the command after the matching ] command.
--- if the byte at the data pointer is nonzero, then instead of moving the instruction pointer forward to the next command, jump it back to the command after the matching [ command.
-
-data Tape = Tape
- { left :: [Int]
- , head :: Int
- , right :: [Int]
- }
- deriving (Show, Eq)
-
-initialTape :: Tape
-initialTape = Tape (repeat 0) 0 $ repeat 0
diff --git a/homework/81248/brainfsck/stack.yaml b/homework/81248/brainfsck/stack.yaml
deleted file mode 100644
index 21f2284..0000000
--- a/homework/81248/brainfsck/stack.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
-resolver: 12.13
-
-packages:
-- .
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
deleted file mode 100644
index d6ddc14..0000000
--- a/homework/81248/cToHtml/app/.Main.hs.swp
+++ /dev/null
Binary files differ
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
diff --git a/homework/81248/clex/.gitignore b/homework/81248/clex/.gitignore
deleted file mode 100644
index c0989f9..0000000
--- a/homework/81248/clex/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-.stack-work/
-clex.cabal
-*~
-*.swp
diff --git a/homework/81248/clex/Setup.hs b/homework/81248/clex/Setup.hs
deleted file mode 100644
index 9a994af..0000000
--- a/homework/81248/clex/Setup.hs
+++ /dev/null
@@ -1,2 +0,0 @@
-import Distribution.Simple
-main = defaultMain
diff --git a/homework/81248/clex/keyword-strings.txt b/homework/81248/clex/keyword-strings.txt
deleted file mode 100644
index d6c2157..0000000
--- a/homework/81248/clex/keyword-strings.txt
+++ /dev/null
@@ -1,76 +0,0 @@
-"auto"
-"break"
-"case"
-"char"
-"const"
-"continue"
-"default"
-"do"
-"double"
-"else"
-"enum"
-"extern"
-"float"
-"for"
-"goto"
-"if"
-"int"
-"long"
-"register"
-"return"
-"short"
-"signed"
-"sizeof"
-"static"
-"struct"
-"switch"
-"typedef"
-"union"
-"unsigned"
-"void"
-"volatile"
-"while"
-".."
-"+="
-"-="
-"*="
-"/="
-"%="
-"&="
-"^="
-"|="
-"++"
-"--"
-"->"
-"&&"
-"||"
-"<="
-">="
-"=="
-"!="
-">>"
-"<<"
-"."
-"<"
-">"
-"&"
-"|"
-"~"
-"!"
-";"
-"{"
-"}"
-","
-":"
-"="
-"("
-")"
-"["
-"]"
-"-"
-"+"
-"*"
-"/"
-"%"
-"^"
-"?"
diff --git a/homework/81248/clex/package.yaml b/homework/81248/clex/package.yaml
deleted file mode 100644
index 3bf0dc9..0000000
--- a/homework/81248/clex/package.yaml
+++ /dev/null
@@ -1,33 +0,0 @@
-name: clex
-version: 0.0.0.1
-author: "Georgi Lyubenov"
-maintainer: "godzbanebane@gmail.com"
-
-description: Lex C and keep whitespace so I can print it afterwards.
-
-dependencies:
-- base >= 4.7 && < 5
-- bytestring
-- attoparsec
-- word8
-
-library:
- source-dirs: src
-
-ghc-options:
-- -Wall
-- -Werror
-
-tests:
- clex-test:
- main: Spec.hs
- source-dirs: test
- ghc-options:
- - -threaded
- - -rtsopts
- - -with-rtsopts=-N
- dependencies:
- - clex
- - QuickCheck
- - hspec
- - bytestring-arbitrary
diff --git a/homework/81248/clex/sample.c b/homework/81248/clex/sample.c
deleted file mode 100644
index dad89ad..0000000
--- a/homework/81248/clex/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/clex/src/Clex/Lex.hs b/homework/81248/clex/src/Clex/Lex.hs
deleted file mode 100644
index ae78c5d..0000000
--- a/homework/81248/clex/src/Clex/Lex.hs
+++ /dev/null
@@ -1,181 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-
-module Clex.Lex
- ( lexC
- ) where
-
-
-import Prelude hiding (takeWhile)
-
-import Data.Foldable (asum)
-import Data.Word8 ( Word8, isHexDigit, isOctDigit, isAlpha
- , _e, _E, _x, _X,_f, _F, _u, _U, _l, _L, _0
- , _plus, _hyphen, _underscore, _quotesingle
- , _quotedbl, _backslash, _period)
-
-import Data.Attoparsec.ByteString
-import Data.Attoparsec.ByteString.Char8 (isDigit_w8, isSpace_w8)
-
-import Data.ByteString (ByteString)
-import qualified Data.ByteString as BS
-
-import Control.Applicative ((<|>))
-
-import Clex.Types
-
-
-lexC :: ByteString -> Either String [Token]
-lexC = parseOnly (cParser <* endOfInput)
-
-cParser :: Parser [Token]
-cParser = many' tokenParser
-
--- Order is important! For example we need to first check for a floating point number
--- with a leading digit, instead of one without, because the second one will always match the first one.
-tokenParser :: Parser Token
-tokenParser = asum $ concat
- [ [whitespaceParser]
- , [ scientificParser, leadingDotParser, dotFloatParser
- , hexNumParser, octNumParser, numParser, charParser, stringParser
- ]
- , map keywordParser allKeyWords
- , map operParser allOpers
- , [identifierParser]]
-
-whitespaceParser :: Parser Token
-whitespaceParser = Whitespace <$> takeWhile1 isSpace_w8
-
-keywordParser :: ByteString -> Parser Token
-keywordParser kw = do
- parsed <- recognize <$> string kw
- -- we need to check if we still have more letters after the keyword
- next <- peekWord8
- let parsed' = pure parsed
- case next of
- Nothing -> parsed'
- (Just x) -> if (not . isAlpha) x then parsed'
- else fail "more input after keyword"
-
-operParser :: ByteString -> Parser Token
-operParser = (recognize <$>) . string
-
-isDigit :: Word8 -> Bool
-isDigit = isDigit_w8
-
-isLetter :: Word8 -> Bool
-isLetter b = isAlpha b
- || b == _underscore
-
-exponentParser :: Parser ByteString
-exponentParser = do
- e <- satisfy (\c -> c == _E || c == _e)
- sign <- option "" plusMinus
- digits <- takeWhile1 isDigit_w8
- pure $ BS.singleton e <> sign <> digits
- where
- plusMinus = BS.singleton <$> satisfy (\c -> c == _plus || c == _hyphen) -- plus or minus
-
-float :: Parser Word8
-float = satisfy $
- \c -> c == _F
- || c == _f
- || c == _L
- || c == _l
-
-unsigned :: Parser ByteString
-unsigned = BS.pack <$> many' (satisfy $
- \c -> c == _U
- || c == _u
- || c == _L
- || c == _l)
-
-isxX :: Word8 -> Bool
-isxX c = c == _X
- || c == _x
-
-singleQuote :: Parser Word8
-singleQuote = word8 _quotesingle
-
-doubleQuote :: Parser Word8
-doubleQuote = word8 _quotedbl
-
-charParser :: Parser Token
-charParser = do
- l <- option "" (BS.singleton <$> word8 _L)
- _ <- singleQuote
- str <- BS.concat <$> many1' ((BS.snoc <$> string "\\" <*> anyWord8) <|> notInWeirdClass)
- sq <- singleQuote
-
- pure $ CharLit ((l <> (sq `BS.cons` str)) `BS.snoc` sq)
- where
- notInWeirdClass = BS.singleton <$>
- satisfy (\c -> c /= _backslash
- && c /= _quotesingle)
-
-stringParser :: Parser Token
-stringParser = do
- l <- option "" (BS.singleton <$> word8 _L)
- _ <- doubleQuote
- str <- BS.concat <$> many' ((BS.snoc <$> string "\\" <*> anyWord8) <|> notInWeirdClass)
- dq <- doubleQuote
-
- pure $ StringLit ((l <> (dq `BS.cons` str)) `BS.snoc` dq)
- where
- notInWeirdClass = BS.singleton <$>
- satisfy (\c -> c /= _backslash
- && c /= _quotedbl)
-
-zero :: Parser Word8
-zero = word8 _0
-
-hexNumParser :: Parser Token
-hexNumParser = do
- z <- zero
- x <- satisfy isxX
- hex <- takeWhile1 isHexDigit
- f <- unsigned
-
- pure $ HexNumber (z `BS.cons` x `BS.cons` hex <> f)
-
-octNumParser :: Parser Token
-octNumParser = do
- z <- zero
- oct <- takeWhile1 isOctDigit
- f <- unsigned
-
- pure $ OctNumber (z `BS.cons` oct <> f)
-
-numParser :: Parser Token
-numParser = do
- num <- takeWhile1 isDigit
- f <- unsigned
-
- pure $ Number (num <> f)
-
-scientificParser :: Parser Token
-scientificParser = do
- digits <- takeWhile1 isDigit
- expon <- exponentParser
- f <- option "" (BS.singleton <$> float)
- pure $ Scientific $ digits <> expon <> f
-
-dotFloatParser :: Parser Token
-dotFloatParser = do
- leadingDigits <- takeWhile isDigit
- d <- BS.singleton <$> word8 _period
- afterDigits <- takeWhile1 isDigit
- expon <- option "" exponentParser
- f <- option "" (BS.singleton <$> float)
- pure $ DotFloat $ leadingDigits <> d <> afterDigits <> expon <> f
-
-leadingDotParser :: Parser Token
-leadingDotParser = do
- leadingDigits <- takeWhile1 isDigit
- d <- BS.singleton <$> word8 _period
- afterDigits <- takeWhile isDigit
- expon <- option "" exponentParser
- f <- option "" (BS.singleton <$> float)
- pure $ LeadingDot $ leadingDigits <> d <> afterDigits <> expon <> f
-
-identifierParser :: Parser Token
-identifierParser = Identifier <$> takeWhile1 isLetter
diff --git a/homework/81248/clex/src/Clex/Types.hs b/homework/81248/clex/src/Clex/Types.hs
deleted file mode 100644
index 9083514..0000000
--- a/homework/81248/clex/src/Clex/Types.hs
+++ /dev/null
@@ -1,377 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-
-module Clex.Types
- ( Token(..)
- , allKeyWords
- , allOpers
- , recognize
- , tokenToBS
- , tokensToBS
- ) where
-
-import Data.ByteString (ByteString)
-import qualified Data.ByteString as BS
-
-data Token =
- Whitespace ByteString
- | Auto
- | Break
- | Case
- | Char
- | Const
- | Continue
- | Default
- | Do
- | Double
- | Else
- | Enum
- | Extern
- | Float
- | For
- | Goto
- | If
- | Int
- | Long
- | Register
- | Return
- | Short
- | Signed
- | Sizeof
- | Static
- | Struct
- | Switch
- | Typedef
- | Union
- | Unsigned
- | Void
- | Volatile
- | While
- | Ellipsis
- | RightShiftAssign
- | LeftShiftAssign
- | AddAssign
- | SubAssign
- | MulAssign
- | DivAssign
- | ModAssign
- | AndAssign
- | XorAssign
- | OrAssign
- | Incr
- | Decr
- | Ptr
- | Dot
- | And
- | Or
- | Not
- | LtEq
- | GtEq
- | Eq
- | NEq
- | Lt
- | Gt
- | Semicolon
- | LeftCurly
- | RightCurly
- | Comma
- | Colon
- | Assign
- | LeftBracket
- | RightBracket
- | LeftSquare
- | RightSquare
- | RightShift
- | LeftShift
- | BitAnd
- | BitOr
- | BitNot
- | Sub
- | Add
- | Mul
- | Div
- | Mod
- | Xor
- | Ternary
- | HexNumber ByteString
- | OctNumber ByteString
- | Number ByteString
- | CharLit ByteString
- | Scientific ByteString
- | DotFloat ByteString
- | LeadingDot ByteString
- | StringLit ByteString
- | Identifier ByteString
- deriving (Show, Eq)
-
--- Mapping from ByteStrings to Tokens
-recognize :: ByteString -> Token
--- keywords
-recognize "auto" = Auto
-recognize "break" = Break
-recognize "case" = Case
-recognize "char" = Char
-recognize "const" = Const
-recognize "continue" = Continue
-recognize "default" = Default
-recognize "do" = Do
-recognize "double" = Double
-recognize "else" = Else
-recognize "enum" = Enum
-recognize "extern" = Extern
-recognize "float" = Float
-recognize "for" = For
-recognize "goto" = Goto
-recognize "if" = If
-recognize "int" = Int
-recognize "long" = Long
-recognize "register" = Register
-recognize "return" = Return
-recognize "short" = Short
-recognize "signed" = Signed
-recognize "sizeof" = Sizeof
-recognize "static" = Static
-recognize "struct" = Struct
-recognize "switch" = Switch
-recognize "typedef" = Typedef
-recognize "union" = Union
-recognize "unsigned" = Unsigned
-recognize "void" = Void
-recognize "volatile" = Volatile
-recognize "while" = While
-
--- operators
---
--- two-byte
-recognize "..." = Ellipsis
-recognize ">>=" = RightShiftAssign
-recognize "<<=" = LeftShiftAssign
-recognize "+=" = AddAssign
-recognize "-=" = SubAssign
-recognize "*=" = MulAssign
-recognize "/=" = DivAssign
-recognize "%=" = ModAssign
-recognize "&=" = AndAssign
-recognize "^=" = XorAssign
-recognize "|=" = OrAssign
-recognize "++" = Incr
-recognize "--" = Decr
-recognize "->" = Ptr
-recognize "&&" = And
-recognize "||" = Or
-recognize "<=" = LtEq
-recognize ">=" = GtEq
-recognize "==" = Eq
-recognize "!=" = NEq
-recognize ">>" = RightShift
-recognize "<<" = LeftShift
-
--- one-byte
-recognize "." = Dot
-recognize "<" = Lt
-recognize ">" = Gt
-recognize "&" = BitAnd
-recognize "|" = BitOr
-recognize "~" = BitNot
-recognize "!" = Not
-recognize ";" = Semicolon
-recognize "{" = LeftCurly
-recognize "}" = RightCurly
-recognize "," = Comma
-recognize ":" = Colon
-recognize "=" = Assign
-recognize "(" = LeftBracket
-recognize ")" = RightBracket
-recognize "[" = LeftSquare
-recognize "]" = RightSquare
-recognize "-" = Sub
-recognize "+" = Add
-recognize "*" = Mul
-recognize "/" = Div
-recognize "%" = Mod
-recognize "^" = Xor
-recognize "?" = Ternary
-
--- if all else fails an identifier
-recognize x = Identifier x
-
-allKeyWords :: [ByteString]
-allKeyWords =
- [ "auto"
- , "break"
- , "case"
- , "char"
- , "const"
- , "continue"
- , "default"
- , "do"
- , "double"
- , "else"
- , "enum"
- , "extern"
- , "float"
- , "for"
- , "goto"
- , "if"
- , "int"
- , "long"
- , "register"
- , "return"
- , "short"
- , "signed"
- , "sizeof"
- , "static"
- , "struct"
- , "switch"
- , "typedef"
- , "union"
- , "unsigned"
- , "void"
- , "volatile"
- , "while"
- ]
-
--- Opers need to be seperate because they have different rules
--- for formation. For example you can have @"()()()"@, but you can't
--- have @"constconstconst"@.
-allOpers :: [ByteString]
-allOpers =
- [ "..."
- , ">>="
- , "<<="
- , "+="
- , "-="
- , "*="
- , "/="
- , "%="
- , "&="
- , "^="
- , "|="
- , "++"
- , "--"
- , "->"
- , "&&"
- , "||"
- , "<="
- , ">="
- , "=="
- , "!="
- , ">>"
- , "<<"
- , "."
- , "<"
- , ">"
- , "&"
- , "|"
- , "~"
- , "!"
- , ";"
- , "{"
- , "}"
- , ","
- , ":"
- , "="
- , "("
- , ")"
- , "["
- , "]"
- , "-"
- , "+"
- , "*"
- , "/"
- , "%"
- , "^"
- , "?"
- ]
-
-tokensToBS :: [Token] -> ByteString
-tokensToBS = BS.concat . map tokenToBS
-
-tokenToBS :: Token -> ByteString
-tokenToBS (Whitespace bs) = bs
-tokenToBS Auto = "auto"
-tokenToBS Break = "break"
-tokenToBS Case = "case"
-tokenToBS Char = "char"
-tokenToBS Const = "const"
-tokenToBS Continue = "continue"
-tokenToBS Default = "default"
-tokenToBS Do = "do"
-tokenToBS Double = "double"
-tokenToBS Else = "else"
-tokenToBS Enum = "enum"
-tokenToBS Extern = "extern"
-tokenToBS Float = "float"
-tokenToBS For = "for"
-tokenToBS Goto = "goto"
-tokenToBS If = "if"
-tokenToBS Int = "int"
-tokenToBS Long = "long"
-tokenToBS Register = "register"
-tokenToBS Return = "return"
-tokenToBS Short = "short"
-tokenToBS Signed = "signed"
-tokenToBS Sizeof = "sizeof"
-tokenToBS Static = "static"
-tokenToBS Struct = "struct"
-tokenToBS Switch = "switch"
-tokenToBS Typedef = "typedef"
-tokenToBS Union = "union"
-tokenToBS Unsigned = "unsigned"
-tokenToBS Void = "void"
-tokenToBS Volatile = "volatile"
-tokenToBS While = "while"
-tokenToBS Ellipsis = "..."
-tokenToBS RightShiftAssign = ">>="
-tokenToBS LeftShiftAssign = "<<="
-tokenToBS AddAssign = "+="
-tokenToBS SubAssign = "-="
-tokenToBS MulAssign = "*="
-tokenToBS DivAssign = "/="
-tokenToBS ModAssign = "%="
-tokenToBS AndAssign = "&="
-tokenToBS XorAssign = "^="
-tokenToBS OrAssign = "|="
-tokenToBS Incr = "++"
-tokenToBS Decr = "--"
-tokenToBS Ptr = "->"
-tokenToBS Dot = "."
-tokenToBS And = "&&"
-tokenToBS Or = "||"
-tokenToBS Not = "!"
-tokenToBS LtEq = "<="
-tokenToBS GtEq = ">="
-tokenToBS Eq = "=="
-tokenToBS NEq = "!="
-tokenToBS Lt = "<"
-tokenToBS Gt = ">"
-tokenToBS Semicolon = ";"
-tokenToBS LeftCurly = "{"
-tokenToBS RightCurly = "}"
-tokenToBS Comma = ","
-tokenToBS Colon = ":"
-tokenToBS Assign = "="
-tokenToBS LeftBracket = "("
-tokenToBS RightBracket = ")"
-tokenToBS LeftSquare = "["
-tokenToBS RightSquare = "]"
-tokenToBS RightShift = ">>"
-tokenToBS LeftShift = "<<"
-tokenToBS BitAnd = "&"
-tokenToBS BitOr = "|"
-tokenToBS BitNot = "~"
-tokenToBS Sub = "-"
-tokenToBS Add = "+"
-tokenToBS Mul = "*"
-tokenToBS Div = "/"
-tokenToBS Mod = "%"
-tokenToBS Xor = "^"
-tokenToBS Ternary = "?"
-tokenToBS (HexNumber bs) = bs
-tokenToBS (OctNumber bs) = bs
-tokenToBS (Number bs) = bs
-tokenToBS (CharLit bs) = bs
-tokenToBS (Scientific bs) = bs
-tokenToBS (DotFloat bs) = bs
-tokenToBS (LeadingDot bs) = bs
-tokenToBS (StringLit bs) = bs
-tokenToBS (Identifier bs) = bs
diff --git a/homework/81248/clex/stack.yaml b/homework/81248/clex/stack.yaml
deleted file mode 100644
index 5512547..0000000
--- a/homework/81248/clex/stack.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-resolver: lts-12.13
-
-packages:
-- .
-
-extra-deps:
-- bytestring-arbitrary-0.1.2
diff --git a/homework/81248/clex/test/Clex/LexSpec.hs b/homework/81248/clex/test/Clex/LexSpec.hs
deleted file mode 100644
index c5fec81..0000000
--- a/homework/81248/clex/test/Clex/LexSpec.hs
+++ /dev/null
@@ -1,58 +0,0 @@
-module Clex.LexSpec
- ( spec
- ) where
-
-import qualified Data.ByteString as BS
-import Data.ByteString (ByteString)
-import Data.ByteString.Char8 (pack)
-
-import Clex.Types
-import Clex.Lex (lexC)
-
-import Test.QuickCheck
-import Test.Hspec
-import Test.Hspec.QuickCheck
-import Clex.TypesSpec ()
-
-spec :: Spec
-spec = describe "lexing" $ do
- prop "tokensToBS after lexC is id" $
- \x -> let x' = unValidC x in
- case lexC x' of
- (Left _) -> False
- (Right x'') -> x' == tokensToBS x''
- prop "lexing after tokensToBS is id" $
- \x -> let x' = unTokenC x in
- case lexC $ tokensToBS x' of
- (Left _) -> False
- (Right x'') -> x' == x''
-
-newtype TokenC = TokenC {unTokenC :: [Token]}
- deriving (Eq, Show)
-
-newtype ValidC = ValidC {unValidC :: ByteString}
- deriving (Eq, Show)
-
-instance Arbitrary TokenC where
- arbitrary = TokenC . packWhitespaceTokens . concat <$>
- listOf1 (do
- x <- arbitrary
- whitespace <- whitespaceGen
- pure [x, whitespace])
- where
- whitespaceGen = Whitespace . pack <$> do listOf1 $ elements ['\t', ' ', '\n']
-
-instance Arbitrary ValidC where
- arbitrary = ValidC . BS.concat . map tokenToBS <$> listOf1 (frequency
- [ (30, arbitrary)
- , (60, whitespaceGen)
- ])
- where
- whitespaceGen = Whitespace . pack <$> do listOf1 $ elements ['\t', ' ', '\n']
-
-packWhitespaceTokens :: [Token] -> [Token]
-packWhitespaceTokens [] = []
-packWhitespaceTokens [x] = [x]
-packWhitespaceTokens (Whitespace x : Whitespace y : xs)
- = packWhitespaceTokens $ Whitespace (x <> y) : xs
-packWhitespaceTokens (x:xs) = x : packWhitespaceTokens xs
diff --git a/homework/81248/clex/test/Clex/TypesSpec.hs b/homework/81248/clex/test/Clex/TypesSpec.hs
deleted file mode 100644
index 805affc..0000000
--- a/homework/81248/clex/test/Clex/TypesSpec.hs
+++ /dev/null
@@ -1,177 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-{-# OPTIONS -fno-warn-orphans #-}
-
-module Clex.TypesSpec
- ( spec
- ) where
-
-import Data.ByteString.Char8 (pack)
-
-import Clex.Types
-
-import Test.QuickCheck
-import Test.Hspec
-import Test.Hspec.QuickCheck
-import Data.ByteString.Arbitrary
-
-spec :: Spec
-spec = describe "types"
- conversionSpec
-
-conversionSpec :: Spec
-conversionSpec = describe "ByteString conversions" $ do
- prop "recognize is inverse to tokenToBS" $
- \x -> (not . isLiteral) x ==> x == recognize (tokenToBS x)
- prop "tokenToBS is inverse to recognize" $
- \x -> let x' = fromABS x in x' == tokenToBS (recognize x')
-
-isLiteral :: Token -> Bool
-isLiteral (HexNumber _) = True
-isLiteral (OctNumber _) = True
-isLiteral (Number _) = True
-isLiteral (CharLit _) = True
-isLiteral (Scientific _) = True
-isLiteral (DotFloat _) = True
-isLiteral (LeadingDot _) = True
-isLiteral (StringLit _) = True
-isLiteral _ = False
-
-instance Arbitrary Token where
- arbitrary = frequency
- [ (30, nullaryGen)
- , (30, identifierGen)
- , (10, literalGen)
- ]
- where
- nullaryGen = elements
- [ Auto
- , Break
- , Case
- , Char
- , Const
- , Continue
- , Default
- , Do
- , Double
- , Else
- , Enum
- , Extern
- , Float
- , For
- , Goto
- , If
- , Int
- , Long
- , Register
- , Return
- , Short
- , Signed
- , Sizeof
- , Static
- , Struct
- , Switch
- , Typedef
- , Union
- , Unsigned
- , Void
- , Volatile
- , While
- , Ellipsis
- , RightShiftAssign
- , LeftShiftAssign
- , AddAssign
- , SubAssign
- , MulAssign
- , DivAssign
- , ModAssign
- , AndAssign
- , XorAssign
- , OrAssign
- , Incr
- , Decr
- , Ptr
- , Dot
- , And
- , Or
- , Not
- , LtEq
- , GtEq
- , Eq
- , NEq
- , Lt
- , Gt
- , Semicolon
- , LeftCurly
- , RightCurly
- , Comma
- , Colon
- , Assign
- , LeftBracket
- , RightBracket
- , LeftSquare
- , RightSquare
- , RightShift
- , LeftShift
- , BitAnd
- , BitOr
- , BitNot
- , Sub
- , Add
- , Mul
- , Div
- , Mod
- , Xor
- , Ternary
- ]
- identifierGen = Identifier <$> (pack <$> do listOf1 $ elements $ '_' : ['a'..'z'] ++ ['A'..'Z'])
- `suchThat` (not . reserved)
- reserved = (`elem` allKeyWords)
- -- don't feel like overdoing this right now
- literalGen = oneof
- [ elements
- [ HexNumber "0xb23abcf4"
- , HexNumber "0x123ab5f4ul"
- , HexNumber "0X123a4cf4"
- , HexNumber "0x1e3ebcf4lull"
-
- , OctNumber "0234"
- , OctNumber "012354ul"
- , OctNumber "012744"
- , OctNumber "0134lull"
-
- , Number "234"
- , Number "12354ul"
- , Number "12744"
- , Number "134lull"
- ]
- , elements
- [ CharLit "'c'"
- , CharLit "L'c'"
- , CharLit "'\n'"
- , CharLit "'\t'"
- , CharLit "'a'"
- ]
- , elements
- [ DotFloat ".213E+10f"
- , DotFloat ".213e-10"
- , DotFloat ".213e-10l"
- , DotFloat ".213e10l"
- , DotFloat ".213l"
- , DotFloat ".213"
- , DotFloat ".213e9L"
-
- , LeadingDot "213.2E+10f"
- , LeadingDot "213.3e-10"
- , LeadingDot "213.e-10l"
- , LeadingDot "213.e10l"
- , LeadingDot "213.e9L"
- , LeadingDot "213.9L"
- , LeadingDot "213.L"
- ]
- , elements
- [ StringLit "\"\""
- , StringLit "L\"asdfwqe\""
- , StringLit "\"asd\nfw\tqe\""
- , StringLit "L\"\""
- ]
- ]
diff --git a/homework/81248/clex/test/Spec.hs b/homework/81248/clex/test/Spec.hs
deleted file mode 100644
index a824f8c..0000000
--- a/homework/81248/clex/test/Spec.hs
+++ /dev/null
@@ -1 +0,0 @@
-{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
diff --git a/homework/81248/stack.yaml b/homework/81248/stack.yaml
deleted file mode 100644
index 035a96b..0000000
--- a/homework/81248/stack.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-resolver: lts-12.13
-
-packages:
-- ./clex
-- ./cToHtml
-- ./brainfsck
-
-extra-deps:
-- bytestring-arbitrary-0.1.2
diff --git a/homework/81270/.gitignore b/homework/81270/.gitignore
deleted file mode 100644
index 102b938..0000000
--- a/homework/81270/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-cmake-build-*
-.idea \ No newline at end of file
diff --git a/homework/81270/CMakeLists.txt b/homework/81270/CMakeLists.txt
deleted file mode 100644
index 24c1d1d..0000000
--- a/homework/81270/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-cmake_minimum_required(VERSION 3.9)
-project(81270)
-
-set(CMAKE_CXX_STANDARD 11)
-
-add_subdirectory(js2html)
-
-add_subdirectory(brainf-interpret) \ No newline at end of file
diff --git a/homework/81270/brainf-interpret/CMakeLists.txt b/homework/81270/brainf-interpret/CMakeLists.txt
deleted file mode 100644
index 7407ada..0000000
--- a/homework/81270/brainf-interpret/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-cmake_minimum_required(VERSION 3.9)
-project(brainf-interpret)
-
-add_executable(brainf-interpret Interpreter.cpp) \ No newline at end of file
diff --git a/homework/81270/brainf-interpret/Interpreter.cpp b/homework/81270/brainf-interpret/Interpreter.cpp
deleted file mode 100644
index ebca77b..0000000
--- a/homework/81270/brainf-interpret/Interpreter.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-//
-// Created by bmestanov on 15.11.18.
-//
-
-#define TAPE_SIZE 65536
-#define STACK_SIZE 8192
-
-#include <fstream>
-#include <iostream>
-
-void failIf(bool condition, const char *message) {
- if (condition) {
- std::cerr << message;
- exit(1);
- }
-}
-
-int main(int argc, char **argv) {
- argc--;
- argv++;
- char memory[TAPE_SIZE] = {0};
- char *pp = memory; // program pointer
- long stack[STACK_SIZE];
- int sp = 0; // stack pointer
-
- failIf(!argv[0], "No file provided");
-
- std::ifstream file;
- file.open(argv[0]);
-
- failIf(!file, "Error opening file");
-
- while (!file.eof()) {
- auto symbol = static_cast<char>(file.get());
- switch (symbol) {
- case '>': {
- // Allow memory wrap
- pp = memory + (pp - memory + 1) % TAPE_SIZE;
- break;
- }
- case '<': {
- pp = memory + (pp - memory - 1) % TAPE_SIZE;
- break;
- }
- case '+': {
- (*pp)++;
- break;
- }
- case '-': {
- (*pp)--;
- break;
- }
- case '.': {
- std::putchar(*pp);
- break;
- }
- case ',': {
- *pp = static_cast<char>(std::getchar());
- break;
- }
- case '[': {
- if (*pp) {
- failIf(sp == STACK_SIZE, "Stack overflow");
- stack[sp++] = file.tellg();
- } else {
- long move = 1;
- while (move > 0) {
- auto next = static_cast<char>(file.get());
- if (next == '[') move++;
- if (next == ']') move--;
- if (file.eof()) failIf(true, "Invalid syntax");
- }
- }
- break;
- }
- case ']': {
- failIf(sp == 0, "Invalid syntax");
- if (*pp) {
- long top = stack[sp - 1];
- file.seekg(top);
- } else {
- sp--;
- }
- }
- default:;
- }
- }
-
- return 0;
-} \ No newline at end of file
diff --git a/homework/81270/brainf-interpret/hello.b b/homework/81270/brainf-interpret/hello.b
deleted file mode 100644
index a2de5df..0000000
--- a/homework/81270/brainf-interpret/hello.b
+++ /dev/null
@@ -1,3 +0,0 @@
->+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-]
-<.#>+++++++++++[<+++++>-]<.>++++++++[<+++>-]<.+++.------.--------.[-]>++++++++[
-<++++>-]<+.[-]++++++++++.
diff --git a/homework/81270/brainf-interpret/primes.b b/homework/81270/brainf-interpret/primes.b
deleted file mode 100644
index 294fc6b..0000000
--- a/homework/81270/brainf-interpret/primes.b
+++ /dev/null
@@ -1,221 +0,0 @@
-===================================================================
-======================== OUTPUT STRING ============================
-===================================================================
->++++++++[<++++++++>-]<++++++++++++++++.[-]
->++++++++++[<++++++++++>-]<++++++++++++++.[-]
->++++++++++[<++++++++++>-]<+++++.[-]
->++++++++++[<++++++++++>-]<+++++++++.[-]
->++++++++++[<++++++++++>-]<+.[-]
->++++++++++[<++++++++++>-]<+++++++++++++++.[-]
->+++++[<+++++>-]<+++++++.[-]
->++++++++++[<++++++++++>-]<+++++++++++++++++.[-]
->++++++++++[<++++++++++>-]<++++++++++++.[-]
->+++++[<+++++>-]<+++++++.[-]
->++++++++++[<++++++++++>-]<++++++++++++++++.[-]
->++++++++++[<++++++++++>-]<+++++++++++.[-]
->+++++++[<+++++++>-]<+++++++++.[-]
->+++++[<+++++>-]<+++++++.[-]
-
-===================================================================
-======================== INPUT NUMBER ============================
-===================================================================
-+ cont=1
-[
- - cont=0
- >,
- ======SUB10======
- ----------
-
- [ not 10
- <+> cont=1
- =====SUB38======
- ----------
- ----------
- ----------
- --------
-
- >
- =====MUL10=======
- [>+>+<<-]>>[<<+>>-]< dup
-
- >>>+++++++++
- [
- <<<
- [>+>+<<-]>>[<<+>>-]< dup
- [<<+>>-]
- >>-
- ]
- <<<[-]<
- ======RMOVE1======
- <
- [>+<-]
- ]
- <
-]
->>[<<+>>-]<<
-
-===================================================================
-======================= PROCESS NUMBER ===========================
-===================================================================
-
-==== ==== ==== ====
-numd numu teid teiu
-==== ==== ==== ====
-
->+<-
-[
- >+
- ======DUP======
- [>+>+<<-]>>[<<+>>-]<
-
- >+<--
-
- >>>>>>>>+<<<<<<<< isprime=1
-
- [
- >+
-
- <-
-
- =====DUP3=====
- <[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<<<
-
- =====DUP2=====
- >[>>+>+<<<-]>>>[<<<+>>>-]<<< <
-
-
- >>>
-
-
- ====DIVIDES=======
- [>+>+<<-]>>[<<+>>-]< DUP i=div
-
- <<
- [
- >>>>>+ bool=1
- <<<
- [>+>+<<-]>>[<<+>>-]< DUP
- [>>[-]<<-] IF i THEN bool=0
- >>
- [ IF i=0
- <<<<
- [>+>+<<-]>>[<<+>>-]< i=div
- >>>
- - bool=0
- ]
- <<<
- - DEC i
- <<
- -
- ]
-
- +>>[<<[-]>>-]<<
- >[-]< CLR div
- =====END DIVIDES====
-
-
- [>>>>>>[-]<<<<<<-] if divides then isprime=0
-
-
- <<
-
- >>[-]>[-]<<<
- ]
-
- >>>>>>>>
- [
- -
- <<<<<<<[-]<<
-
- [>>+>+<<<-]>>>[<<<+>>>-]<<<
-
- >>
-
-
-
-
- ===================================================================
- ======================== OUTPUT NUMBER ===========================
- ===================================================================
- [>+<-]>
-
- [
- ======DUP======
- [>+>+<<-]>>[<<+>>-]<
-
-
- ======MOD10====
- >+++++++++<
- [
- >>>+<< bool= 1
- [>+>[-]<<-] bool= ten==0
- >[<+>-] ten = tmp
- >[<<++++++++++>>-] if ten=0 ten=10
- <<- dec ten
- <- dec num
- ]
- +++++++++ num=9
- >[<->-]< dec num by ten
-
- =======RROT======
- [>+<-]
- < [>+<-]
- < [>+<-]
- >>>[<<<+>>>-]
- <
-
- =======DIV10========
- >+++++++++<
- [
- >>>+<< bool= 1
- [>+>[-]<<-] bool= ten==0
- >[<+>-] ten = tmp
- >[<<++++++++++>>>+<-] if ten=0 ten=10 inc div
- <<- dec ten
- <- dec num
- ]
- >>>>[<<<<+>>>>-]<<<< copy div to num
- >[-]< clear ten
-
- =======INC1=========
- <+>
- ]
-
- <
- [
- =======MOVER=========
- [>+<-]
-
- =======ADD48========
- +++++++[<+++++++>-]<->
-
- =======PUTC=======
- <.[-]>
-
- ======MOVEL2========
- >[<<+>>-]<
-
- <-
- ]
-
- >++++[<++++++++>-]<.[-]
-
- ===================================================================
- =========================== END FOR ===============================
- ===================================================================
-
-
- >>>>>>>
- ]
- <<<<<<<<
-
-
-
- >[-]<
- [-]
- <<-
-]
-
-======LF========
-
-++++++++++.[-] \ No newline at end of file
diff --git a/homework/81270/js2html/CMakeLists.txt b/homework/81270/js2html/CMakeLists.txt
deleted file mode 100644
index 7a42900..0000000
--- a/homework/81270/js2html/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-cmake_minimum_required(VERSION 3.9)
-project(js2html)
-
-set(CMAKE_CXX_STANDARD 11)
-
-add_executable(lexer
- Common.h
- Token.h
- Token.h
- Highlighter.h
- js2html.cpp
- Token.cpp
- Highlighter.cpp)
-
-add_custom_command(TARGET lexer
- PRE_BUILD
- COMMAND flex -o ${PROJECT_SOURCE_DIR}/js2html.cpp ${PROJECT_SOURCE_DIR}/js2html.flex) \ No newline at end of file
diff --git a/homework/81270/js2html/Common.h b/homework/81270/js2html/Common.h
deleted file mode 100644
index 8a3cf17..0000000
--- a/homework/81270/js2html/Common.h
+++ /dev/null
@@ -1,18 +0,0 @@
-//
-// Created by bmestanov on 23.10.18.
-//
-
-#ifndef ES2HTML_COMMON_H
-#define ES2HTML_COMMON_H
-
-#include <string>
-#include <vector>
-
-using TokenTypeId = int;
-
-using IPLString = std::string;
-
-template<typename T>
-using IPLVector= std::vector<T>;
-
-#endif //ES2HTML_COMMON_H
diff --git a/homework/81270/js2html/Highlighter.cpp b/homework/81270/js2html/Highlighter.cpp
deleted file mode 100644
index cd56496..0000000
--- a/homework/81270/js2html/Highlighter.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-//
-// Created by bmestanov on 25.10.18.
-//
-
-#include "Highlighter.h"
-#include <fstream>
-#include <sstream>
-#include <iostream>
-
-Highlighter::Highlighter(const char *outputPath, const char *stylePath) :
- outputPath(outputPath), stylePath(stylePath) {}
-
-void Highlighter::highlight(const IPLVector<Token> &tokens) {
- std::stringstream ss;
-
- ss << "<!doctype html>\n";
- ss << "<html>\n";
- ss << " <head>\n";
- ss << " <title>hello.js</title>\n";
- ss << " <link rel=\"stylesheet\" href=\"" << stylePath << "\">\n";
- ss << " </head>\n";
- ss << " <body>\n";
- ss << " <pre class=\"code\">\n";
-
- for (auto &token : tokens) {
- IPLString cssClass = getClass(token);
- if (cssClass.empty()) {
- // Print with no formatting
- ss << token.lexeme;
- } else {
- ss << "<span class=\"" << cssClass << "\">" << token.lexeme << "</span>";
- }
- }
-
- ss << " </body>\n";
- ss << "</html>\n";
-
- std::ofstream fs(outputPath);
- if (fs) {
- fs << ss.rdbuf();
- } else {
- std::cout << ss.rdbuf();
- }
-}
-
-IPLString Highlighter::getClass(const Token &token) {
- switch (token.type) {
- case Whitespace:
- case NewLine:
- case Raw:
- return "";
- case Comment:
- return "comment";
- case Keyword:
- return "keyword";
- case NumericLiteral:
- return "numeric";
- case StringLiteral:
- return "string";
- case TemplateLiteral:
- return "template";
- case Regex:
- return "regex";
- case Identifier:
- return "identifier";
- case BooleanLiteral:
- return "boolean";
- case Global:
- return "global";
- }
-}
diff --git a/homework/81270/js2html/Highlighter.h b/homework/81270/js2html/Highlighter.h
deleted file mode 100644
index a655480..0000000
--- a/homework/81270/js2html/Highlighter.h
+++ /dev/null
@@ -1,24 +0,0 @@
-//
-// Created by bmestanov on 25.10.18.
-//
-
-#ifndef ES2HTML_HIGHLIGHTER_H
-#define ES2HTML_HIGHLIGHTER_H
-
-#include "Token.h"
-
-class Highlighter {
-public:
- explicit Highlighter(const char *outputPath = nullptr, const char *stylePath = "style.css");
-
- void highlight(const IPLVector<Token> &tokens);
-
-private:
- const char *stylePath;
- const char *outputPath;
-
- static IPLString getClass(const Token &token);
-};
-
-
-#endif //ES2HTML_HIGHLIGHTER_H
diff --git a/homework/81270/js2html/README.md b/homework/81270/js2html/README.md
deleted file mode 100644
index ae32b7c..0000000
--- a/homework/81270/js2html/README.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# How to build
-
-1. Generate flex scanner
-```
-flex -o js2html.cpp js2html.flex
-```
-
-2. Use Cmake to build platform-specific project \ No newline at end of file
diff --git a/homework/81270/js2html/Token.cpp b/homework/81270/js2html/Token.cpp
deleted file mode 100644
index 8e49f1b..0000000
--- a/homework/81270/js2html/Token.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "Token.h"
-
-Token::Token(const TokenType &type, const char *lexeme) :
- type(type), lexeme(lexeme) {
-}
diff --git a/homework/81270/js2html/Token.h b/homework/81270/js2html/Token.h
deleted file mode 100644
index b56cb0e..0000000
--- a/homework/81270/js2html/Token.h
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// Created by bmestanov on 23.10.18.
-//
-
-#ifndef ES2HTML_LEXER_H
-#define ES2HTML_LEXER_H
-
-#include <vector>
-#include <string>
-#include <functional>
-#include "Token.h"
-#include "Common.h"
-
-enum TokenType {
- Whitespace,
- NewLine,
- Raw,
- Comment,
- Keyword,
- BooleanLiteral,
- NumericLiteral,
- StringLiteral,
- TemplateLiteral,
- Regex,
- Identifier,
- Global
-};
-
-struct Token {
- TokenType type;
- IPLString lexeme;
-
- Token(const TokenType &type, const char *lexeme);
-};
-
-
-#endif //ES2HTML_LEXER_H
diff --git a/homework/81270/js2html/hello.js b/homework/81270/js2html/hello.js
deleted file mode 100644
index d2e6b0b..0000000
--- a/homework/81270/js2html/hello.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// Single line comment
-
-const someVariable = 3.14e+2;
-const someString = 'Escaped \' string!';
-const someTemplate = `A simple one`;
-const someRegex = /[0-9]+/i;
-
-/**
- Multiline comment
- */
-function foo() {
- return [] instanceof Array;
-} \ No newline at end of file
diff --git a/homework/81270/js2html/js2html.cpp b/homework/81270/js2html/js2html.cpp
deleted file mode 100644
index 60a9ede..0000000
--- a/homework/81270/js2html/js2html.cpp
+++ /dev/null
@@ -1,2042 +0,0 @@
-#line 2 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.cpp"
-
-#line 4 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.cpp"
-
-#define YY_INT_ALIGNED short int
-
-/* A lexical scanner generated by flex */
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 4
-#if YY_FLEX_SUBMINOR_VERSION > 0
-#define FLEX_BETA
-#endif
-
-/* First, we deal with platform-specific or compiler-specific issues. */
-
-/* begin standard C headers. */
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/* end standard C headers. */
-
-/* flex integer type definitions */
-
-#ifndef FLEXINT_H
-#define FLEXINT_H
-
-/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-
-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-
-/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
- * if you want the limit (max/min) macros for int types.
- */
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS 1
-#endif
-
-#include <inttypes.h>
-typedef int8_t flex_int8_t;
-typedef uint8_t flex_uint8_t;
-typedef int16_t flex_int16_t;
-typedef uint16_t flex_uint16_t;
-typedef int32_t flex_int32_t;
-typedef uint32_t flex_uint32_t;
-#else
-typedef signed char flex_int8_t;
-typedef short int flex_int16_t;
-typedef int flex_int32_t;
-typedef unsigned char flex_uint8_t;
-typedef unsigned short int flex_uint16_t;
-typedef unsigned int flex_uint32_t;
-
-/* Limits of integral types. */
-#ifndef INT8_MIN
-#define INT8_MIN (-128)
-#endif
-#ifndef INT16_MIN
-#define INT16_MIN (-32767-1)
-#endif
-#ifndef INT32_MIN
-#define INT32_MIN (-2147483647-1)
-#endif
-#ifndef INT8_MAX
-#define INT8_MAX (127)
-#endif
-#ifndef INT16_MAX
-#define INT16_MAX (32767)
-#endif
-#ifndef INT32_MAX
-#define INT32_MAX (2147483647)
-#endif
-#ifndef UINT8_MAX
-#define UINT8_MAX (255U)
-#endif
-#ifndef UINT16_MAX
-#define UINT16_MAX (65535U)
-#endif
-#ifndef UINT32_MAX
-#define UINT32_MAX (4294967295U)
-#endif
-
-#ifndef SIZE_MAX
-#define SIZE_MAX (~(size_t)0)
-#endif
-
-#endif /* ! C99 */
-
-#endif /* ! FLEXINT_H */
-
-/* begin standard C++ headers. */
-
-/* TODO: this is always defined, so inline it */
-#define yyconst const
-
-#if defined(__GNUC__) && __GNUC__ >= 3
-#define yynoreturn __attribute__((__noreturn__))
-#else
-#define yynoreturn
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an
- * integer in range [0..255] for use as an array index.
- */
-#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN (yy_start) = 1 + 2 *
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state. The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START (((yy_start) - 1) / 2)
-#define YYSTATE YY_START
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart( yyin )
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#ifndef YY_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k.
- * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
- * Ditto for the __ia64__ case accordingly.
- */
-#define YY_BUF_SIZE 32768
-#else
-#define YY_BUF_SIZE 16384
-#endif /* __ia64__ */
-#endif
-
-/* The state buf must be large enough to hold one state per character in the main buffer.
- */
-#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
-
-#ifndef YY_TYPEDEF_YY_BUFFER_STATE
-#define YY_TYPEDEF_YY_BUFFER_STATE
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-#endif
-
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef size_t yy_size_t;
-#endif
-
-extern int yyleng;
-
-extern FILE *yyin, *yyout;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
- #define YY_LESS_LINENO(n)
- #define YY_LINENO_REWIND_TO(ptr)
-
-/* Return all but the first "n" matched characters back to the input stream. */
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- *yy_cp = (yy_hold_char); \
- YY_RESTORE_YY_MORE_OFFSET \
- (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up yytext again */ \
- } \
- while ( 0 )
-#define unput(c) yyunput( c, (yytext_ptr) )
-
-#ifndef YY_STRUCT_YY_BUFFER_STATE
-#define YY_STRUCT_YY_BUFFER_STATE
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- int yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- int yy_n_chars;
-
- /* Whether we "own" the buffer - i.e., we know we created it,
- * and can realloc() it to grow it, and should free() it to
- * delete it.
- */
- int yy_is_our_buffer;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether we're considered to be at the beginning of a line.
- * If so, '^' rules will be active on the next match, otherwise
- * not.
- */
- int yy_at_bol;
-
- int yy_bs_lineno; /**< The line count. */
- int yy_bs_column; /**< The column count. */
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via yyrestart()), so that the user can continue scanning by
- * just pointing yyin at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
-
- };
-#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-
-/* Stack of input buffers. */
-static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
-static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
-static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- *
- * Returns the top of the stack, or NULL.
- */
-#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
- ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
- : NULL)
-/* Same as previous macro, but useful when we know that the buffer stack is not
- * NULL or when we need an lvalue. For internal use only.
- */
-#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
-
-/* yy_hold_char holds the character lost when yytext is formed. */
-static char yy_hold_char;
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-int yyleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = NULL;
-static int yy_init = 0; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow yywrap()'s to do buffer switches
- * instead of setting up a fresh yyin. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void yyrestart ( FILE *input_file );
-void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer );
-YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size );
-void yy_delete_buffer ( YY_BUFFER_STATE b );
-void yy_flush_buffer ( YY_BUFFER_STATE b );
-void yypush_buffer_state ( YY_BUFFER_STATE new_buffer );
-void yypop_buffer_state ( void );
-
-static void yyensure_buffer_stack ( void );
-static void yy_load_buffer_state ( void );
-static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file );
-#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER )
-
-YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size );
-YY_BUFFER_STATE yy_scan_string ( const char *yy_str );
-YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len );
-
-void *yyalloc ( yy_size_t );
-void *yyrealloc ( void *, yy_size_t );
-void yyfree ( void * );
-
-#define yy_new_buffer yy_create_buffer
-#define yy_set_interactive(is_interactive) \
- { \
- if ( ! YY_CURRENT_BUFFER ){ \
- yyensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- yy_create_buffer( yyin, YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
- }
-#define yy_set_bol(at_bol) \
- { \
- if ( ! YY_CURRENT_BUFFER ){\
- yyensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- yy_create_buffer( yyin, YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
- }
-#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
-
-/* Begin user sect3 */
-typedef flex_uint8_t YY_CHAR;
-
-FILE *yyin = NULL, *yyout = NULL;
-
-typedef int yy_state_type;
-
-extern int yylineno;
-int yylineno = 1;
-
-extern char *yytext;
-#ifdef yytext_ptr
-#undef yytext_ptr
-#endif
-#define yytext_ptr yytext
-
-static yy_state_type yy_get_previous_state ( void );
-static yy_state_type yy_try_NUL_trans ( yy_state_type current_state );
-static int yy_get_next_buffer ( void );
-static void yynoreturn yy_fatal_error ( const char* msg );
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up yytext.
- */
-#define YY_DO_BEFORE_ACTION \
- (yytext_ptr) = yy_bp; \
- yyleng = (int) (yy_cp - yy_bp); \
- (yy_hold_char) = *yy_cp; \
- *yy_cp = '\0'; \
- (yy_c_buf_p) = yy_cp;
-#define YY_NUM_RULES 13
-#define YY_END_OF_BUFFER 14
-/* This struct is not used in this scanner,
- but its presence is necessary. */
-struct yy_trans_info
- {
- flex_int32_t yy_verify;
- flex_int32_t yy_nxt;
- };
-static const flex_int16_t yy_accept[308] =
- { 0,
- 0, 0, 14, 12, 1, 2, 2, 12, 11, 12,
- 12, 12, 6, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 12, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 1, 2, 0, 7, 0, 11,
- 0, 0, 6, 0, 0, 3, 6, 6, 0, 0,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 0, 0, 8, 11,
- 11, 11, 11, 11, 11, 4, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 4, 11, 11, 11, 11,
-
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 7, 7, 0, 0, 9, 0, 0, 9,
- 3, 6, 0, 0, 0, 0, 6, 0, 0, 6,
- 11, 11, 11, 11, 11, 11, 11, 10, 11, 11,
- 11, 11, 11, 11, 11, 8, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 0, 0, 6, 0, 0, 6, 9, 0, 0, 0,
- 9, 0, 0, 6, 0, 0, 6, 6, 6, 6,
-
- 6, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 5, 11, 11, 11, 6,
- 6, 6, 6, 3, 3, 6, 6, 6, 6, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-
- 11, 11, 11, 11, 11, 11, 0
- } ;
-
-static const YY_CHAR yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 1, 1, 4, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 5, 1, 6, 1, 1, 7, 1,
- 1, 8, 9, 1, 10, 11, 12, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 1, 1, 1,
- 1, 1, 1, 1, 14, 15, 6, 16, 17, 18,
- 6, 6, 19, 20, 6, 6, 21, 22, 23, 24,
- 6, 25, 26, 6, 6, 6, 6, 6, 6, 6,
- 1, 27, 1, 1, 6, 28, 29, 30, 31, 32,
-
- 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
- 43, 44, 6, 45, 46, 47, 48, 49, 50, 51,
- 52, 6, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-static const YY_CHAR yy_meta[53] =
- { 0,
- 1, 1, 2, 1, 1, 3, 1, 1, 1, 1,
- 1, 1, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 1, 1, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3
- } ;
-
-static const flex_int16_t yy_base[316] =
- { 0,
- 0, 0, 456, 457, 453, 457, 451, 48, 0, 47,
- 440, 47, 45, 407, 408, 421, 404, 400, 405, 420,
- 416, 28, 414, 398, 409, 30, 33, 396, 395, 40,
- 38, 44, 59, 57, 396, 31, 404, 408, 403, 17,
- 49, 393, 44, 53, 432, 457, 65, 457, 92, 0,
- 93, 97, 92, 421, 60, 0, 93, 100, 105, 118,
- 387, 388, 383, 384, 386, 393, 403, 85, 403, 383,
- 385, 379, 386, 373, 374, 377, 94, 107, 457, 382,
- 383, 90, 386, 372, 108, 0, 367, 364, 382, 96,
- 370, 367, 363, 365, 362, 359, 382, 371, 352, 361,
-
- 355, 352, 354, 360, 71, 93, 352, 363, 349, 356,
- 355, 344, 125, 132, 137, 144, 114, 148, 153, 136,
- 0, 150, 159, 165, 377, 376, 375, 374, 373, 372,
- 355, 343, 349, 338, 349, 342, 356, 0, 341, 346,
- 342, 333, 356, 335, 341, 152, 322, 340, 335, 336,
- 320, 135, 317, 335, 330, 329, 320, 320, 316, 325,
- 311, 327, 324, 311, 306, 323, 303, 310, 303, 300,
- 314, 299, 299, 301, 310, 309, 308, 308, 299, 302,
- 324, 323, 322, 321, 320, 319, 150, 319, 322, 317,
- 162, 315, 314, 313, 312, 311, 310, 309, 308, 307,
-
- 306, 266, 284, 271, 268, 272, 280, 281, 274, 259,
- 267, 265, 266, 267, 269, 258, 256, 265, 266, 252,
- 252, 253, 255, 263, 255, 247, 248, 263, 269, 250,
- 256, 243, 242, 255, 235, 0, 241, 249, 249, 268,
- 267, 266, 265, 159, 457, 264, 263, 262, 261, 244,
- 235, 234, 225, 222, 222, 223, 231, 225, 231, 221,
- 227, 221, 227, 212, 226, 217, 219, 208, 212, 220,
- 171, 210, 215, 216, 212, 206, 204, 199, 212, 202,
- 195, 209, 194, 194, 187, 195, 206, 196, 189, 171,
- 170, 157, 161, 173, 160, 162, 168, 152, 146, 159,
-
- 140, 133, 135, 126, 89, 65, 457, 214, 63, 217,
- 220, 223, 226, 229, 232
- } ;
-
-static const flex_int16_t yy_def[316] =
- { 0,
- 307, 1, 307, 307, 307, 307, 307, 308, 309, 310,
- 307, 311, 307, 309, 309, 309, 309, 309, 309, 309,
- 309, 309, 309, 309, 309, 309, 312, 309, 309, 309,
- 309, 309, 309, 309, 309, 309, 309, 309, 309, 309,
- 309, 309, 309, 309, 307, 307, 308, 307, 308, 309,
- 310, 310, 307, 311, 313, 314, 307, 307, 307, 307,
- 309, 309, 309, 309, 309, 309, 309, 309, 309, 309,
- 309, 309, 309, 309, 309, 309, 312, 312, 307, 309,
- 309, 309, 309, 309, 309, 309, 309, 309, 309, 309,
- 309, 309, 309, 309, 309, 309, 309, 309, 309, 309,
-
- 309, 309, 309, 309, 309, 309, 309, 309, 309, 309,
- 309, 309, 308, 310, 307, 307, 307, 313, 313, 315,
- 314, 307, 307, 307, 307, 307, 307, 307, 307, 307,
- 309, 309, 309, 309, 309, 309, 309, 309, 309, 309,
- 309, 309, 309, 309, 309, 312, 309, 309, 309, 309,
- 309, 309, 309, 309, 309, 309, 309, 309, 309, 309,
- 309, 309, 309, 309, 309, 309, 309, 309, 309, 309,
- 309, 309, 309, 309, 309, 309, 309, 309, 309, 309,
- 307, 307, 307, 307, 307, 307, 307, 311, 315, 307,
- 315, 307, 307, 307, 307, 307, 307, 307, 307, 307,
-
- 307, 309, 309, 309, 309, 309, 309, 309, 309, 309,
- 309, 309, 309, 309, 309, 309, 309, 309, 309, 309,
- 309, 309, 309, 309, 309, 309, 309, 309, 309, 309,
- 309, 309, 309, 309, 309, 309, 309, 309, 309, 307,
- 307, 307, 307, 307, 307, 307, 307, 307, 307, 309,
- 309, 309, 309, 309, 309, 309, 309, 309, 309, 309,
- 309, 309, 309, 309, 309, 309, 309, 309, 309, 309,
- 309, 309, 309, 309, 309, 309, 309, 309, 309, 309,
- 309, 309, 309, 309, 309, 309, 309, 309, 309, 309,
- 309, 309, 309, 309, 309, 309, 309, 309, 309, 309,
-
- 309, 309, 309, 309, 309, 309, 0, 307, 307, 307,
- 307, 307, 307, 307, 307
- } ;
-
-static const flex_int16_t yy_nxt[510] =
- { 0,
- 4, 5, 6, 7, 8, 9, 10, 4, 4, 4,
- 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
- 21, 22, 23, 24, 25, 26, 4, 27, 28, 29,
- 30, 31, 32, 33, 9, 9, 34, 9, 9, 9,
- 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 9, 9, 48, 48, 55, 57, 69, 58, 56, 78,
- 79, 59, 74, 99, 103, 50, 104, 119, 82, 48,
- 85, 120, 109, 52, 49, 70, 75, 60, 100, 83,
- 86, 76, 84, 87, 105, 88, 110, 91, 111, 112,
- 86, 49, 89, 106, 90, 92, 113, 95, 96, 48,
-
- 107, 93, 97, 114, 53, 122, 94, 173, 115, 123,
- 57, 138, 58, 125, 126, 174, 59, 127, 49, 52,
- 78, 79, 86, 52, 116, 124, 128, 129, 138, 48,
- 130, 139, 60, 78, 146, 149, 150, 153, 48, 159,
- 175, 154, 160, 190, 86, 181, 182, 155, 187, 183,
- 187, 49, 184, 185, 187, 188, 186, 138, 52, 120,
- 54, 187, 122, 306, 120, 187, 123, 192, 193, 190,
- 191, 194, 191, 195, 196, 305, 191, 197, 78, 79,
- 217, 218, 124, 191, 187, 138, 187, 191, 288, 289,
- 187, 304, 138, 187, 303, 187, 191, 187, 191, 187,
-
- 302, 187, 191, 86, 86, 86, 187, 301, 138, 191,
- 187, 138, 300, 191, 47, 47, 47, 51, 51, 51,
- 54, 54, 54, 77, 77, 77, 118, 118, 118, 121,
- 299, 121, 189, 189, 189, 298, 297, 296, 86, 86,
- 86, 295, 294, 293, 138, 292, 291, 138, 290, 86,
- 86, 86, 86, 287, 86, 286, 285, 284, 86, 86,
- 283, 282, 281, 280, 138, 138, 138, 279, 138, 138,
- 278, 277, 276, 249, 248, 247, 246, 243, 242, 241,
- 240, 86, 275, 274, 86, 273, 86, 272, 271, 270,
- 138, 269, 268, 267, 266, 236, 265, 264, 263, 262,
-
- 261, 260, 86, 86, 86, 86, 259, 258, 257, 256,
- 255, 254, 253, 252, 251, 138, 250, 138, 201, 200,
- 199, 198, 197, 249, 248, 194, 247, 246, 245, 190,
- 244, 186, 243, 242, 183, 241, 240, 86, 239, 86,
- 238, 237, 236, 235, 86, 234, 233, 232, 231, 138,
- 230, 229, 228, 227, 226, 225, 224, 223, 222, 138,
- 86, 86, 221, 220, 219, 216, 215, 86, 214, 213,
- 212, 211, 210, 209, 208, 207, 138, 138, 206, 205,
- 204, 138, 203, 202, 130, 201, 200, 127, 199, 198,
- 180, 179, 178, 86, 177, 176, 172, 171, 170, 169,
-
- 168, 86, 167, 166, 165, 164, 163, 86, 162, 161,
- 158, 157, 156, 152, 151, 148, 147, 145, 144, 138,
- 143, 142, 141, 140, 138, 137, 136, 135, 134, 133,
- 132, 131, 117, 45, 108, 102, 101, 86, 98, 81,
- 80, 73, 72, 71, 68, 67, 66, 65, 64, 63,
- 62, 61, 53, 46, 45, 307, 3, 307, 307, 307,
- 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
- 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
- 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
- 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
-
- 307, 307, 307, 307, 307, 307, 307, 307, 307
- } ;
-
-static const flex_int16_t yy_chk[510] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 8, 10, 12, 13, 22, 13, 12, 27,
- 27, 13, 26, 36, 40, 309, 40, 55, 30, 47,
- 31, 55, 43, 10, 8, 22, 26, 13, 36, 30,
- 31, 26, 30, 32, 41, 32, 43, 33, 44, 44,
- 34, 47, 32, 41, 32, 33, 49, 34, 34, 51,
-
- 41, 33, 34, 52, 53, 57, 33, 105, 53, 57,
- 58, 306, 58, 59, 59, 105, 58, 59, 49, 51,
- 77, 77, 305, 52, 53, 57, 60, 60, 68, 113,
- 60, 68, 58, 78, 78, 82, 82, 85, 114, 90,
- 106, 85, 90, 120, 106, 115, 115, 85, 117, 115,
- 117, 113, 116, 116, 117, 118, 116, 304, 114, 118,
- 119, 117, 122, 303, 119, 117, 122, 123, 123, 191,
- 120, 123, 120, 124, 124, 302, 120, 124, 146, 146,
- 152, 152, 122, 120, 187, 301, 187, 120, 271, 271,
- 187, 300, 299, 244, 298, 244, 191, 187, 191, 244,
-
- 297, 187, 191, 296, 295, 294, 244, 293, 292, 191,
- 244, 291, 290, 191, 308, 308, 308, 310, 310, 310,
- 311, 311, 311, 312, 312, 312, 313, 313, 313, 314,
- 289, 314, 315, 315, 315, 288, 287, 286, 285, 284,
- 283, 282, 281, 280, 279, 278, 277, 276, 275, 274,
- 273, 272, 270, 269, 268, 267, 266, 265, 264, 263,
- 262, 261, 260, 259, 258, 257, 256, 255, 254, 253,
- 252, 251, 250, 249, 248, 247, 246, 243, 242, 241,
- 240, 239, 238, 237, 235, 234, 233, 232, 231, 230,
- 229, 228, 227, 226, 225, 224, 223, 222, 221, 220,
-
- 219, 218, 217, 216, 215, 214, 213, 212, 211, 210,
- 209, 208, 207, 206, 205, 204, 203, 202, 201, 200,
- 199, 198, 197, 196, 195, 194, 193, 192, 190, 189,
- 188, 186, 185, 184, 183, 182, 181, 180, 179, 178,
- 177, 176, 175, 174, 173, 172, 171, 170, 169, 168,
- 167, 166, 165, 164, 163, 162, 161, 160, 159, 158,
- 157, 156, 155, 154, 153, 151, 150, 149, 148, 147,
- 145, 144, 143, 142, 141, 140, 139, 137, 136, 135,
- 134, 133, 132, 131, 130, 129, 128, 127, 126, 125,
- 112, 111, 110, 109, 108, 107, 104, 103, 102, 101,
-
- 100, 99, 98, 97, 96, 95, 94, 93, 92, 91,
- 89, 88, 87, 84, 83, 81, 80, 76, 75, 74,
- 73, 72, 71, 70, 69, 67, 66, 65, 64, 63,
- 62, 61, 54, 45, 42, 39, 38, 37, 35, 29,
- 28, 25, 24, 23, 21, 20, 19, 18, 17, 16,
- 15, 14, 11, 7, 5, 3, 307, 307, 307, 307,
- 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
- 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
- 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
- 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
-
- 307, 307, 307, 307, 307, 307, 307, 307, 307
- } ;
-
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-extern int yy_flex_debug;
-int yy_flex_debug = 0;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-char *yytext;
-#line 1 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.flex"
-#line 2 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.flex"
-#include "Common.h"
-#include "Token.h"
-#include "Highlighter.h"
-
-IPLVector<Token> tokens;
-#line 664 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.cpp"
-#line 665 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.cpp"
-
-#define INITIAL 0
-
-#ifndef YY_NO_UNISTD_H
-/* Special case for "unistd.h", since it is non-ANSI. We include it way
- * down here because we want the user's section 1 to have been scanned first.
- * The user has a chance to override it with an option.
- */
-#include <unistd.h>
-#endif
-
-#ifndef YY_EXTRA_TYPE
-#define YY_EXTRA_TYPE void *
-#endif
-
-static int yy_init_globals ( void );
-
-/* Accessor methods to globals.
- These are made visible to non-reentrant scanners for convenience. */
-
-int yylex_destroy ( void );
-
-int yyget_debug ( void );
-
-void yyset_debug ( int debug_flag );
-
-YY_EXTRA_TYPE yyget_extra ( void );
-
-void yyset_extra ( YY_EXTRA_TYPE user_defined );
-
-FILE *yyget_in ( void );
-
-void yyset_in ( FILE * _in_str );
-
-FILE *yyget_out ( void );
-
-void yyset_out ( FILE * _out_str );
-
- int yyget_leng ( void );
-
-char *yyget_text ( void );
-
-int yyget_lineno ( void );
-
-void yyset_lineno ( int _line_number );
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int yywrap ( void );
-#else
-extern int yywrap ( void );
-#endif
-#endif
-
-#ifndef YY_NO_UNPUT
-
- static void yyunput ( int c, char *buf_ptr );
-
-#endif
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy ( char *, const char *, int );
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen ( const char * );
-#endif
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
-static int yyinput ( void );
-#else
-static int input ( void );
-#endif
-
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k */
-#define YY_READ_BUF_SIZE 16384
-#else
-#define YY_READ_BUF_SIZE 8192
-#endif /* __ia64__ */
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
- { \
- int c = '*'; \
- int n; \
- for ( n = 0; n < max_size && \
- (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
- buf[n] = (char) c; \
- if ( c == '\n' ) \
- buf[n++] = (char) c; \
- if ( c == EOF && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- result = n; \
- } \
- else \
- { \
- errno=0; \
- while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
- { \
- if( errno != EINTR) \
- { \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- break; \
- } \
- errno=0; \
- clearerr(yyin); \
- } \
- }\
-\
-
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* end tables serialization structures and prototypes */
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL_IS_OURS 1
-
-extern int yylex (void);
-
-#define YY_DECL int yylex (void)
-#endif /* !YY_DECL */
-
-/* Code executed at the beginning of each rule, after yytext and yyleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK /*LINTED*/break;
-#endif
-
-#define YY_RULE_SETUP \
- YY_USER_ACTION
-
-/** The main scanner function which does all the work.
- */
-YY_DECL
-{
- yy_state_type yy_current_state;
- char *yy_cp, *yy_bp;
- int yy_act;
-
- if ( !(yy_init) )
- {
- (yy_init) = 1;
-
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! (yy_start) )
- (yy_start) = 1; /* first start state */
-
- if ( ! yyin )
- yyin = stdin;
-
- if ( ! yyout )
- yyout = stdout;
-
- if ( ! YY_CURRENT_BUFFER ) {
- yyensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- yy_create_buffer( yyin, YY_BUF_SIZE );
- }
-
- yy_load_buffer_state( );
- }
-
- {
-#line 47 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.flex"
-
-
-#line 885 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.cpp"
-
- while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
- {
- yy_cp = (yy_c_buf_p);
-
- /* Support of yytext. */
- *yy_cp = (yy_hold_char);
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = (yy_start);
-yy_match:
- do
- {
- YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 308 )
- yy_c = yy_meta[yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
- ++yy_cp;
- }
- while ( yy_base[yy_current_state] != 457 );
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
- if ( yy_act == 0 )
- { /* have to back up */
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- yy_act = yy_accept[yy_current_state];
- }
-
- YY_DO_BEFORE_ACTION;
-
-do_action: /* This label is used only to access EOF actions. */
-
- switch ( yy_act )
- { /* beginning of action switch */
- case 0: /* must back up */
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = (yy_hold_char);
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- goto yy_find_action;
-
-case 1:
-YY_RULE_SETUP
-#line 49 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.flex"
-{ tokens.emplace_back(Whitespace, yytext); }
- YY_BREAK
-case 2:
-/* rule 2 can match eol */
-YY_RULE_SETUP
-#line 51 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.flex"
-{ tokens.emplace_back(NewLine, yytext); }
- YY_BREAK
-case 3:
-/* rule 3 can match eol */
-YY_RULE_SETUP
-#line 53 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.flex"
-{ tokens.emplace_back(Comment, yytext); }
- YY_BREAK
-case 4:
-YY_RULE_SETUP
-#line 55 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.flex"
-{ tokens.emplace_back(Keyword, yytext); }
- YY_BREAK
-case 5:
-YY_RULE_SETUP
-#line 57 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.flex"
-{ tokens.emplace_back(BooleanLiteral, yytext); }
- YY_BREAK
-case 6:
-YY_RULE_SETUP
-#line 59 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.flex"
-{ tokens.emplace_back(NumericLiteral, yytext); }
- YY_BREAK
-case 7:
-/* rule 7 can match eol */
-YY_RULE_SETUP
-#line 61 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.flex"
-{ tokens.emplace_back(StringLiteral, yytext); }
- YY_BREAK
-case 8:
-/* rule 8 can match eol */
-YY_RULE_SETUP
-#line 63 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.flex"
-{ tokens.emplace_back(TemplateLiteral, yytext); }
- YY_BREAK
-case 9:
-/* rule 9 can match eol */
-YY_RULE_SETUP
-#line 65 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.flex"
-{ tokens.emplace_back(Regex, yytext); }
- YY_BREAK
-case 10:
-YY_RULE_SETUP
-#line 67 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.flex"
-{ tokens.emplace_back(Global, yytext); }
- YY_BREAK
-case 11:
-YY_RULE_SETUP
-#line 69 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.flex"
-{ tokens.emplace_back(Identifier, yytext); }
- YY_BREAK
-case 12:
-YY_RULE_SETUP
-#line 71 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.flex"
-{ tokens.emplace_back(Raw, yytext); }
- YY_BREAK
-case 13:
-YY_RULE_SETUP
-#line 74 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.flex"
-ECHO;
- YY_BREAK
-#line 1012 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.cpp"
-case YY_STATE_EOF(INITIAL):
- yyterminate();
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = (yy_hold_char);
- YY_RESTORE_YY_MORE_OFFSET
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed yyin at a new source and called
- * yylex(). If so, then we have to assure
- * consistency between YY_CURRENT_BUFFER and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++(yy_c_buf_p);
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = (yy_c_buf_p);
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_END_OF_FILE:
- {
- (yy_did_buffer_switch_on_eof) = 0;
-
- if ( yywrap( ) )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * yytext, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) =
- (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- (yy_c_buf_p) =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
- } /* end of user's declarations */
-} /* end of yylex */
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-static int yy_get_next_buffer (void)
-{
- char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
- char *source = (yytext_ptr);
- int number_to_move, i;
- int ret_val;
-
- if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
- {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1);
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
-
- else
- {
- int num_to_read =
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
-
- int yy_c_buf_p_offset =
- (int) ((yy_c_buf_p) - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer )
- {
- int new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 )
- b->yy_buf_size += b->yy_buf_size / 8;
- else
- b->yy_buf_size *= 2;
-
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- yyrealloc( (void *) b->yy_ch_buf,
- (yy_size_t) (b->yy_buf_size + 2) );
- }
- else
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = NULL;
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
- number_to_move - 1;
-
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- (yy_n_chars), num_to_read );
-
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- if ( (yy_n_chars) == 0 )
- {
- if ( number_to_move == YY_MORE_ADJ )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- yyrestart( yyin );
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
- /* Extend the array by 50%, plus the number we really need. */
- int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
- (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size );
- if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
- /* "- 2" to take care of EOB's */
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
- }
-
- (yy_n_chars) += number_to_move;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
-
- (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
-
- return ret_val;
-}
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
- static yy_state_type yy_get_previous_state (void)
-{
- yy_state_type yy_current_state;
- char *yy_cp;
-
- yy_current_state = (yy_start);
-
- for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
- {
- YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 308 )
- yy_c = yy_meta[yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
- }
-
- return yy_current_state;
-}
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
- static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
-{
- int yy_is_jam;
- char *yy_cp = (yy_c_buf_p);
-
- YY_CHAR yy_c = 1;
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 308 )
- yy_c = yy_meta[yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
- yy_is_jam = (yy_current_state == 307);
-
- return yy_is_jam ? 0 : yy_current_state;
-}
-
-#ifndef YY_NO_UNPUT
-
- static void yyunput (int c, char * yy_bp )
-{
- char *yy_cp;
-
- yy_cp = (yy_c_buf_p);
-
- /* undo effects of setting up yytext */
- *yy_cp = (yy_hold_char);
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- /* +2 for EOB chars. */
- int number_to_move = (yy_n_chars) + 2;
- char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
- char *source =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
-
- while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += (int) (dest - source);
- yy_bp += (int) (dest - source);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
- (yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- *--yy_cp = (char) c;
-
- (yytext_ptr) = yy_bp;
- (yy_hold_char) = *yy_cp;
- (yy_c_buf_p) = yy_cp;
-}
-
-#endif
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
- static int yyinput (void)
-#else
- static int input (void)
-#endif
-
-{
- int c;
-
- *(yy_c_buf_p) = (yy_hold_char);
-
- if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- /* This was really a NUL. */
- *(yy_c_buf_p) = '\0';
-
- else
- { /* need more input */
- int offset = (int) ((yy_c_buf_p) - (yytext_ptr));
- ++(yy_c_buf_p);
-
- switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_LAST_MATCH:
- /* This happens because yy_g_n_b()
- * sees that we've accumulated a
- * token and flags that we need to
- * try matching the token before
- * proceeding. But for input(),
- * there's no matching to consider.
- * So convert the EOB_ACT_LAST_MATCH
- * to EOB_ACT_END_OF_FILE.
- */
-
- /* Reset buffer status. */
- yyrestart( yyin );
-
- /*FALLTHROUGH*/
-
- case EOB_ACT_END_OF_FILE:
- {
- if ( yywrap( ) )
- return 0;
-
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) = (yytext_ptr) + offset;
- break;
- }
- }
- }
-
- c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
- *(yy_c_buf_p) = '\0'; /* preserve yytext */
- (yy_hold_char) = *++(yy_c_buf_p);
-
- return c;
-}
-#endif /* ifndef YY_NO_INPUT */
-
-/** Immediately switch to a different input stream.
- * @param input_file A readable stream.
- *
- * @note This function does not reset the start condition to @c INITIAL .
- */
- void yyrestart (FILE * input_file )
-{
-
- if ( ! YY_CURRENT_BUFFER ){
- yyensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- yy_create_buffer( yyin, YY_BUF_SIZE );
- }
-
- yy_init_buffer( YY_CURRENT_BUFFER, input_file );
- yy_load_buffer_state( );
-}
-
-/** Switch to a different input buffer.
- * @param new_buffer The new input buffer.
- *
- */
- void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
-{
-
- /* TODO. We should be able to replace this entire function body
- * with
- * yypop_buffer_state();
- * yypush_buffer_state(new_buffer);
- */
- yyensure_buffer_stack ();
- if ( YY_CURRENT_BUFFER == new_buffer )
- return;
-
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
- yy_load_buffer_state( );
-
- /* We don't actually know whether we did this switch during
- * EOF (yywrap()) processing, but the only time this flag
- * is looked at is after yywrap() is called, so it's safe
- * to go ahead and always set it.
- */
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-static void yy_load_buffer_state (void)
-{
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
- yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
- (yy_hold_char) = *(yy_c_buf_p);
-}
-
-/** Allocate and initialize an input buffer state.
- * @param file A readable stream.
- * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
- *
- * @return the allocated buffer state.
- */
- YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
-{
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_buf_size = size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) );
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_is_our_buffer = 1;
-
- yy_init_buffer( b, file );
-
- return b;
-}
-
-/** Destroy the buffer.
- * @param b a buffer created with yy_create_buffer()
- *
- */
- void yy_delete_buffer (YY_BUFFER_STATE b )
-{
-
- if ( ! b )
- return;
-
- if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
- YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
-
- if ( b->yy_is_our_buffer )
- yyfree( (void *) b->yy_ch_buf );
-
- yyfree( (void *) b );
-}
-
-/* Initializes or reinitializes a buffer.
- * This function is sometimes called more than once on the same buffer,
- * such as during a yyrestart() or at EOF.
- */
- static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
-
-{
- int oerrno = errno;
-
- yy_flush_buffer( b );
-
- b->yy_input_file = file;
- b->yy_fill_buffer = 1;
-
- /* If b is the current buffer, then yy_init_buffer was _probably_
- * called from yyrestart() or through yy_get_next_buffer.
- * In that case, we don't want to reset the lineno or column.
- */
- if (b != YY_CURRENT_BUFFER){
- b->yy_bs_lineno = 1;
- b->yy_bs_column = 0;
- }
-
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-
- errno = oerrno;
-}
-
-/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
- * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
- *
- */
- void yy_flush_buffer (YY_BUFFER_STATE b )
-{
- if ( ! b )
- return;
-
- b->yy_n_chars = 0;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[0];
-
- b->yy_at_bol = 1;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- if ( b == YY_CURRENT_BUFFER )
- yy_load_buffer_state( );
-}
-
-/** Pushes the new state onto the stack. The new state becomes
- * the current state. This function will allocate the stack
- * if necessary.
- * @param new_buffer The new state.
- *
- */
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
-{
- if (new_buffer == NULL)
- return;
-
- yyensure_buffer_stack();
-
- /* This block is copied from yy_switch_to_buffer. */
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- /* Only push if top exists. Otherwise, replace top. */
- if (YY_CURRENT_BUFFER)
- (yy_buffer_stack_top)++;
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
-
- /* copied from yy_switch_to_buffer. */
- yy_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-/** Removes and deletes the top of the stack, if present.
- * The next element becomes the new top.
- *
- */
-void yypop_buffer_state (void)
-{
- if (!YY_CURRENT_BUFFER)
- return;
-
- yy_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- if ((yy_buffer_stack_top) > 0)
- --(yy_buffer_stack_top);
-
- if (YY_CURRENT_BUFFER) {
- yy_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
- }
-}
-
-/* Allocates the stack if it does not exist.
- * Guarantees space for at least one push.
- */
-static void yyensure_buffer_stack (void)
-{
- yy_size_t num_to_alloc;
-
- if (!(yy_buffer_stack)) {
-
- /* First allocation is just for 2 elements, since we don't know if this
- * scanner will even need a stack. We use 2 instead of 1 to avoid an
- * immediate realloc on the next call.
- */
- num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
- (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
- (num_to_alloc * sizeof(struct yy_buffer_state*)
- );
- if ( ! (yy_buffer_stack) )
- YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
-
- memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-
- (yy_buffer_stack_max) = num_to_alloc;
- (yy_buffer_stack_top) = 0;
- return;
- }
-
- if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
-
- /* Increase the buffer to prepare for a possible push. */
- yy_size_t grow_size = 8 /* arbitrary grow size */;
-
- num_to_alloc = (yy_buffer_stack_max) + grow_size;
- (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
- ((yy_buffer_stack),
- num_to_alloc * sizeof(struct yy_buffer_state*)
- );
- if ( ! (yy_buffer_stack) )
- YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
-
- /* zero only the new slots.*/
- memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
- (yy_buffer_stack_max) = num_to_alloc;
- }
-}
-
-/** Setup the input buffer state to scan directly from a user-specified character buffer.
- * @param base the character buffer
- * @param size the size in bytes of the character buffer
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
-{
- YY_BUFFER_STATE b;
-
- if ( size < 2 ||
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
- base[size-1] != YY_END_OF_BUFFER_CHAR )
- /* They forgot to leave room for the EOB's. */
- return NULL;
-
- b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
-
- b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
- b->yy_buf_pos = b->yy_ch_buf = base;
- b->yy_is_our_buffer = 0;
- b->yy_input_file = NULL;
- b->yy_n_chars = b->yy_buf_size;
- b->yy_is_interactive = 0;
- b->yy_at_bol = 1;
- b->yy_fill_buffer = 0;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- yy_switch_to_buffer( b );
-
- return b;
-}
-
-/** Setup the input buffer state to scan a string. The next call to yylex() will
- * scan from a @e copy of @a str.
- * @param yystr a NUL-terminated string to scan
- *
- * @return the newly allocated buffer state object.
- * @note If you want to scan bytes that may contain NUL values, then use
- * yy_scan_bytes() instead.
- */
-YY_BUFFER_STATE yy_scan_string (const char * yystr )
-{
-
- return yy_scan_bytes( yystr, (int) strlen(yystr) );
-}
-
-/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
- * scan from a @e copy of @a bytes.
- * @param yybytes the byte buffer to scan
- * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len )
-{
- YY_BUFFER_STATE b;
- char *buf;
- yy_size_t n;
- int i;
-
- /* Get memory for full buffer, including space for trailing EOB's. */
- n = (yy_size_t) (_yybytes_len + 2);
- buf = (char *) yyalloc( n );
- if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
-
- for ( i = 0; i < _yybytes_len; ++i )
- buf[i] = yybytes[i];
-
- buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
-
- b = yy_scan_buffer( buf, n );
- if ( ! b )
- YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
-
- /* It's okay to grow etc. this buffer, and we should throw it
- * away when we're done.
- */
- b->yy_is_our_buffer = 1;
-
- return b;
-}
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-static void yynoreturn yy_fatal_error (const char* msg )
-{
- fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
-}
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- yytext[yyleng] = (yy_hold_char); \
- (yy_c_buf_p) = yytext + yyless_macro_arg; \
- (yy_hold_char) = *(yy_c_buf_p); \
- *(yy_c_buf_p) = '\0'; \
- yyleng = yyless_macro_arg; \
- } \
- while ( 0 )
-
-/* Accessor methods (get/set functions) to struct members. */
-
-/** Get the current line number.
- *
- */
-int yyget_lineno (void)
-{
-
- return yylineno;
-}
-
-/** Get the input stream.
- *
- */
-FILE *yyget_in (void)
-{
- return yyin;
-}
-
-/** Get the output stream.
- *
- */
-FILE *yyget_out (void)
-{
- return yyout;
-}
-
-/** Get the length of the current token.
- *
- */
-int yyget_leng (void)
-{
- return yyleng;
-}
-
-/** Get the current token.
- *
- */
-
-char *yyget_text (void)
-{
- return yytext;
-}
-
-/** Set the current line number.
- * @param _line_number line number
- *
- */
-void yyset_lineno (int _line_number )
-{
-
- yylineno = _line_number;
-}
-
-/** Set the input stream. This does not discard the current
- * input buffer.
- * @param _in_str A readable stream.
- *
- * @see yy_switch_to_buffer
- */
-void yyset_in (FILE * _in_str )
-{
- yyin = _in_str ;
-}
-
-void yyset_out (FILE * _out_str )
-{
- yyout = _out_str ;
-}
-
-int yyget_debug (void)
-{
- return yy_flex_debug;
-}
-
-void yyset_debug (int _bdebug )
-{
- yy_flex_debug = _bdebug ;
-}
-
-static int yy_init_globals (void)
-{
- /* Initialization is the same as for the non-reentrant scanner.
- * This function is called from yylex_destroy(), so don't allocate here.
- */
-
- (yy_buffer_stack) = NULL;
- (yy_buffer_stack_top) = 0;
- (yy_buffer_stack_max) = 0;
- (yy_c_buf_p) = NULL;
- (yy_init) = 0;
- (yy_start) = 0;
-
-/* Defined in main.c */
-#ifdef YY_STDINIT
- yyin = stdin;
- yyout = stdout;
-#else
- yyin = NULL;
- yyout = NULL;
-#endif
-
- /* For future reference: Set errno on error, since we are called by
- * yylex_init()
- */
- return 0;
-}
-
-/* yylex_destroy is for both reentrant and non-reentrant scanners. */
-int yylex_destroy (void)
-{
-
- /* Pop the buffer stack, destroying each element. */
- while(YY_CURRENT_BUFFER){
- yy_delete_buffer( YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- yypop_buffer_state();
- }
-
- /* Destroy the stack itself. */
- yyfree((yy_buffer_stack) );
- (yy_buffer_stack) = NULL;
-
- /* Reset the globals. This is important in a non-reentrant scanner so the next time
- * yylex() is called, initialization will occur. */
- yy_init_globals( );
-
- return 0;
-}
-
-/*
- * Internal utility routines.
- */
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, const char * s2, int n )
-{
-
- int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
-}
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (const char * s )
-{
- int n;
- for ( n = 0; s[n]; ++n )
- ;
-
- return n;
-}
-#endif
-
-void *yyalloc (yy_size_t size )
-{
- return malloc(size);
-}
-
-void *yyrealloc (void * ptr, yy_size_t size )
-{
-
- /* The cast to (char *) in the following accommodates both
- * implementations that use char* generic pointers, and those
- * that use void* generic pointers. It works with the latter
- * because both ANSI C and C++ allow castless assignment from
- * any pointer type to void*, and deal with argument conversions
- * as though doing an assignment.
- */
- return realloc(ptr, size);
-}
-
-void yyfree (void * ptr )
-{
- free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
-}
-
-#define YYTABLES_NAME "yytables"
-
-#line 74 "/home/bmestanov/FMI/IPL/homework/81270/es2html/js2html.flex"
-
-
-int yywrap()
-{
- return 1;
-}
-
-int main(int argc, const char *argv[]) {
- ++argv, --argc;
- if ( argc > 0 )
- yyin = fopen( argv[0], "r" );
- else
- yyin = stdin;
-
- yylex();
-
- ++argv, --argc;
- const char *out = nullptr;
- if (argc > 0) {
- out = argv[0];
- }
-
- Highlighter hh(out);
- hh.highlight(tokens);
- return 0;
-}
diff --git a/homework/81270/js2html/js2html.flex b/homework/81270/js2html/js2html.flex
deleted file mode 100644
index 7aef857..0000000
--- a/homework/81270/js2html/js2html.flex
+++ /dev/null
@@ -1,99 +0,0 @@
-%{
-#include "Common.h"
-#include "Token.h"
-#include "Highlighter.h"
-
-IPLVector<Token> tokens;
-%}
-
-LineTerminator \n|\r|\r\n
-
-Whitespace \t+
-
-SingleLineComment \/\/.*
-
-MultiLineComment \/\*{1,2}[^\*]+\*\/
-
-Comment {SingleLineComment}|{MultiLineComment}
-
-Keyword break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|function|if|import|in|of|instanceof|new|return|super|switch|this|throw|try|typeof|var|void|while|with|module
-
-BooleanLiteral true|false
-
-DecimalDigits [0-9]+
-
-SignedInteger {DecimalDigits}|\+{DecimalDigits}|\-{DecimalDigits}
-
-ExponentPart e{SignedInteger}|E{SignedInteger}
-
-DecimalLiteral {DecimalDigits}\.{DecimalDigits}?{ExponentPart}?|\.{DecimalDigits}{ExponentPart}?|{DecimalDigits}{ExponentPart}?
-
-NumericLiteral {DecimalLiteral}
-
-SingleQuoteString '([^\']|(\\\'))*'
-
-DoubleQuoteString \"([^\"]|(\\\"))*\"
-
-StringLiteral {SingleQuoteString}|{DoubleQuoteString}
-
-TemplateLiteral `([^`]|(\\`))*`
-
-Regex \/[^\/]+\/[gimuy]*
-
-Identifier [a-zA-Z_$][a-zA-Z0-9_$]*
-
-Global Infinity|NaN|undefined|null|eval|isNaN|parseFloat|parseInt|Object|Function|Boolean|Symbol|Error|Number|Math|Date|String|RegExp|Array|Map|Set|JSON|Promise|arguments
-
-%%
-
-{Whitespace} { tokens.emplace_back(Whitespace, yytext); }
-
-{LineTerminator} { tokens.emplace_back(NewLine, yytext); }
-
-{Comment} { tokens.emplace_back(Comment, yytext); }
-
-{Keyword} { tokens.emplace_back(Keyword, yytext); }
-
-{BooleanLiteral} { tokens.emplace_back(BooleanLiteral, yytext); }
-
-{NumericLiteral} { tokens.emplace_back(NumericLiteral, yytext); }
-
-{StringLiteral} { tokens.emplace_back(StringLiteral, yytext); }
-
-{TemplateLiteral} { tokens.emplace_back(TemplateLiteral, yytext); }
-
-{Regex} { tokens.emplace_back(Regex, yytext); }
-
-{Global} { tokens.emplace_back(Global, yytext); }
-
-{Identifier} { tokens.emplace_back(Identifier, yytext); }
-
-. { tokens.emplace_back(Raw, yytext); }
-
-
-%%
-
-int yywrap()
-{
- return 1;
-}
-
-int main(int argc, const char *argv[]) {
- ++argv, --argc;
- if ( argc > 0 )
- yyin = fopen( argv[0], "r" );
- else
- yyin = stdin;
-
- yylex();
-
- ++argv, --argc;
- const char *out = nullptr;
- if (argc > 0) {
- out = argv[0];
- }
-
- Highlighter hh(out);
- hh.highlight(tokens);
- return 0;
-} \ No newline at end of file
diff --git a/homework/81270/js2html/style.css b/homework/81270/js2html/style.css
deleted file mode 100644
index c58741f..0000000
--- a/homework/81270/js2html/style.css
+++ /dev/null
@@ -1,31 +0,0 @@
-.keyword {
- color: brown;
-}
-
-.comment {
- color: darkgreen;
-}
-
-.identifier {
- color: darkslategrey;
-}
-
-.numeric {
- color: darkblue;
-}
-
-.string {
- color: orange;
-}
-
-.template {
- color: darkred;
-}
-
-.regex {
- color: orangered;
-}
-
-.global {
- color: blueviolet;
-} \ No newline at end of file
diff --git a/homework/81281/README.md b/homework/81281/README.md
deleted file mode 100644
index 8327fbd..0000000
--- a/homework/81281/README.md
+++ /dev/null
@@ -1 +0,0 @@
-# Homework repo
diff --git a/homework/81281/brainfsckInterpreter/README.md b/homework/81281/brainfsckInterpreter/README.md
deleted file mode 100644
index 29d4b63..0000000
--- a/homework/81281/brainfsckInterpreter/README.md
+++ /dev/null
@@ -1,21 +0,0 @@
-# Homework 3.2
-
-## Create a brainf*** interpreter
-
-_The interpreter reads from a file if there is input._
-
-### How to install and use SWI-Prolog
-
-+ [How to install SWI-Prolog](https://wwu-pi.github.io/tutorials/lectures/lsp/010_install_swi_prolog.html)
-
-+ [Quick start on how to use it](http://www.swi-prolog.org/pldoc/man?section=quickstart)
-
-+ [Command line options](http://www.swi-prolog.org/pldoc/man?section=cmdline)
-
-### Added bash script for executing program after successful installation of SWI-Prolog on a Unix or Unix-like variants
-
-[Script](./runMeChooseMode.sh)
-
-_Mode 0 is for interactive interpretation and 1 is for interpretation of a file._
-
-**The interpreter is a bit slow if the program has a lot of loops with the current method of handling loops. Also Prolog isn't the fastest PL of them all xD.**
diff --git a/homework/81281/brainfsckInterpreter/brainySource.pl b/homework/81281/brainfsckInterpreter/brainySource.pl
deleted file mode 100644
index 6c73192..0000000
--- a/homework/81281/brainfsckInterpreter/brainySource.pl
+++ /dev/null
@@ -1,132 +0,0 @@
-token(tNextCellAddress) --> ">", !.
-token(tLastCellAddress) --> "<", !.
-token(tPlusPlusCellContent) --> "+", !.
-token(tMinusMinusCellContent) --> "-", !.
-token(tWriteCellContent) --> ".", !.
-token(tReadCellContent) --> ",", !.
-token([tWhileLoop|Body]) --> "[", parseLoop(Body), "]".
-token(tUnknown) --> allThatIsNotAToken(I), !, {I \= []}.
-
-parseLoop([]) --> "".
-parseLoop([H|T]) --> token(H), !, parseLoop(T).
-
-allThatIsNotAToken([C|Cs]) --> [C|Cs], \+ token(C), \+ token([C|Cs]),
- allThatIsNotAToken(Cs).
-allThatIsNotAToken([]) --> [].
-
-parceBF([H|T]) --> token(H), !, parceBF(T).
-parceBF([]) --> [], !.
-
-cleanUnknownAndCountInput([], [], 0):- !.
-cleanUnknownAndCountInput([tUnknown|T], R, InputCnt):-
- cleanUnknownAndCountInput(T, R, InputCnt).
-cleanUnknownAndCountInput([tReadCellContent|T], [tReadCellContent|R], InputCnt):-
- cleanUnknownAndCountInput(T, R, TInputCnt),
- InputCnt is TInputCnt + 1.
-cleanUnknownAndCountInput([H|T], [H|R], InputCnt):-
- \+ is_list(H),
- H \= tUnknown,
- H \= tReadCellContent,
- cleanUnknownAndCountInput(T, R, InputCnt).
-cleanUnknownAndCountInput([H|T], R, InputCnt):-
- is_list(H),
- cleanUnknownAndCountInput(H, R1, InputBitH),
- cleanUnknownAndCountInput(T, R2, InputBitT),
- InputCnt is InputBitH + InputBitT,
- append([R1], R2, R).
-
-interpret(StreamCodes):-
- phrase(parceBF(CommandsU), StreamCodes),
- cleanUnknownAndCountInput(CommandsU, Commands, InputCnt),
- ((InputCnt =\= 0,
- write("\nThere are input symbols, so ready to read from a file.\nPlease enter the name of the file:\s"),
- current_stream(0, read, Stream),
- read_line_to_codes(Stream, Read),
- open(Read, read, ReadStream));
- (ReadStream = [])),
- execute(Commands, [[],[0]], ReadStream),
- !.
-
-
-execute([], _, _).
-
-execute([[tWhileLoop|Body]|Rest], Memory, ReadStream):-
- Memory = [_,[CurrCellContent|_]],
- CurrCellContent =\= 0,
- append(Body, [[tWhileLoop|Body]|Rest], NewRest),
- % write("While loop not 0: "),
- % write(NewRest), nl,
- !,
- execute(NewRest, Memory, ReadStream).
-
-execute([[tWhileLoop|_]|Rest], Memory, ReadStream):-
- Memory = [_,[CurrCellContent|_]],
- CurrCellContent =:= 0,
- !,
- % write("While loop is 0: "),
- % write(Rest), nl,
- execute(Rest, Memory, ReadStream).
-
-execute([tReadCellContent|Rest], Memory, ReadStream):-
- executeCommand(tReadCellContent, Memory, UpdatedMemory, ReadStream, ResultStream),
- !,
- execute(Rest, UpdatedMemory, ResultStream).
-
-execute([tReadCellContent|Rest], Memory, []):-
- !,
- execute(Rest, Memory, []).
-
-execute([CurrentCommand|Rest], Memory, ReadStream):-
- executeCommand(CurrentCommand, Memory, UpdatedMemory),
- !,
- execute(Rest, UpdatedMemory, ReadStream).
-
-
-executeCommand(tNextCellAddress, [PrevAddrs, [CurrAddr|NextAddrs]], [NewPrevAddrs, NewNextAddrs]):-
- append(PrevAddrs, [CurrAddr], NewPrevAddrs),
- ((NextAddrs == [], NewNextAddrs = [0]) ; (NewNextAddrs = NextAddrs)).
- % write("Operation: "), write(tNextCellAddress),
- % write(" Old memory: "), write([PrevAddrs, [CurrAddr|NextAddrs]]),
- % write(" New memory: "), write([NewPrevAddrs, NewNextAddrs]),
- % nl.
-
-executeCommand(tLastCellAddress, [PrevAddrs, CurrAddrs], [MorePrevAddrs, [PrevAddr|CurrAddrs]]):-
- append(MorePrevAddrs, [PrevAddr], PrevAddrs).
- % write("Operation: "), write(tLastCellAddress),
- % write(" Old memory: "), write([PrevAddrs, CurrAddrs]),
- % write(" New memory: "), write([MorePrevAddrs, [PrevAddr|CurrAddrs]]),
- % nl.
-
-executeCommand(tPlusPlusCellContent, CurrentMemory, [PrevAddrs, [NewCurrentCell|RestAddrs]]):-
- CurrentMemory = [PrevAddrs, [CurrentCell|RestAddrs]],
- Temp is CurrentCell + 1,
- ((Temp > 255, NewCurrentCell is 0); (NewCurrentCell is Temp)).
- % write("Operation: "), write(tPlusPlusCellContent),
- % write(" New memory: "), write([PrevAddrs, [NewCurrentCell|RestAddrs]]),
- % nl.
-
-executeCommand(tMinusMinusCellContent, CurrentMemory, [PrevAddrs, [NewCurrentCell|RestAddrs]]):-
- CurrentMemory = [PrevAddrs, [CurrentCell|RestAddrs]],
- Temp is CurrentCell - 1,
- ((Temp < 0, NewCurrentCell is 255); (NewCurrentCell is Temp)).
- % write("Operation: "), write(tMinusMinusCellContent),
- % write(" New memory: "), write([PrevAddrs, [NewCurrentCell|RestAddrs]]),
- % nl.
-
-executeCommand(tWriteCellContent, CurrentMemory, CurrentMemory):-
- CurrentMemory = [_, [CurrentCell|_]],
- char_code(Character, CurrentCell),
- write(Character).
-
-executeCommand(tReadCellContent, [PrevAddrs, [_|RestAddrs]], [PrevAddrs, [NewCellContent|RestAddrs]], ReadStream, ReadStream):-
- is_stream(ReadStream),
- get_code(ReadStream, CurrentInput),
- CurrentInput >= 0,
- ((char_code('\r', CurrentInput), char_code('\n', NL), NewCellContent = NL);
- (NewCellContent = CurrentInput)).
-
-executeCommand(tReadCellContent, [PrevAddrs, [CurrCelContent|RestAddrs]], [PrevAddrs, [CurrCelContent|RestAddrs]], ReadStream, []):-
- is_stream(ReadStream),
- get_code(ReadStream, CurrentInput),
- CurrentInput == -1,
- close(ReadStream).
diff --git a/homework/81281/brainfsckInterpreter/interpreterMain.pl b/homework/81281/brainfsckInterpreter/interpreterMain.pl
deleted file mode 100644
index ff51f34..0000000
--- a/homework/81281/brainfsckInterpreter/interpreterMain.pl
+++ /dev/null
@@ -1,35 +0,0 @@
-:- use_module(library(dcg/basics)).
-:- use_module(library(readutil)).
-:- use_module(library(quintus)).
-:- [brainySource].
-
-:- set_prolog_flag(verbose, silent).
-:- initialization(main, main).
-
-main:-
- current_prolog_flag(argv, Argv),
- Argv = [H1|_],
- atom_string(H1, Filename),
- ((Filename == "", readyToReadAndInterpret("Hello, how can I help you?\nExit me by typing \"quit\"."));
- (Filename \= "", readyToReadAndInterpret("Ready to interpret your file.\n", Filename))),
- halt.
-main:-
- halt(1).
-
-readyToReadAndInterpret(Message):-
- write(Message),
- startCycleTillQuit.
-
-readyToReadAndInterpret(Message, File):-
- write(Message),
- open(File, read, RFile),
- read_stream_to_codes(RFile, BFSource),
- close(RFile),
- interpret(BFSource).
-
-startCycleTillQuit:-
- nl,
- current_stream(0, read, Stream),
- read_line_to_codes(Stream, BFProgram),
- ((string_codes("quit", BFProgram), write("Bye!"), nl);
- (interpret(BFProgram), startCycleTillQuit)).
diff --git a/homework/81281/brainfsckInterpreter/runMeChooseMode.sh b/homework/81281/brainfsckInterpreter/runMeChooseMode.sh
deleted file mode 100755
index 4162db4..0000000
--- a/homework/81281/brainfsckInterpreter/runMeChooseMode.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-echo -ne "Please enter 0 for live interpreter or 1 for interpretation of a file: "
-read mode
-
-base=`pwd`"/interpreterMain.pl"
-
-if [ $mode == 0 ]
-then
- exec swipl -q -f "$base" ""
-else
- echo -n "Please enter the name of the file: "
- read fileName
- exec swipl -q -f "$base" "$fileName"
-fi
diff --git a/homework/81281/brainfsckInterpreter/testPrograms/bigProgram.b b/homework/81281/brainfsckInterpreter/testPrograms/bigProgram.b
deleted file mode 100644
index 2f311a7..0000000
--- a/homework/81281/brainfsckInterpreter/testPrograms/bigProgram.b
+++ /dev/null
@@ -1,32 +0,0 @@
-99 bottles in 1752 brainfuck instructions
-by jim crawford (http://www (dot) goombas (dot) org/)
->++++++++++[<++++++++++>-]<->>>>>+++[>+++>+++<<-]<<<<+<[>[>+
->+<<-]>>[-<<+>>]++++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[[-]>>
->>>>[[-]<++++++++++<->>]<-[>+>+<<-]>[<+>-]+>[[-]<->]<<<<<<<<
-<->>]<[>+>+<<-]>>[-<<+>>]+>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<
-<[>>+>+<<<-]>>>[-<<<+>>>]++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<
-<[>+<[-]]<[>>+<<[-]]>>[<<+>>[-]]<<<[>>+>+<<<-]>>>[-<<<+>>>]+
-+++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[>+<[-]]<[>>+<<[-]]>>[<
-<+>>[-]]<<[[-]>>>++++++++[>>++++++<<-]>[<++++++++[>++++++<-]
->.<++++++++[>------<-]>[<<+>>-]]>.<<++++++++[>>------<<-]<[-
->>+<<]<++++++++[<++++>-]<.>+++++++[>+++++++++<-]>+++.<+++++[
->+++++++++<-]>.+++++..--------.-------.++++++++++++++>>[>>>+
->+<<<<-]>>>>[-<<<<+>>>>]>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<<<
-[>>>+>+<<<<-]>>>>[-<<<<+>>>>]+>+<[-<->]<[[-]>>-<<]>>[[-]<<+>
->]<<<[>>+<<[-]]>[>+<[-]]++>>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<
-+<[[-]>-<]>[<<<<<<<.>>>>>>>[-]]<<<<<<<<<.>>----.---------.<<
-.>>----.+++..+++++++++++++.[-]<<[-]]<[>+>+<<-]>>[-<<+>>]+>+<
-[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<<[>>+>+<<<-]>>>[-<<<+>>>]++++
->+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[>+<[-]]<[>>+<<[-]]>>[<<+>
->[-]]<<[[-]>++++++++[<++++>-]<.>++++++++++[>+++++++++++<-]>+
-.-.<<.>>++++++.------------.---.<<.>++++++[>+++<-]>.<++++++[
->----<-]>++.+++++++++++..[-]<<[-]++++++++++.[-]]<[>+>+<<-]>>
-[-<<+>>]+++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[[-]++++++++++.
->+++++++++[>+++++++++<-]>+++.+++++++++++++.++++++++++.------
-.<++++++++[>>++++<<-]>>.<++++++++++.-.---------.>.<-.+++++++
-++++.++++++++.---------.>.<-------------.+++++++++++++.-----
------.>.<++++++++++++.---------------.<+++[>++++++<-]>..>.<-
----------.+++++++++++.>.<<+++[>------<-]>-.+++++++++++++++++
-.---.++++++.-------.----------.[-]>[-]<<<.[-]]<[>+>+<<-]>>[-
-<<+>>]++++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[[-]++++++++++.[
--]<[-]>]<+<]
diff --git a/homework/81281/brainfsckInterpreter/testPrograms/input.txt b/homework/81281/brainfsckInterpreter/testPrograms/input.txt
deleted file mode 100644
index 341cc98..0000000
--- a/homework/81281/brainfsckInterpreter/testPrograms/input.txt
+++ /dev/null
@@ -1 +0,0 @@
-example 123
diff --git a/homework/81281/brainfsckInterpreter/testPrograms/pr.b b/homework/81281/brainfsckInterpreter/testPrograms/pr.b
deleted file mode 100644
index 1dce918..0000000
--- a/homework/81281/brainfsckInterpreter/testPrograms/pr.b
+++ /dev/null
@@ -1,21 +0,0 @@
-Calculate the value 256 and test if it's zero
-If the interpreter errors on overflow this is where it'll happen
-++++++++[>++++++++<-]>[<++++>-]
-+<[>-<
- Not zero so multiply by 256 again to get 65536
- [>++++<-]>[<++++++++>-]<[>++++++++<-]
- +>[>
- # Print "32"
- ++++++++++[>+++++<-]>+.-.[-]<
- <[-]<->] <[>>
- # Print "16"
- +++++++[>+++++++<-]>.+++++.[-]<
-<<-]] >[>
- # Print "8"
- ++++++++[>+++++++<-]>.[-]<
-<-]<
-# Print " bit cells\n"
-+++++++++++[>+++>+++++++++>+++++++++>+<<<<-]>-.>-.+++++++.+++++++++++.<.
->>.++.+++++++..<-.>>-
-Clean up used cells.
-[[-]<]
diff --git a/homework/81281/brainfsckInterpreter/testPrograms/smallProgram.b b/homework/81281/brainfsckInterpreter/testPrograms/smallProgram.b
deleted file mode 100644
index e080b7f..0000000
--- a/homework/81281/brainfsckInterpreter/testPrograms/smallProgram.b
+++ /dev/null
@@ -1,33 +0,0 @@
-[ This program prints Sierpinski triangle on 80-column display. ]
- >
- + +
- + +
- [ < + +
- + +
- + + + +
- > - ] >
- + + + + + + + +
- [ >
- + + + +
- < - ] >
- > + + > > > + >
- > > + <
- < < < < < < < <
- < [ - [ - > + <
- ] > [ - < + > > > . < < ] > > >
- [ [
- - > + +
- + + + +
- + + [ > + + + +
- < - ] >
- . < < [ - > + <
- ] + > [ - > + +
- + + + + + + + + < < + > ] > . [
- - ] > ]
- ] + < < < [ - [
- - > + < ] + > [
- - < + > > > - [ - > + < ] + + >
- [ - < - > ] < <
- < ] < < < < ] + + + + + + + + +
- + . + + + . [ - ] < ] + + + + +
- * * * * * M a d e * B y : * N Y Y R I K K I * 2 0 0 2 * * * * *
diff --git a/homework/81281/c2html/README.md b/homework/81281/c2html/README.md
deleted file mode 100644
index f57d94f..0000000
--- a/homework/81281/c2html/README.md
+++ /dev/null
@@ -1,40 +0,0 @@
-# Homework 1 + 2
-## Create a xxx2html syntax highlighter for a language of your choice.
-+ ~~In this case it is C.~~
-## Extend the xxx2html tool to:
-
-+ ~~Produce pretty-printed html.~~
-
-+ **TODO:** bonus: support line length limit
-
-+ **TODO:** Produce html where functions have their background colored depending on cyclomatic complexity ranging from light green to light read.
-
-+ ~~Produce html where control structures can be collapsed.~~
-
-
-### How to install and use SWI-Prolog
-
-+ [How to install SWI-Prolog](https://wwu-pi.github.io/tutorials/lectures/lsp/010_install_swi_prolog.html)
-
-+ [Quick start on how to use it](http://www.swi-prolog.org/pldoc/man?section=quickstart)
-
-+ [Command line options](http://www.swi-prolog.org/pldoc/man?section=cmdline)
-
-### Added bash script for executing program after successful installation of SWI-Prolog on a Unix or Unix-like variants
-
-[Script](./c2htmlrun.sh)
-
-### If you are going to install SWI-Prolog on Windows
-+ You can omit lines 6 to 17 from c2html.pl.
-+ Afterward in order to execute the program you can call the main predicate and give it a valid string name of file.
-
-For example **mainy("test.c").**
-
-
-### For the curious who want to find about DCG Grammar rules :
-
-+ [SWI-Prolog/DCG](http://www.swi-prolog.org/pldoc/man?section=DCG)
-
-+ [Wikibooks](https://en.wikibooks.org/wiki/Prolog/Definite_Clause_Grammars)
-
-+ [A tutorial](http://www.pathwayslms.com/swipltuts/dcg/)
diff --git a/homework/81281/c2html/c2html.pl b/homework/81281/c2html/c2html.pl
deleted file mode 100644
index 9479b96..0000000
--- a/homework/81281/c2html/c2html.pl
+++ /dev/null
@@ -1,132 +0,0 @@
-:- use_module(library(dcg/basics)).
-:- use_module(library(readutil)).
-:- [tokens, prettify, print, essentials, controlStructures].
-:- set_prolog_flag(verbose, silent).
-
-:- initialization(main, main).
-
-main :-
- current_prolog_flag(argv, Argv),
- Argv = [H1, H2|_],
- atom_string(H1, File),
- atom_string(H2, Number),
- mainy(File, Number),
- format('You can see the result in the html file.~n'),
- halt.
-main :-
- halt(1).
-
-mainy(File, Number):-
-
- open(File, read, RFile),
- read_stream_to_codes(RFile, CSource),
- close(RFile),
- phrase(tokens(Tokens), CSource),
- flattenMine(Tokens, TokenStream),
- ((Number == "0", PrettyCode = TokenStream);
- (Number == "1", prettify(TokenStream, Raw),
- flattenMine(Raw, PrettyCode));
- (Number == "2", prettify(TokenStream, Raw),
- identifyControlStructures(Raw, RawF),
- flattenMine(RawF, PrettyCode))),
- open('page.html', write, WFile),
- write(WFile,'<!doctype>
- <html>
-
- <head>
- <title>hello.c</title>
- <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">
- <style>
- .keyword {
- color: blue;
- }
-
- .number {
- color: violet;
- }
-
- .identifier {
- color: green;
- }
-
- .operator {
- font-style: bold;
- color: blue;
- }
-
- .comment {
- color: lime;
- }
-
- .string {
- color: orange;
- }
-
- .parenthese {
- font-style: bold;
- color: brown;
- }
-
- .quotation {
- font-style: bold;
- color: black;
- }
-
- .unknown {
- font-style: bold;
- color: red;
- }
-
- .function {
- color: purple;
- }
-
- .collapsible {
- background-color: PaleGreen;
- cursor: pointer;
- padding: 10px;
- width: 100%;
- border: none;
- text-align: left;
- outline: none;
- font-size: 15px;
- }
-
- .active,
- .collapsible:hover {
- background-color: PaleGoldenRod;
- }
-
- .content {
- padding: 0 18px;
- display: none;
- overflow: hidden;
- background-color: #f1f1f1;
- }
- </style>
- </head>
-
- <body>
- <pre class=\"code\">'),
- tohtmlfile(WFile, PrettyCode),
- write(WFile, ' <script>
- var coll = document.getElementsByClassName(\"collapsible\");
- var i;
-
- for (i = 0; i < coll.length; i++) {
- coll[i].addEventListener(\"click\", function() {
- this.classList.toggle(\"active\");
- var content = this.nextElementSibling;
- if (content.style.display === \"block\") {
- content.style.display = \"none\";
- } else {
- content.style.display = \"block\";
- }
- });
- }
- </script>
- </pre>
- </body>
-
- </html>'),
- close(WFile).
diff --git a/homework/81281/c2html/c2htmlrun.sh b/homework/81281/c2html/c2htmlrun.sh
deleted file mode 100644
index dec4b69..0000000
--- a/homework/81281/c2html/c2htmlrun.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-echo -n "Please enter the name of the C file you wish to highlight: "
-read fileName
-echo -ne "Please enter:\n\t0 for highlighting\n\t1 highlighting and prettification\n\t2 for highlighting and prettification and control structure collapse: "
-read number
-if ! [[ $fileName == *.c\n ]]; then
- base=`pwd`"/c2html.pl"
- PL=swipl
- exec $PL -q -f "$base" "$fileName" "$number"
-else
- echo "Not a correct C filename!"
-fi
diff --git a/homework/81281/c2html/controlStructures.pl b/homework/81281/c2html/controlStructures.pl
deleted file mode 100644
index 026c216..0000000
--- a/homework/81281/c2html/controlStructures.pl
+++ /dev/null
@@ -1,56 +0,0 @@
-:- [essentials, tokens].
-identifyControlStructures([], []):- !.
-identifyControlStructures([H|T], [NewH|R]):-
- \+ append(_, [[ttypedef|_]|_], H),
- append(_, [[Token|_]|_], H),
- member(Token, [tdo, tfor, twhile, tif, telse, tswitch, tfunction, tstruct]),
- T = [T1|T2],
- append(T11, [[tleftBrace, "{"], [execNL, "\n"]], T1),
- \+ ((member(M, T11), M \= [execTAB, "\s\s\s\s"])),
- gatherBody(T2, [], PackedStructBody, Rest, 1),
- identifyControlStructures(PackedStructBody, Result),
- append([H, T1], Result, NewH), !,
- identifyControlStructures(Rest, R).
-identifyControlStructures([H|T], [NewH|R]):-
- \+ append(_, [[ttypedef|_]|_], H),
- append(_, [[Token|_]|_], H),
- member(Token, [tfor, twhile, tif, telse]),
- T = [T1|_],
- \+ append(_, [[tleftBrace, "{"], [execNL, "\n"]], T1),
- getPrefixTabsLength(H, N),
- getPrefixTabsLength(T1, M),
- N + 1 =:= M,
- gatherOneLineBody(T, [], PackedOneLineBody, Rest, N),
- identifyControlStructures(PackedOneLineBody, Result),
- append([H], Result, NewH), !,
- identifyControlStructures(Rest, R).
-identifyControlStructures([H|T], [H|R]):- !,
- identifyControlStructures(T, R).
-
-
-gatherOneLineBody([], Res, Res, [], _):- !.
-gatherOneLineBody([H|T], Res, Res, [H|T], N):-
- getPrefixTabsLength(H, M),
- N + 1 =\= M, !.
-gatherOneLineBody([H|T], Buff, Res, Rest, N):-
- getPrefixTabsLength(H, M),
- N + 1 =:= M,
- append(Buff, [H], NewBuff), !,
- gatherOneLineBody(T, NewBuff, Res, Rest, M).
-
-
-gatherBody(Rest, Res, Res, Rest, 0):- !.
-gatherBody([H|T], Buff, Res, Rest, N):-
- N =\= 0, append(H1, [[tleftBrace, "{"]|_], H),
- \+ ((member(M, H1), M \= [execTAB, "\s\s\s\s"])),
- append(Buff, [H], NewBuff), N1 is N + 1, !,
- gatherBody(T, NewBuff, Res, Rest, N1).
-gatherBody([H|T], Buff, Res, Rest, N):-
- N =\= 0, append(H1, [[trightBrace, "}"]|_], H),
- \+ ((member(M, H1), M \= [execTAB, "\s\s\s\s"])),
- append(Buff, [H], NewBuff), N1 is N - 1, !,
- gatherBody(T, NewBuff, Res, Rest, N1).
-gatherBody([H|T], Buff, Res, Rest, N):-
- N =\= 0,
- append(Buff, [H], NewBuff), !,
- gatherBody(T, NewBuff, Res, Rest, N).
diff --git a/homework/81281/c2html/essentials.pl b/homework/81281/c2html/essentials.pl
deleted file mode 100644
index 0a792fa..0000000
--- a/homework/81281/c2html/essentials.pl
+++ /dev/null
@@ -1,14 +0,0 @@
-% From [[[a, b], [a, c]], [b, c]] -> [[a, b], [a, c], [b, c]]
-% From [[[a, b], [a, c, [a]]] -> [[a, b], [a, c, [a]], [b, c]].
-flattenMine([], []):- !.
-flattenMine([H|T], R):- flattenElem(H, RH), flattenMine(T, RT), append(RH, RT, R), !.
-
-flattenElem([H|T], [[H|T]]):- \+ is_list(H), !.
-flattenElem([H|T], [H|T]):- is_list(H), H = [H1|_], \+ is_list(H1), !.
-flattenElem([H|T], [[H|T]]):- is_list(H), H = [H1|_], is_list(H1), !.
-
-getPrefixTabsLength(L, N):- append(A, B, L),
- \+((member(AA, A), AA \= [execTAB, "\s\s\s\s"])), \+((member(BB, B), BB == [execTAB, "\s\s\s\s"])), length(A, N).
-
-removeNTabs(L, 0, L):- !.
-removeNTabs([_|T], N, R):- N > 0, N1 is N - 1, !, removeNTabs(T, N1, R).
diff --git a/homework/81281/c2html/exampleCodeAndTestPage/initialTest.c b/homework/81281/c2html/exampleCodeAndTestPage/initialTest.c
deleted file mode 100644
index 7f1b4cd..0000000
--- a/homework/81281/c2html/exampleCodeAndTestPage/initialTest.c
+++ /dev/null
@@ -1,99 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-int N = 0;
-int a[750001] = {0};
-/*Problem Secrect DAA
- */
-//// mauuu
-
-int matrix[3][3] = {{0, 0, 0}, {0, 1, 0}, {0, 1, 1}};
-int arr[3] = {0, 0, 0};
-char matrix[3][3] = {{'0', '0', '0'}, {'0', '1', '0'}, {'0', '1', '1'}};
-void swap(int* i, int* j)
-{
- int t = *i;
- *i = *j;
- (*i)->go();
- *j = t;
-}
-int partition(int l, int r)
-{
- int randIdx = l + rand() % (r - l);
-
- int pivot = a[randIdx];
-
- swap(&a[l], &a[randIdx]);
- int ind = l;
- for (int i = l + 1; i < r; i++)
- {
- if (a[i] <= pivot)
- {
- ind++;
- swap(&a[i], &a[ind]);
- }
- }
-
- swap(&a[l], &a[ind]);
- switch (allala)
- {
- case 0:
- o = 9;
- break;
- default:
- break;
- }
- return ind;
-}
-void quickSort(int l, int r)
-{
- if (l < r)
- {
- int idx = partition(l, r);
- quickSort(l, idx);
- quickSort(idx + 1, r);
- }
-}
-int binarySearch(int k)
-{
-
- int middle, left = 0, right = N - 1;
- if (k < a[left])
- return (-1);
- if (k == a[left])
- return (left + 1);
- if (k > a[right])
- return (-1);
-
- while (right - left > 1)
- {
- middle = (left + right) / 2;
- if (k <= a[middle])
- right = middle;
- else
- left = middle;
- }
- int j = 4 * 5;
- int k = 6 * j;
- return ((right <= N - 1 && a[right] == k) ? (right + 1) : (-1));
-}
-
-int main()
-{
- srand(time(0));
- scanf("%d", &N);
- for (int i = 0; i < N; ++i)
- {
- scanf("%d ", &a[i]);
- }
- quickSort(0, N);
-
- int tmp = 0;
- scanf("%d", &tmp);
- while (tmp != 0)
- {
- printf("%d\n", binarySearch(tmp));
- scanf("%d", &tmp);
- }
- return 0;
-}
diff --git a/homework/81281/c2html/exampleCodeAndTestPage/messyCode.c b/homework/81281/c2html/exampleCodeAndTestPage/messyCode.c
deleted file mode 100644
index 4ac99b4..0000000
--- a/homework/81281/c2html/exampleCodeAndTestPage/messyCode.c
+++ /dev/null
@@ -1,139 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-int N = 0;
-int a[750001] = {0};
-struct Books
-{
- char title[50];
- char author[50];
- char subject[100];
- int book_id;
- void dummy()
- {
- printf("Hello\n");
- for (size_t i = 0; i < count; i++)
- {
- /*yes*/
- }
- }
-} book;
-
-typedef struct temp
-{
- int a;
-
-} classTemp;
-
-void classTemp_GetData(classTemp* pThis)
-{
- printf("Enter value of a : ");
- scanf("%d", &(pThis->a));
-}
-
-classTemp T;
-
-struct point* biggest_point(size_t size,
- struct point* points,
- struct point* (*point_compare)(struct point* a,
- struct point* b))
-{
- int i;
- struct point* biggest = NULL;
-
- for (i = 0; i < size; i++)
- {
- biggest = point_compare(biggest, points + i);
- }
- return biggest;
-}
-
-int matrix[3][3] = {{0, 0, 0}, {0, 1, 0}, {0, 1, 1}};
-int arr[3] = {0, 0, 0};
-char matrix[3][3] = {{'0', '0', '0'}, {'0', '1', '0'}, {'0', '1', '1'}};
-/*Problem Secrect DAA
-/// lalalallala
-*/
-//// mauuu
-int a, b;
-void swap(int* i, int* j)
-{
-int t = *i;
-*i = *j;(*i)->go();
-*j = t;
-do
-{
-printf("mau\n");
- } while (i > 1);
-}
-int partition(int l, int r)
-{
-int randIdx = l + rand() % (r - l);
-int pivot = a[randIdx];
-
-swap(&a[l], &a[randIdx]);
-int ind = l;
-for (int i = l + 1; i < r; i++)
-{
-if (a[i] <= pivot)
-{
-ind++;
-swap(&a[i], &a[ind]);
-switch (allala)
- {
- case 0:
- o = 9;
- break;
- default:
- break;
- }
- }
- }
-
- swap(&a[l], &a[ind]);
- return ind;
-}
-void quickSort(int l, int r)
-{
- if (l < r)
- {
- int idx = partition(l, r);
- quickSort(l, idx);
- quickSort(idx + 1, r);
- }
-}
-int binarySearch(int k)
-{
- int middle, left = 0, right = N - 1;
- if (k < a[left])
- return (-1);
- if (k == a[left])
- return (left + 1);
- if (k > a[right])
- return (-1); while (right - left > 1)
- {
- middle = (left + right) / 2;
- if (k <= a[middle])
-right = middle;
- else
- left = middle;
- }
- return ((right <= N - 1 && a[right] == k) ? (right + 1) : (-1));
-}
-
-int main()
-{
- srand(time(0));
- scanf("%d", &N);
- for (int i = 0; i < N; ++i)
- {
- scanf("%d ", &a[i]);
- }
- quickSort(0, N);
- int tmp = 0; scanf("%d", &tmp);while (tmp != 0)
- {
-printf("%d\n", binarySearch(tmp));
- scanf("%d", &tmp);
- }
- return 0;
-}
diff --git a/homework/81281/c2html/exampleCodeAndTestPage/page.html b/homework/81281/c2html/exampleCodeAndTestPage/page.html
deleted file mode 100644
index 15ebd7a..0000000
--- a/homework/81281/c2html/exampleCodeAndTestPage/page.html
+++ /dev/null
@@ -1,266 +0,0 @@
-<!doctype>
-<html>
-
- <head>
- <title>hello.c</title>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <style>
- .keyword {
- color: blue;
- }
-
- .number {
- color: violet;
- }
-
- .identifier {
- color: green;
- }
-
- .operator {
- font-style: bold;
- color: blue;
- }
-
- .comment {
- color: lime;
- }
-
- .string {
- color: orange;
- }
-
- .parenthese {
- font-style: bold;
- color: brown;
- }
-
- .quotation {
- font-style: bold;
- color: black;
- }
-
- .unknown {
- font-style: bold;
- color: red;
- }
-
- .function {
- color: purple;
- }
-
- .collapsible {
- background-color: PaleGreen;
- cursor: pointer;
- padding: 10px;
- width: 100%;
- border: none;
- text-align: left;
- outline: none;
- font-size: 15px;
- }
-
- .active,
- .collapsible:hover {
- background-color: PaleGoldenRod;
- }
-
- .content {
- padding: 0 18px;
- display: none;
- overflow: hidden;
- background-color: #f1f1f1;
- }
- </style>
- </head>
-
- <body>
- <pre class="code"><span class="keyword">#include</span> <span class="string">&lt;stdio.h&gt;</span>
-<span class="keyword">#include</span> <span class="string">&lt;stdlib.h&gt;</span>
-<span class="keyword">#include</span> <span class="string">&lt;time.h&gt;</span>
-<span class="keyword">int</span> <span class="identifier">N</span> <span class="operator">=</span> <span class="number">0</span><span class="parenthese">;</span>
-<span class="keyword">int</span> <span class="identifier">a</span><span class="parenthese">[</span><span class="number">750001</span><span class="parenthese">]</span> <span class="operator">=</span> <span class="parenthese">{</span><span class="number">0</span><span class="parenthese">}</span><span class="parenthese">;</span>
-<button class="collapsible"><span class="keyword">struct</span> <span class="identifier">Books</span>
-</span></button>
-<div class="content"><span class="parenthese">{</span>
- <span class="keyword">char</span> <span class="identifier">title</span><span class="parenthese">[</span><span class="number">50</span><span class="parenthese">]</span><span class="parenthese">;</span>
- <span class="keyword">char</span> <span class="identifier">author</span><span class="parenthese">[</span><span class="number">50</span><span class="parenthese">]</span><span class="parenthese">;</span>
- <span class="keyword">char</span> <span class="identifier">subject</span><span class="parenthese">[</span><span class="number">100</span><span class="parenthese">]</span><span class="parenthese">;</span>
- <span class="keyword">int</span> <span class="identifier">book_id</span><span class="parenthese">;</span>
-<button class="collapsible"> <span class="keyword">void</span> <span class="function">dummy</span><span class="parenthese">(</span><span class="parenthese">)</span>
-</span></button>
-<div class="content"> <span class="parenthese">{</span>
- <span class="function">printf</span><span class="parenthese">(</span><span class="quotation">"</span><span class="identifier">Hello</span><span class="identifier">\n</span><span class="quotation">"</span><span class="parenthese">)</span><span class="parenthese">;</span>
-<button class="collapsible"> <span class="keyword">for</span> <span class="parenthese">(</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="operator">=</span> <span class="number">0</span><span class="parenthese">;</span> <span class="identifier">i</span> <span class="operator"><</span> <span class="identifier">count</span><span class="parenthese">;</span> <span class="identifier">i</span><span class="operator">++</span><span class="parenthese">)</span>
-</span></button>
-<div class="content"> <span class="parenthese">{</span>
- <span class="comment">/*yes*/</span>
- <span class="parenthese">}</span>
-
-</div> <span class="parenthese">}</span>
-
-</div><span class="parenthese">}</span> <span class="identifier">book</span><span class="parenthese">;</span>
-
-</div><span class="keyword">typedef</span> <span class="keyword">struct</span> <span class="identifier">temp</span>
-<span class="parenthese">{</span>
- <span class="keyword">int</span> <span class="identifier">a</span><span class="parenthese">;</span>
-<span class="parenthese">}</span> <span class="identifier">classTemp</span><span class="parenthese">;</span>
-
-<button class="collapsible"><span class="keyword">void</span> <span class="function">classTemp_GetData</span><span class="parenthese">(</span><span class="identifier">classTemp</span> <span class="operator">*</span> <span class="identifier">pThis</span><span class="parenthese">)</span>
-</span></button>
-<div class="content"><span class="parenthese">{</span>
- <span class="function">printf</span><span class="parenthese">(</span><span class="quotation">"</span><span class="identifier">Enter</span><span class="identifier">value</span><span class="identifier">of</span><span class="identifier">a</span><span class="parenthese">:</span><span class="quotation">"</span><span class="parenthese">)</span><span class="parenthese">;</span>
- <span class="function">scanf</span><span class="parenthese">(</span><span class="quotation">"</span><span class="number">%d</span><span class="quotation">"</span><span class="quotation">,</span> <span class="operator">&</span> <span class="parenthese">(</span><span class="identifier">pThis</span><span class="operator">-></span><span class="identifier">a</span><span class="parenthese">)</span><span class="parenthese">)</span><span class="parenthese">;</span>
-<span class="parenthese">}</span>
-
-</div><span class="identifier">classTemp</span> <span class="identifier">T</span><span class="parenthese">;</span>
-<button class="collapsible"><span class="keyword">struct</span> <span class="identifier">point</span> <span class="operator">*</span> <span class="function">biggest_point</span><span class="parenthese">(</span><span class="identifier">size_t</span> <span class="identifier">size</span><span class="quotation">,</span> <span class="keyword">struct</span> <span class="identifier">point</span> <span class="operator">*</span> <span class="identifier">points</span><span class="quotation">,</span> <span class="keyword">struct</span> <span class="identifier">point</span> <span class="operator">*</span> <span class="parenthese">(</span><span class="operator">*</span><span class="identifier">point_compare</span><span class="parenthese">)</span> <span class="parenthese">(</span><span class="keyword">struct</span> <span class="identifier">point</span> <span class="operator">*</span> <span class="identifier">a</span><span class="quotation">,</span> <span class="keyword">struct</span> <span class="identifier">point</span> <span class="operator">*</span> <span class="identifier">b</span><span class="parenthese">)</span><span class="parenthese">)</span>
-</span></button>
-<div class="content"><span class="parenthese">{</span>
- <span class="keyword">int</span> <span class="identifier">i</span><span class="parenthese">;</span>
- <span class="keyword">struct</span> <span class="identifier">point</span> <span class="operator">*</span> <span class="identifier">biggest</span> <span class="operator">=</span> <span class="identifier">NULL</span><span class="parenthese">;</span>
-<button class="collapsible"> <span class="keyword">for</span> <span class="parenthese">(</span><span class="identifier">i</span> <span class="operator">=</span> <span class="number">0</span><span class="parenthese">;</span> <span class="identifier">i</span> <span class="operator"><</span> <span class="identifier">size</span><span class="parenthese">;</span> <span class="identifier">i</span><span class="operator">++</span><span class="parenthese">)</span>
-</span></button>
-<div class="content"> <span class="parenthese">{</span>
- <span class="identifier">biggest</span> <span class="operator">=</span> <span class="function">point_compare</span><span class="parenthese">(</span><span class="identifier">biggest</span><span class="quotation">,</span> <span class="identifier">points</span> <span class="operator">+</span> <span class="identifier">i</span><span class="parenthese">)</span><span class="parenthese">;</span>
- <span class="parenthese">}</span>
-
-</div> <span class="keyword">return</span> <span class="identifier">biggest</span><span class="parenthese">;</span>
-<span class="parenthese">}</span>
-
-</div><span class="keyword">int</span> <span class="identifier">matrix</span><span class="parenthese">[</span><span class="number">3</span><span class="parenthese">]</span><span class="parenthese">[</span><span class="number">3</span><span class="parenthese">]</span> <span class="operator">=</span> <span class="parenthese">{</span><span class="parenthese">{</span><span class="number">0</span><span class="quotation">,</span> <span class="number">0</span><span class="quotation">,</span> <span class="number">0</span><span class="parenthese">}</span><span class="quotation">,</span> <span class="parenthese">{</span><span class="number">0</span><span class="quotation">,</span> <span class="number">1</span><span class="quotation">,</span> <span class="number">0</span><span class="parenthese">}</span><span class="quotation">,</span> <span class="parenthese">{</span><span class="number">0</span><span class="quotation">,</span> <span class="number">1</span><span class="quotation">,</span> <span class="number">1</span><span class="parenthese">}</span><span class="parenthese">}</span><span class="parenthese">;</span>
-<span class="keyword">int</span> <span class="identifier">arr</span><span class="parenthese">[</span><span class="number">3</span><span class="parenthese">]</span> <span class="operator">=</span> <span class="parenthese">{</span><span class="number">0</span><span class="quotation">,</span> <span class="number">0</span><span class="quotation">,</span> <span class="number">0</span><span class="parenthese">}</span><span class="parenthese">;</span>
-<span class="keyword">char</span> <span class="identifier">matrix</span><span class="parenthese">[</span><span class="number">3</span><span class="parenthese">]</span><span class="parenthese">[</span><span class="number">3</span><span class="parenthese">]</span> <span class="operator">=</span> <span class="parenthese">{</span><span class="parenthese">{</span><span class="quotation">'</span><span class="number">0</span><span class="quotation">'</span><span class="quotation">,</span> <span class="quotation">'</span><span class="number">0</span><span class="quotation">'</span><span class="quotation">,</span> <span class="quotation">'</span><span class="number">0</span><span class="quotation">'</span><span class="parenthese">}</span><span class="quotation">,</span> <span class="parenthese">{</span><span class="quotation">'</span><span class="number">0</span><span class="quotation">'</span><span class="quotation">,</span> <span class="quotation">'</span><span class="number">1</span><span class="quotation">'</span><span class="quotation">,</span> <span class="quotation">'</span><span class="number">0</span><span class="quotation">'</span><span class="parenthese">}</span><span class="quotation">,</span> <span class="parenthese">{</span><span class="quotation">'</span><span class="number">0</span><span class="quotation">'</span><span class="quotation">,</span> <span class="quotation">'</span><span class="number">1</span><span class="quotation">'</span><span class="quotation">,</span> <span class="quotation">'</span><span class="number">1</span><span class="quotation">'</span><span class="parenthese">}</span><span class="parenthese">}</span><span class="parenthese">;</span>
-<span class="comment">/*Problem Secrect DAA
-/// lalalallala
-*/</span>
-<span class="comment">//// mauuu</span>
-<span class="keyword">int</span> <span class="identifier">a</span><span class="quotation">,</span> <span class="identifier">b</span><span class="parenthese">;</span>
-<button class="collapsible"><span class="keyword">void</span> <span class="function">swap</span><span class="parenthese">(</span><span class="keyword">int</span> <span class="operator">*</span><span class="identifier">i</span><span class="quotation">,</span> <span class="keyword">int</span> <span class="operator">*</span><span class="identifier">j</span><span class="parenthese">)</span>
-</span></button>
-<div class="content"><span class="parenthese">{</span>
- <span class="keyword">int</span> <span class="identifier">t</span> <span class="operator">=</span> <span class="operator">*</span><span class="identifier">i</span><span class="parenthese">;</span>
- <span class="operator">*</span><span class="identifier">i</span><span class="operator">=</span> <span class="operator">*</span><span class="identifier">j</span><span class="parenthese">;</span>
- <span class="parenthese">(</span><span class="operator">*</span><span class="identifier">i</span><span class="parenthese">)</span><span class="operator">-></span><span class="function">go</span><span class="parenthese">(</span><span class="parenthese">)</span><span class="parenthese">;</span>
- <span class="operator">*</span><span class="identifier">j</span><span class="operator">=</span> <span class="identifier">t</span><span class="parenthese">;</span>
-<button class="collapsible"> <span class="keyword">do</span>
-</span></button>
-<div class="content"> <span class="parenthese">{</span>
- <span class="function">printf</span><span class="parenthese">(</span><span class="quotation">"</span><span class="identifier">mau</span><span class="identifier">\n</span><span class="quotation">"</span><span class="parenthese">)</span><span class="parenthese">;</span>
- <span class="parenthese">}</span> <span class="keyword">while</span> <span class="parenthese">(</span><span class="identifier">i</span> <span class="operator">></span> <span class="number">1</span><span class="parenthese">)</span><span class="parenthese">;</span>
-
-</div><span class="parenthese">}</span>
-
-</div><button class="collapsible"><span class="keyword">int</span> <span class="function">partition</span><span class="parenthese">(</span><span class="keyword">int</span> <span class="identifier">l</span><span class="quotation">,</span> <span class="keyword">int</span> <span class="identifier">r</span><span class="parenthese">)</span>
-</span></button>
-<div class="content"><span class="parenthese">{</span>
- <span class="keyword">int</span> <span class="identifier">randIdx</span> <span class="operator">=</span> <span class="identifier">l</span> <span class="operator">+</span> <span class="function">rand</span><span class="parenthese">(</span><span class="parenthese">)</span> <span class="operator">%</span> <span class="parenthese">(</span><span class="identifier">r</span> <span class="operator">-</span> <span class="identifier">l</span><span class="parenthese">)</span><span class="parenthese">;</span>
- <span class="keyword">int</span> <span class="identifier">pivot</span> <span class="operator">=</span> <span class="identifier">a</span><span class="parenthese">[</span><span class="identifier">randIdx</span><span class="parenthese">]</span><span class="parenthese">;</span>
- <span class="function">swap</span><span class="parenthese">(</span><span class="operator">&</span><span class="identifier">a</span><span class="parenthese">[</span><span class="identifier">l</span><span class="parenthese">]</span><span class="quotation">,</span> <span class="operator">&</span><span class="identifier">a</span><span class="parenthese">[</span><span class="identifier">randIdx</span><span class="parenthese">]</span><span class="parenthese">)</span><span class="parenthese">;</span>
- <span class="keyword">int</span> <span class="identifier">ind</span> <span class="operator">=</span> <span class="identifier">l</span><span class="parenthese">;</span>
-<button class="collapsible"> <span class="keyword">for</span> <span class="parenthese">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="operator">=</span> <span class="identifier">l</span> <span class="operator">+</span> <span class="number">1</span><span class="parenthese">;</span> <span class="identifier">i</span> <span class="operator"><</span> <span class="identifier">r</span><span class="parenthese">;</span> <span class="identifier">i</span><span class="operator">++</span><span class="parenthese">)</span>
-</span></button>
-<div class="content"> <span class="parenthese">{</span>
-<button class="collapsible"> <span class="keyword">if</span> <span class="parenthese">(</span><span class="identifier">a</span><span class="parenthese">[</span><span class="identifier">i</span><span class="parenthese">]</span> <span class="operator"><=</span> <span class="identifier">pivot</span><span class="parenthese">)</span>
-</span></button>
-<div class="content"> <span class="parenthese">{</span>
- <span class="identifier">ind</span><span class="operator">++</span><span class="parenthese">;</span>
- <span class="function">swap</span><span class="parenthese">(</span><span class="operator">&</span><span class="identifier">a</span><span class="parenthese">[</span><span class="identifier">i</span><span class="parenthese">]</span><span class="quotation">,</span> <span class="operator">&</span><span class="identifier">a</span><span class="parenthese">[</span><span class="identifier">ind</span><span class="parenthese">]</span><span class="parenthese">)</span><span class="parenthese">;</span>
-<button class="collapsible"> <span class="keyword">switch</span> <span class="parenthese">(</span><span class="identifier">allala</span><span class="parenthese">)</span>
-</span></button>
-<div class="content"> <span class="parenthese">{</span>
- <span class="keyword">case</span> <span class="number">0</span> <span class="parenthese">:</span>
- <span class="identifier">o</span> <span class="operator">=</span> <span class="number">9</span><span class="parenthese">;</span>
- <span class="keyword">break</span><span class="parenthese">;</span>
- <span class="keyword">default</span> <span class="parenthese">:</span>
- <span class="keyword">break</span><span class="parenthese">;</span>
- <span class="parenthese">}</span>
-
-</div> <span class="parenthese">}</span>
-
-</div> <span class="parenthese">}</span>
-
-</div> <span class="function">swap</span><span class="parenthese">(</span><span class="operator">&</span><span class="identifier">a</span><span class="parenthese">[</span><span class="identifier">l</span><span class="parenthese">]</span><span class="quotation">,</span> <span class="operator">&</span><span class="identifier">a</span><span class="parenthese">[</span><span class="identifier">ind</span><span class="parenthese">]</span><span class="parenthese">)</span><span class="parenthese">;</span>
- <span class="keyword">return</span> <span class="identifier">ind</span><span class="parenthese">;</span>
-<span class="parenthese">}</span>
-
-</div><button class="collapsible"><span class="keyword">void</span> <span class="function">quickSort</span><span class="parenthese">(</span><span class="keyword">int</span> <span class="identifier">l</span><span class="quotation">,</span> <span class="keyword">int</span> <span class="identifier">r</span><span class="parenthese">)</span>
-</span></button>
-<div class="content"><span class="parenthese">{</span>
-<button class="collapsible"> <span class="keyword">if</span> <span class="parenthese">(</span><span class="identifier">l</span> <span class="operator"><</span> <span class="identifier">r</span><span class="parenthese">)</span>
-</span></button>
-<div class="content"> <span class="parenthese">{</span>
- <span class="keyword">int</span> <span class="identifier">idx</span> <span class="operator">=</span> <span class="function">partition</span><span class="parenthese">(</span><span class="identifier">l</span><span class="quotation">,</span> <span class="identifier">r</span><span class="parenthese">)</span><span class="parenthese">;</span>
- <span class="function">quickSort</span><span class="parenthese">(</span><span class="identifier">l</span><span class="quotation">,</span> <span class="identifier">idx</span><span class="parenthese">)</span><span class="parenthese">;</span>
- <span class="function">quickSort</span><span class="parenthese">(</span><span class="identifier">idx</span> <span class="operator">+</span> <span class="number">1</span><span class="quotation">,</span> <span class="identifier">r</span><span class="parenthese">)</span><span class="parenthese">;</span>
- <span class="parenthese">}</span>
-
-</div><span class="parenthese">}</span>
-
-</div><button class="collapsible"><span class="keyword">int</span> <span class="function">binarySearch</span><span class="parenthese">(</span><span class="keyword">int</span> <span class="identifier">k</span><span class="parenthese">)</span>
-</span></button>
-<div class="content"><span class="parenthese">{</span>
- <span class="keyword">int</span> <span class="identifier">middle</span><span class="quotation">,</span> <span class="identifier">left</span> <span class="operator">=</span> <span class="number">0</span><span class="quotation">,</span> <span class="identifier">right</span> <span class="operator">=</span> <span class="identifier">N</span> <span class="operator">-</span> <span class="number">1</span><span class="parenthese">;</span>
- <span class="keyword">if</span> <span class="parenthese">(</span><span class="identifier">k</span> <span class="operator"><</span> <span class="identifier">a</span><span class="parenthese">[</span><span class="identifier">left</span><span class="parenthese">]</span><span class="parenthese">)</span>
- <span class="keyword">return</span> <span class="parenthese">(</span><span class="number">-1</span><span class="parenthese">)</span><span class="parenthese">;</span>
- <span class="keyword">if</span> <span class="parenthese">(</span><span class="identifier">k</span> <span class="operator">==</span> <span class="identifier">a</span><span class="parenthese">[</span><span class="identifier">left</span><span class="parenthese">]</span><span class="parenthese">)</span>
- <span class="keyword">return</span> <span class="parenthese">(</span><span class="identifier">left</span> <span class="operator">+</span> <span class="number">1</span><span class="parenthese">)</span><span class="parenthese">;</span>
- <span class="keyword">if</span> <span class="parenthese">(</span><span class="identifier">k</span> <span class="operator">></span> <span class="identifier">a</span><span class="parenthese">[</span><span class="identifier">right</span><span class="parenthese">]</span><span class="parenthese">)</span>
- <span class="keyword">return</span> <span class="parenthese">(</span><span class="number">-1</span><span class="parenthese">)</span><span class="parenthese">;</span>
-<button class="collapsible"> <span class="keyword">while</span> <span class="parenthese">(</span><span class="identifier">right</span> <span class="operator">-</span> <span class="identifier">left</span> <span class="operator">></span> <span class="number">1</span><span class="parenthese">)</span>
-</span></button>
-<div class="content"> <span class="parenthese">{</span>
- <span class="identifier">middle</span> <span class="operator">=</span> <span class="parenthese">(</span><span class="identifier">left</span> <span class="operator">+</span> <span class="identifier">right</span><span class="parenthese">)</span> <span class="operator">/</span> <span class="number">2</span><span class="parenthese">;</span>
- <span class="keyword">if</span> <span class="parenthese">(</span><span class="identifier">k</span> <span class="operator"><=</span> <span class="identifier">a</span><span class="parenthese">[</span><span class="identifier">middle</span><span class="parenthese">]</span><span class="parenthese">)</span>
- <span class="identifier">right</span> <span class="operator">=</span> <span class="identifier">middle</span><span class="parenthese">;</span>
- <span class="keyword">else</span>
- <span class="identifier">left</span> <span class="operator">=</span> <span class="identifier">middle</span><span class="parenthese">;</span>
- <span class="parenthese">}</span>
-
-</div> <span class="keyword">return</span> <span class="parenthese">(</span><span class="parenthese">(</span><span class="identifier">right</span> <span class="operator"><=</span> <span class="identifier">N</span> <span class="operator">-</span> <span class="number">1</span> <span class="operator">&&</span> <span class="identifier">a</span><span class="parenthese">[</span><span class="identifier">right</span><span class="parenthese">]</span> <span class="operator">==</span> <span class="identifier">k</span><span class="parenthese">)</span> <span class="quotation">?</span> <span class="parenthese">(</span><span class="identifier">right</span> <span class="operator">+</span> <span class="number">1</span><span class="parenthese">)</span> <span class="parenthese">:</span> <span class="parenthese">(</span><span class="number">-1</span><span class="parenthese">)</span><span class="parenthese">)</span><span class="parenthese">;</span>
-<span class="parenthese">}</span>
-
-</div><button class="collapsible"><span class="keyword">int</span> <span class="function">main</span><span class="parenthese">(</span><span class="parenthese">)</span>
-</span></button>
-<div class="content"><span class="parenthese">{</span>
- <span class="function">srand</span><span class="parenthese">(</span><span class="function">time</span><span class="parenthese">(</span><span class="number">0</span><span class="parenthese">)</span><span class="parenthese">)</span><span class="parenthese">;</span>
- <span class="function">scanf</span><span class="parenthese">(</span><span class="quotation">"</span><span class="number">%d</span><span class="quotation">"</span><span class="quotation">,</span> <span class="operator">&</span><span class="identifier">N</span><span class="parenthese">)</span><span class="parenthese">;</span>
-<button class="collapsible"> <span class="keyword">for</span> <span class="parenthese">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="operator">=</span> <span class="number">0</span><span class="parenthese">;</span> <span class="identifier">i</span> <span class="operator"><</span> <span class="identifier">N</span><span class="parenthese">;</span> <span class="operator">++</span><span class="identifier">i</span><span class="parenthese">)</span>
-</span></button>
-<div class="content"> <span class="parenthese">{</span>
- <span class="function">scanf</span><span class="parenthese">(</span><span class="quotation">"</span><span class="number">%d</span><span class="quotation">"</span><span class="quotation">,</span> <span class="operator">&</span><span class="identifier">a</span><span class="parenthese">[</span><span class="identifier">i</span><span class="parenthese">]</span><span class="parenthese">)</span><span class="parenthese">;</span>
- <span class="parenthese">}</span>
-
-</div> <span class="function">quickSort</span><span class="parenthese">(</span><span class="number">0</span><span class="quotation">,</span> <span class="identifier">N</span><span class="parenthese">)</span><span class="parenthese">;</span>
- <span class="keyword">int</span> <span class="identifier">tmp</span> <span class="operator">=</span> <span class="number">0</span><span class="parenthese">;</span>
- <span class="function">scanf</span><span class="parenthese">(</span><span class="quotation">"</span><span class="number">%d</span><span class="quotation">"</span><span class="quotation">,</span> <span class="operator">&</span><span class="identifier">tmp</span><span class="parenthese">)</span><span class="parenthese">;</span>
-<button class="collapsible"> <span class="keyword">while</span> <span class="parenthese">(</span><span class="identifier">tmp</span> <span class="operator">!=</span> <span class="number">0</span><span class="parenthese">)</span>
-</span></button>
-<div class="content"> <span class="parenthese">{</span>
- <span class="function">printf</span><span class="parenthese">(</span><span class="quotation">"</span><span class="number">%d</span><span class="identifier">\n</span><span class="quotation">"</span><span class="quotation">,</span> <span class="function">binarySearch</span><span class="parenthese">(</span><span class="identifier">tmp</span><span class="parenthese">)</span><span class="parenthese">)</span><span class="parenthese">;</span>
- <span class="function">scanf</span><span class="parenthese">(</span><span class="quotation">"</span><span class="number">%d</span><span class="quotation">"</span><span class="quotation">,</span> <span class="operator">&</span><span class="identifier">tmp</span><span class="parenthese">)</span><span class="parenthese">;</span>
- <span class="parenthese">}</span>
-
-</div> <span class="keyword">return</span> <span class="number">0</span><span class="parenthese">;</span>
-<span class="parenthese">}</span>
-
-</div> <script>
- var coll = document.getElementsByClassName("collapsible");
- var i;
-
- for (i = 0; i < coll.length; i++) {
- coll[i].addEventListener("click", function() {
- this.classList.toggle("active");
- var content = this.nextElementSibling;
- if (content.style.display === "block") {
- content.style.display = "none";
- } else {
- content.style.display = "block";
- }
- });
- }
- </script>
- </pre>
- </body>
-
-</html>
diff --git a/homework/81281/c2html/prettify.pl b/homework/81281/c2html/prettify.pl
deleted file mode 100644
index 70626cf..0000000
--- a/homework/81281/c2html/prettify.pl
+++ /dev/null
@@ -1,384 +0,0 @@
-prettify(StreamTokens, PlainWithNLnSnT):-
- removeAllWhites(StreamTokens, Plain),
- % write(Plain),nl,write("Plain ------------"), nl,
- addNewLines(Plain, PlainWithNL),
- % write(PlainWithNL),nl,write("PlainWithNL ------------"), nl,
- addSpaces(PlainWithNL, PlainWithNLnS),
- % write(PlainWithNLnS),nl,write("PlainWithNLnS ------------"), nl,
- addTabs(PlainWithNLnS, PlainWithNLnSnT).
- % write(PlainWithNLnSnT),nl,write("PlainWithNLnSnT ------------"), nl.
- % write(PrettyStream).
- % write(PrettyStream), nl.
-
-% Removes all white characters
-removeAllWhites([], []):- !.
-removeAllWhites([[H,_]|T], R):- member(H, [execTAB, execSpace, execNL, tunknown]),
- removeAllWhites(T, R), !.
-removeAllWhites([[H, B]|T], [[H, B]|R]):- \+ member(H, [execTAB, execSpace, execNL, tunknown]),
- removeAllWhites(T, R), !.
-
-% Pack Till ; for cases like char matrix[3][3] = {{'0', '0', '0'}, {'0', '1', '0'}, {'0', '1', '1'}};
-packTillsemiColon([[tsemicolon, ";"]|T], Buff, Buff, [[tsemicolon, ";"]|T]).
-packTillsemiColon([H|T], Buff, Res, Rest):-
- append(Buff, [H], NewBuff), !,
- packTillsemiColon(T, NewBuff, Res, Rest).
-
-% Pack Till : and include them in result too. For case smt: where smt if more than 1 character
-packTillTwoDots([[ttwodots, ":"]|T], Buff, NBuff, T):- append(Buff, [[ttwodots, ":"]], NBuff).
-packTillTwoDots([H|T], Buff, Res, Rest):-
- append(Buff, [H], NewBuff), !,
- packTillTwoDots(T, NewBuff, Res, Rest).
-
-% Pack Till ; for cases like char matrix[3][3] = {{'0', '0', '0'}, {'0', '1', '0'}, {'0', '1', '1'}};
-packTillsemiColonOnlyIdentifiers([[tsemicolon, ";"]|T], Buff, Buff, [[tsemicolon, ";"]|T]).
-packTillsemiColonOnlyIdentifiers([H1, H2|T], Buff, Res, Rest):-
- H1 = [H11|_], member(H11, [tcomma]),
- H2 = [H21|_], member(H21, [tidentifier]),
- append(Buff, [H1, H2], NewBuff), !,
- packTillsemiColonOnlyIdentifiers(T, NewBuff, Res, Rest).
-
-% Pack for while, if, for and function arguments
-packTillRightParen(Rest, Buff, Res, Rest, 0):-
- append(Buff, [[execNL, '\n']], Res).
-packTillRightParen([H|T], Buff, Res, Rest, N):-
- N =\= 0, H = [H1|_], H1 == tleftParen,
- append(Buff, [H], NewBuff), N1 is N + 1,
- packTillRightParen(T, NewBuff, Res, Rest, N1).
-packTillRightParen([H|T], Buff, Res, Rest, N):-
- N =\= 0, H = [H1|_], H1 == trightParen,
- append(Buff, [H], NewBuff), N1 is N - 1,
- packTillRightParen(T, NewBuff, Res, Rest, N1).
-packTillRightParen([H|T], Buff, Res, Rest, N):-
- N =\= 0, H = [H1|_], \+ member(H1, [trightParen, tleftParen]),
- append(Buff, [H], NewBuff),
- packTillRightParen(T, NewBuff, Res, Rest, N).
-
-
-% Base
-addNewLines([], [], []):- !.
-% if ; // /**/, do
-addNewLines([H|T], Buff, [NewBuff|R]):-
- H = [H1|_], member(H1, [tsemicolon, tcomment1, tcomment2, tdo]),
- append(Buff, [H, [execNL, "\n"]], NewBuff), !,
- addNewLines(T, [], R).
-% if else and no following if
-addNewLines([H1, H2|T], Buff, [NewBuff|R]):-
- H1 = [H11|_], member(H11, [telse]),
- H2 = [H21|_], \+ member(H21, [tif]),
- append(Buff, [H1, [execNL, "\n"]], NewBuff), !,
- addNewLines([H2|T], [], R).
-% if } while(..)
-addNewLines([H1, H2|T], Buff, R):-
- H1 = [H11|_], member(H11, [trightBrace]),
- H2 = [H21|_], member(H21, [twhile]),
- packTillsemiColon(T, [], Res, Rest),
- append(Buff, [H1, H2], NewBuf),
- append(NewBuf, Res, NewBuff), !,
- addNewLines(Rest, NewBuff, R).
-% % if typedef ...
-% addNewLines([H1|T], Buff, R):-
-% H1 = [H11|_], member(H11, [ttypedef]),
-% packTillsemiColon(T, [], Res, Rest),
-% append(Buff, [H1], NewBuf),
-% append(NewBuf, Res, NewBuff), !,
-% addNewLines(Rest, NewBuff, R).
-% if struct
-addNewLines([H1, H2, H3|T], Buff, [NewBuff|R]):-
- H1 = [H11|_], member(H11, [tstruct]),
- H2 = [H21|_], member(H21, [tidentifier]),
- H3 = [H31|_], member(H31, [tleftBrace]),
- append(Buff, [H1, H2, [execNL, "\n"]], NewBuff), !,
- addNewLines([H3|T], [], R).
-% if struct{ } id;
-addNewLines([H1, H2|T], Buff, R):-
- H1 = [H11|_], member(H11, [trightBrace]),
- H2 = [H21|_], member(H21, [tidentifier]),
- packTillsemiColonOnlyIdentifiers(T, [], Res, Rest),
- append(Buff, [H1, H2], NewBuf),
- append(NewBuf, Res, NewBuff), !,
- addNewLines(Rest, NewBuff, R).
-% if struct{ };
-addNewLines([H1, H2|T], Buff, R):-
- H1 = [H11|_], member(H11, [trightBrace]),
- H2 = [H21|_], member(H21, [tsemicolon]),
- append(Buff, [H1, H2, [execNL, "\n"]], NewBuff), !,
- addNewLines(T, NewBuff, R).
-% if char matrix[3][3] = {{'0', '0', '0'}, {'0', '1', '0'}, {'0', '1', '1'}};
-addNewLines([H1, H2, H3|T], Buff, R):-
- H1 = [H11|_], member(H11, [tchar, tint, tdouble, tidentifier, tshort, tsigned, tunsigned, tenum, tfloat]),
- H2 = [H21|_], member(H21, [tidentifier]),
- H3 = [H31|_], member(H31, [tleftSqParen]),
- packTillsemiColon(T, [], Res, Rest),
- append(Buff, [H1, H2, H3], NewBuf),
- append(NewBuf, Res, NewBuff), !,
- addNewLines(Rest, NewBuff, R).
-% if const char matrix[3][3] = {{'0', '0', '0'}, {'0', '1', '0'}, {'0', '1', '1'}};
-addNewLines([H1, H2, H3, H4|T], Buff, R):-
- H1 = [H11|_], member(H11, [tconst]),
- H2 = [H21|_], member(H21, [tchar, tint, tdouble, tidentifier, tshort, tsigned, tunsigned, tenum, tfloat]),
- H3 = [H31|_], member(H31, [tidentifier]),
- H4 = [H41|_], member(H41, [tleftSqParen]),
- packTillsemiColon(T, [], Res, Rest),
- append(Buff, [H1, H2, H3, H4], NewBuf),
- append(NewBuf, Res, NewBuff), !,
- addNewLines(Rest, NewBuff, R).
-% if const tenum {};
-addNewLines([H1, H2, H3|T], Buff, R):-
- H1 = [H11|_], member(H11, [tconst]),
- H2 = [H21|_], member(H21, [tenum]),
- H3 = [H31|_], member(H31, [tidentifier]),
- packTillsemiColon(T, [], Res, Rest),
- append(Buff, [H1, H2, H3], NewBuf),
- append(NewBuf, Res, NewBuff), !,
- addNewLines(Rest, NewBuff, R).
-% if const tenum {};
-addNewLines([H1, H2|T], Buff, R):-
- H1 = [H11|_], member(H11, [tenum]),
- H2 = [H21|_], member(H21, [tidentifier]),
- packTillsemiColon(T, [], Res, Rest),
- append(Buff, [H1, H2], NewBuf),
- append(NewBuf, Res, NewBuff), !,
- addNewLines(Rest, NewBuff, R).
-% if case smt:
-addNewLines([H|T], Buff, [NewBuff|R]):-
- H = [H1|_], member(H1, [tcase]),
- packTillTwoDots([H|T], [], Res, Rest),
- append(Buff, Res, NewBuf),
- append(NewBuf, [[execNL, "\n"]], NewBuff), !,
- addNewLines(Rest, [], R).
-% if default :
-addNewLines([H|T], Buff, [NewBuff|R]):-
- H = [H1|_], member(H1, [tdefault]),
- T = [[ttwodots, ":"]|T1],
- append(Buff, [H, [ttwodots, ":"], [execNL, "\n"]], NewBuff), !,
- addNewLines(T1, [], R).
-% if }EOF
-addNewLines([H|[]], Buff, [NewBuff|R]):-
- H = [H1|_], member(H1, [trightBrace]),
- append(Buff, [H, [execNL, "\n"]], NewBuff), !,
- addNewLines([], [], R).
-% if {0,{;,{,,}0,};},
-addNewLines([H1, H2|T], Buff, R):-
- H1 = [H11|_], member(H11, [tleftBrace, trightBrace]),
- H2 = [H21|_], member(H21, [tnumber, tsemicolon, tcomma]),
- append(Buff, [H1], NewBuff), !,
- addNewLines([H2|T], NewBuff, R).
-% if not {0,{;,{,,}0,};},
-addNewLines([H1, H2|T], Buff, [NewBuff|R]):-
- H1 = [H11|_], member(H11, [tleftBrace, trightBrace]),
- H2 = [H21|_], \+ member(H21, [tnumber, tsemicolon, tcomma]),
- append(Buff, [H1, [execNL, "\n"]], NewBuff), !,
- addNewLines([H2|T], [], R).
-% if function, while, for, if
-addNewLines([H1, H2|T], Buff, [NewBuff|R]):-
- H1 = [H11|_], member(H11, [tif, twhile, tfor, tswitch]),
- packTillRightParen(T, [], MyPart, Rest, 1),
- append(Buff, [H1, H2], NewB1),
- append(NewB1, MyPart, NewBuff), !,
- addNewLines(Rest, [], R).
-% if function void m(){...}
-addNewLines([H, H2|T], Buff, [NewBuff|R]):-
- H = [H1|_], member(H1, [tfunction]),
- packTillRightParen(T, [], MyPart, Rest, 1),
- Rest \= [], Rest= [[M1|_]|_], M1 == tleftBrace,
- append(Buff, [H, H2], NewB1),
- append(NewB1, MyPart, NewBuff), !,
- addNewLines(Rest, [], R).
-% if function like scanf("%d", &n);
-addNewLines([H, H2|T], Buff, R):-
- H = [H1|_], member(H1, [tfunction]),
- packTillRightParen(T, [], _, Rest, 1),
- (Rest == [] ; Rest= [[M1|_]|_], M1 \= tleftBrace),
- append(Buff, [H], NewBuff), !,
- addNewLines([H2|T], NewBuff, R).
-% if #inclide
-addNewLines([H1, H2|T], Buff, [NewBuff|R]):-
- H1 = [H11|_], member(H11, [tinclude]),
- append(Buff, [H1, H2, [execNL, "\n"]], NewBuff), !,
- addNewLines(T, [], R).
-% if not any above just append them
-addNewLines([H|T], Buff, R):-
- append(Buff, [H], NewBuff), !,
- addNewLines(T, NewBuff, R).
-
-%%Main predicate
-addNewLines(Tokens, PackedLines):- addNewLines(Tokens, [], PackedLines), !.
-
-
-% Base
-addSpaces([], Buff, Buff):- !.
-% no spaces before and after '\n' or ')'
-addSpaces([H|T], Buff, Res):-
- H = [H1|_], member(H1, [execNL, trightParen]),
- ((append(NewBuf, [[execSpace, "\s"]], Buff),
- append(NewBuf, [H], NewBuff));
- (\+ append(_, [[execSpace, "\s"]], Buff),
- append(Buff, [H], NewBuff))), !,
- addSpaces(T, NewBuff, Res).
-% Before ',', ';' no space
-addSpaces([H|T], Buff, Res):-
- H = [H1|_], member(H1, [tcomma, tsemicolon]),
- append(NewBuf, [[execSpace, "\s"]], Buff),
- append(NewBuf, [H, [execSpace, "\s"]], NewBuff), !,
- addSpaces(T, NewBuff, Res).
-% No space after (, [, {, function name, tsizeof
-addSpaces([H1|T], Buff, Res):-
- H1 = [H11|_], member(H11, [tleftParen, tfunction, tleftBrace, tleftSqParen,
- tsizeof]),
- append(Buff, [H1], NewBuff), !,
- addSpaces(T, NewBuff, Res).
-% i->mau();--
-addSpaces([H1|T], Buff, Res):-
- H1 = [H11|_], member(H11, [tptr, execNL]),
- append(NewBuf, [_], Buff),
- append(NewBuf, [H1], NewBuff), !,
- addSpaces(T, NewBuff, Res).
-% some tokens before *i, &i
-addSpaces([H1, H2|T], Buff, Res):-
- H1 = [H11|_], member(H11, [tmultiply, tbitwiseAnd]),
- H2 = [H21|_], member(H21, [tidentifier]),
- length(Buff, N), N >= 2,
- append(_, [H3, H4], Buff),
- H3 = [H31|_], \+ member(H31, [tnumber, tidentifier, trightParen, trightSqParen]),
- H4 = [H41|_], member(H41, [execSpace, tleftParen, tleftBrace, tleftSqParen]),
- append(Buff, [H1, H2], NewBuff), !,
- addSpaces(T, NewBuff, Res).
-% new line (*i, (&i
-addSpaces([H1, H2|T], Buff, Res):-
- H1 = [H11|_], member(H11, [tmultiply, tbitwiseAnd]),
- H2 = [H21|_], member(H21, [tidentifier]),
- length(Buff, 1),
- Buff = [[H31|_]], member(H31, [tleftParen, tleftBrace, tleftSqParen]),
- append(Buff, [H1, H2], NewBuff), !,
- addSpaces(T, NewBuff, Res).
-% none before *i, &i
-addSpaces([H1, H2|T], [], Res):-
- H1 = [H11|_], member(H11, [tmultiply, tbitwiseAnd]),
- H2 = [H21|_], member(H21, [tidentifier]),
- append([], [H1, H2], NewBuff), !,
- addSpaces(T, NewBuff, Res).
-% i++, i--
-addSpaces([H1, H2|T], Buff, Res):-
- H1 = [H11|_], member(H11, [tidentifier]),
- H2 = [H21|_], member(H21, [tpp, tmm]),
- append(Buff, [H1, H2], NewBuff), !,
- addSpaces(T, NewBuff, Res).
-% ++i, --i
-addSpaces([H1, H2|T], Buff, Res):-
- H1 = [H11|_], member(H11, [tpp, tmm]),
- H2 = [H21|_], member(H21, [tidentifier]),
- append(Buff, [H1], NewBuff), !,
- addSpaces([H2|T], NewBuff, Res).
-% pack strings line '0'
-addSpaces([H1|T], Buff, Res):-
- H1 = [H11, Lex], member(H11, [tquot]),
- append(M, [[H11,Lex]|Rest], T),
- append(Buff, [H1|M], NewBuf),
- append(NewBuf, [[H11,Lex], [execSpace, "\s"]], NewBuff), !,
- addSpaces(Rest, NewBuff, Res).
-% })]]
-addSpaces([H1, H2|T], Buff, Res):-
- H1 = [H11|_], member(H11, [trightParen, trightBrace, trightSqParen]),
- H2 = [H21|_], member(H21, [trightParen, trightBrace, trightSqParen]),
- append(Buff, [H1], NewBuff), !,
- addSpaces([H2|T], NewBuff, Res).
-% 0], 0}, a], a}, 1), a), a][
-addSpaces([H1, H2, H3|T], Buff, Res):-
- H1 = [H11|_], member(H11, [tnumber, tidentifier]),
- H2 = [H21|_], member(H21, [trightParen, trightBrace, trightSqParen]),
- H3 = [H31|_],
- ((member(H31, [trightParen, trightBrace, trightSqParen, tleftSqParen]),
- append(Buff, [H1, H2], NewBuff));
- (\+ member(H31, [trightParen, trightBrace, trightSqParen]),
- append(Buff, [H1, H2, [execSpace, "\s"]], NewBuff))), !,
- addSpaces([H3|T], NewBuff, Res).
-% a[..
-addSpaces([H1, H2|T], Buff, Res):-
- H1 = [H11|_], member(H11, [tidentifier]),
- H2 = [H21|_], member(H21, [tleftSqParen]),
- append(Buff, [H1], NewBuff), !,
- addSpaces([H2|T], NewBuff, Res).
-% Else
-addSpaces([H|T], Buff, Res):-
- append(Buff, [H, [execSpace, "\s"]], NewBuff), !,
- addSpaces(T, NewBuff, Res).
-
-% Main predicate
-addSpaces([], []):- !.
-addSpaces([HT|TT], Res):- addSpaces(HT, [], RHT), !,
- addSpaces(TT, RTT),
- append([RHT], RTT, Res).
-
-
-% Base
-addTabs([], _, Buff, Buff, _, _):- !.
-% Openning tleftBrace
-addTabs([H|T], Tabs, Buff, Res, Bit1, Bit2):-
- H = [[H1|_]|_],
- append(Tabs, H, NewH),
- append(Buff,[NewH], NewBuff),
- H1 == tleftBrace,
- append(Tabs, [[execTAB, "\s\s\s\s"]], NewTabs), !,
- addTabs(T, NewTabs, NewBuff, Res, Bit1, Bit2).
-% Closing trightBrace and a little newline for readability
-addTabs([H|T], Tabs, Buff, Res, Bit1, Bit2):-
- H = [[H1|_]|_],
- H1 == trightBrace,
- append(NewTabs, [[execTAB, "\s\s\s\s"]], Tabs),
- append(NewTabs, H, NewH1),
- append(NewH1, [[execNL, "\n"]], NewH),
- append(Buff,[NewH], NewBuff), !,
- addTabs(T, NewTabs, NewBuff, Res, Bit1, Bit2).
-% Special case when one line only and maybe nested ifs, fors, etc
-addTabs([H|T], Tabs, Buff, Res, Bit1, Bit2):-
- H = [[H1|_]|_],
- member(H1, [tfor, twhile, tif, telse]),
- T = [[H2|_]|_],
- H2 = [H21|_],
- H21 \= tleftBrace,
- append(Tabs, H, NewH),
- append(Tabs, [[execTAB, "\s\s\s\s"]], NewTabs),
- append(Buff,[NewH], NewBuff), !,
- NewBit2 is Bit2 + 1,
- addTabs(T, NewTabs, NewBuff, Res, Bit1, NewBit2).
-% Ordinary case
-addTabs([H|T], Tabs, Buff, Res, Bit1, Bit2):-
- H = [[H1|_]|_],
- member(H1, [tfor, twhile, tif, telse, tswitch]),
- T = [[[H2|_]|_]|_],
- H2 == tleftBrace,
- append(Tabs, H, NewH),
- append(Buff,[NewH], NewBuff), !,
- addTabs(T, Tabs, NewBuff, Res, Bit1, Bit2).
-% case Bit1 helpes us to identify where if starts and ends
-addTabs([H|T], Tabs, Buff, Res, 0, Bit2):-
- H = [[H1|_]|_],
- member(H1, [tcase, tdefault]),
- append(Tabs, H, NewH),
- append(Buff,[NewH], NewBuff),
- append(Tabs, [[execTAB, "\s\s\s\s"]], NewTabs), !,
- addTabs(T, NewTabs, NewBuff, Res, 1, Bit2).
-% Ordinary case
-addTabs([H|T], Tabs, Buff, Res, 1, Bit2):-
- H = [[H1|_]|_],
- member(H1, [tbreak]),
- append(Tabs, H, NewH),
- append(Buff,[NewH], NewBuff),
- append(NewTabs, [[execTAB, "\s\s\s\s"]], Tabs), !,
- addTabs(T, NewTabs, NewBuff, Res, 0, Bit2).
-% All other tokens and Bit2 isn't 0
-addTabs([H|T], Tabs, Buff, Res, Bit1, Bit2):-
- Bit2 \= 0,
- removeNTabs(Tabs, Bit2, NewTabs),
- append(Tabs, H, NewH),
- append(Buff,[NewH], NewBuff), !,
- addTabs(T, NewTabs, NewBuff, Res, Bit1, 0).
-% All other tokens
-addTabs([H|T], Tabs, Buff, Res, Bit1, Bit2):-
- append(Tabs, H, NewH),
- append(Buff,[NewH], NewBuff), !,
- addTabs(T, Tabs, NewBuff, Res, Bit1, Bit2).
-
-% Main predicate
-addTabs(PackedLinesWithSpaces, PackedLinesWithSpacesAndTabs):-
- addTabs(PackedLinesWithSpaces, [], [], PackedLinesWithSpacesAndTabs, 0, 0), !.
diff --git a/homework/81281/c2html/print.pl b/homework/81281/c2html/print.pl
deleted file mode 100644
index d115e46..0000000
--- a/homework/81281/c2html/print.pl
+++ /dev/null
@@ -1,103 +0,0 @@
-%% Writing to html file the stream of tokens
-tohtmlfile(_, []):- !.
-
-tohtmlfile(Stream, [H|T]) :- is_identifier(H), H = [_,Lexem],
- write(Stream, '<span class=\"identifier\">'),
- write(Stream, Lexem),
- write(Stream,'</span>'),
- !,
- tohtmlfile(Stream, T).
-
-tohtmlfile(Stream, [H|T]) :- is_string(H), H = [_,Lexem],
- write(Stream, '<span class=\"string\">'),
- write(Stream, Lexem),
- write(Stream,'</span>'),
- !,
- tohtmlfile(Stream, T).
-
-tohtmlfile(Stream, [H|T]) :- is_function(H), H = [_, Lexem],
- write(Stream, '<span class=\"function\">'),
- write(Stream, Lexem),
- write(Stream,'</span>'),
- !,
- tohtmlfile(Stream, T).
-
-tohtmlfile(Stream, [H|T]) :- is_header(H), H = [_,Lexem],
- write(Stream, '<span class=\"string\">&lt;'),
- write(Stream, Lexem),
- write(Stream,'&gt;</span>'),
- !,
- tohtmlfile(Stream, T).
-
-tohtmlfile(Stream, [H|T]) :- is_keyWord(H), H = [_,Lexem],
- write(Stream, '<span class=\"keyword\">'),
- write(Stream, Lexem),
- write(Stream,'</span>'),
- !,
- tohtmlfile(Stream, T).
-
-tohtmlfile(Stream, [H|T]) :- is_number(H), H = [_,Lexem],
- write(Stream, '<span class=\"number\">'),
- write(Stream, Lexem),
- write(Stream,'</span>'),
- !,
- tohtmlfile(Stream, T).
-
-tohtmlfile(Stream, [H|T]) :- is_operator(H), H = [_,Lexem],
- write(Stream, '<span class=\"operator\">'),
- write(Stream, Lexem),
- write(Stream,'</span>'),
- !,
- tohtmlfile(Stream, T).
-
-tohtmlfile(Stream, [H|T]) :- is_parenth(H), H = [_,Lexem],
- write(Stream, '<span class=\"parenthese\">'),
- write(Stream, Lexem),
- write(Stream,'</span>'),
- !,
- tohtmlfile(Stream, T).
-
-tohtmlfile(Stream, [H|T]) :- is_quotation(H), H = [_,Lexem],
- write(Stream, '<span class=\"quotation\">'),
- write(Stream, Lexem),
- write(Stream,'</span>'),
- !,
- tohtmlfile(Stream, T).
-
-tohtmlfile(Stream, [H|T]) :- is_unknown(H), H = [_,Lexem],
- write(Stream, '<span class=\"unknown\">'),
- write(Stream, Lexem),
- write(Stream,'</span>'),
- !,
- tohtmlfile(Stream, T).
-
-tohtmlfile(Stream, [H|T]) :- is_comment(H), H = [_,Lexem],
- write(Stream, '<span class=\"comment\">'),
- write(Stream, Lexem),
- write(Stream,'</span>'),
- !,
- tohtmlfile(Stream, T).
-
-tohtmlfile(Stream, [H|T]) :- is_controlStructureBody(H),
- write(Stream, '<button class=\"collapsible\">'),
- H = [H1|T1],
- tohtmlfile(Stream, H1),
- write(Stream, '</span></button>'), nl(Stream),
- write(Stream, '<div class=\"content\">'),
- helper(Stream, T1),
- write(Stream,'</div>'),
- !,
- tohtmlfile(Stream, T).
-
-
-tohtmlfile(Stream, [H|T]) :- is_blank(H), H = [_,Lexem],
- write(Stream, Lexem),
- !,
- tohtmlfile(Stream, T).
-
-
-
-helper(_, []).
-helper(Stream, L):- append(A, [H|B], L), is_controlStructureBody(H),
- helper(Stream,A), tohtmlfile(Stream, [H]), helper(Stream,B).
-helper(Stream, [H|T]):- tohtmlfile(Stream, H), helper(Stream, T).
diff --git a/homework/81281/c2html/tokens.pl b/homework/81281/c2html/tokens.pl
deleted file mode 100644
index 1a41933..0000000
--- a/homework/81281/c2html/tokens.pl
+++ /dev/null
@@ -1,229 +0,0 @@
-%% Definitions of tokens
-token([tauto, "auto" ]) --> "auto", !.
-token([tbreak, "break" ]) --> "break", !.
-token([tcase, "case" ]) --> "case", !.
-token([tchar, "char" ]) --> "char", !.
-token([tconst, "const" ]) --> "const", !.
-token([tcontinue, "continue" ]) --> "continue", !.
-token([tdefault, "default" ]) --> "default", !.
-token([tdo, "do" ]) --> "do", !.
-token([tdouble, "double" ]) --> "double", !.
-token([telse, "else" ]) --> "else", !.
-token([tenum, "enum" ]) --> "enum", !.
-token([textern, "extern" ]) --> "extern", !.
-token([tfloat, "float" ]) --> "float", !.
-token([tfor, "for" ]) --> "for", !.
-token([tgoto, "goto" ]) --> "goto", !.
-token([tif, "if" ]) --> "if", !.
-token([tint, "int" ]) --> "int", !.
-token([tlong, "long" ]) --> "long", !.
-token([tregister, "register" ]) --> "register", !.
-token([treturn, "return" ]) --> "return", !.
-token([tshort, "short" ]) --> "short", !.
-token([tsigned, "signed" ]) --> "signed", !.
-token([tsizeof, "sizeof" ]) --> "sizeof", !.
-token([tstatic, "static" ]) --> "static", !.
-token([tstruct, "struct" ]) --> "struct", !.
-token([tswitch, "switch"]) --> "switch", !.
-token([ttypedef, "typedef" ]) --> "typedef", !.
-token([tunion, "union" ]) --> "union", !.
-token([tunsigned, "unsigned" ]) --> "unsigned", !.
-token([tvoid, "void" ]) --> "void", !.
-token([tvolatile, "volatile" ]) --> "volatile", !.
-token([twhile, "while" ]) --> "while", !.
-token([tinclude, "#include" ]) --> "#include", !.
-
-token([tcomment1, IA]) --> comment1(I), !,
- { atom_chars(IA,I)}.
-
-%% Handling windows written files with "\r\n"
-token([[tcomment2, IA], [execNL, '\n']]) --> comment2(I), !,
- {append(I1, [C1, C2], I),
- ((char_code('\r', C1), char_code('\n', C2), atom_chars(IA,I1));
- (\+ char_code('\r', C1), char_code('\n', C2),
- append(I1, [C1], I2), atom_chars(IA,I2)))}.
-
-token([tstring, IA]) --> stringy(I), !,
- {atom_chars(IA,I)}.
-token([theader, IA]) --> header(I), !,
- {append(IO, [_], I), append([_], II, IO), atom_chars(IA,II)}.
-token([[tfunction, IA], [tleftParen, "("]]) --> func(I), !,
- {append(IO, [_], I), IO \= [], atom_chars(IA, IO)}.
-token([tnumber, I]) --> number(I), !.
-
-token([tbinShiftLeftAssign, "<<="]) --> "<<=", !.
-token([tbinShiftRightAssign, ">>="]) --> ">>=", !.
-token([tpp, "++"]) --> "++", !.
-token([tmm, "--"]) --> "--", !.
-token([tptr, "->"]) --> "->", !.
-token([tgreaterEqual,">=" ]) --> ">=", !.
-token([tequal, "=="]) --> "==", !.
-token([tnotequal,"!=" ]) --> "!=", !.
-token([tlessEqual, "<="]) --> "<=", !.
-token([tplusAssign, "+="]) --> "+=", !.
-token([tminusAssign, "-="]) --> "-=", !.
-token([tmultAssign, "*="]) --> "*=", !.
-token([tdivAssign, "/="]) --> "/=", !.
-token([tlessEqual, "<="]) --> "<=", !.
-token([tlogicalAnd, "&&"]) --> "&&", !.
-token([tlogicalOr, "||"]) --> "||", !.
-token([tbinShiftLeft, "<<"]) --> "<<", !.
-token([tbinShiftRight, ">>"]) --> ">>", !.
-token([tbinAndAssign, "&="]) --> "&=", !.
-token([tbinXOrAssign, "^="]) --> "^=", !.
-token([tbinOrAssign, "|="]) --> "|=", !.
-
-token([tmultiply, "*"]) --> "*", !.
-token([tdivide, "/"]) --> "/", !.
-token([tmod, "%"]) --> "%", !.
-token([tadd, "+"]) --> "+", !.
-token([tsubtract, "-"]) --> "-", !.
-token([tless, "<"]) --> "<", !.
-token([tgreater, ">"]) --> ">", !.
-token([tnot, "!"]) --> "!", !.
-token([tassign,"="]) --> "=", !.
-token([tbitwiseAnd, "&"]) --> "&", !.
-token([tbitwiseOr, "|"]) --> "|", !.
-token([tbitwiseXOr, "^"]) --> "^", !.
-token([tbinCompliment, "~"]) --> "~", !.
-
-
-token([tspace , "\\s"]) --> "\\s", !.
-token([ttab , "\\t"]) --> "\\t", !.
-token([tnl, "\\n"]) --> "\\n", !.
-token([execSpace , "\s"]) --> "\s", !.
-token([execTAB , "\s\s\s\s"]) --> "\t", !.
-token([execNL, "\n"]) --> ( "\n"; "\r\n"), !.
-
-
-token([tleftParen,"("]) --> "(", !.
-token([trightParen, ")"]) --> ")", !.
-token([tleftBrace, "{"]) --> "{", !.
-token([trightBrace, "}"]) --> "}", !.
-token([tleftSqParen, "["]) --> "[", !.
-token([trightSqParen, "]" ]) --> "]", !.
-token([tsemicolon, ";"]) --> ";", !.
-token([ttwodots, ":"]) --> ":", !.
-token([tquestion, "?"]) --> "?", !.
-
-token([tcomma, "," ]) --> ",", !.
-token([tquot, "\'"]) --> "\'", !.
-token([tdoubleQuot, "\""]) --> "\"", !.
-token([tdot, "."]) --> ".", !.
-
-token([tidentifier, IA]) --> identifier(I), !,
- {atom_chars(IA,I)}.
-
-token([tunknown, IA]) --> allThatIsNotAToken(I), !,
- {I \= [], atom_chars(IA, I)}.
-
-
-%% Main predicate
-tokens([Token | Tail]) --> token(Token), !, tokens(Tail).
-tokens([]) --> !, [], !.
-
-
-%% Helper predicates
-identifier([C|Cs]) --> [C], {char_type(C, csymf)}, !,
- identifierHelper(Cs).
-
-identifierHelper([C|Cs]) --> [C], {char_type(C, csym)}, !,
- identifierHelper(Cs).
-identifierHelper([C]) --> [C], {char_type(C, csym), \+ char_code('_', C)}, !.
-identifierHelper([]) --> [], !.
-
-func([C|Cs]) --> [C], {char_type(C, csymf)}, !,
- funkHelper(Cs).
-
-funkHelper([C|Cs]) --> [C], {char_type(C, csym)}, !,
- funkHelper(Cs).
-funkHelper([C]) --> [C], {char_code("(", C)}, !.
-
-stringy([C|Cs]) --> [C], {char_code('\"', C)}, !,
- stringyHelper(Cs).
-
-stringyHelper([C]) --> [C], { char_code('\n', C), fail}, !.
-stringyHelper([C1, C2]) --> [C1, C2], { char_code('\\', C1), char_code('\s', C2), fail}, !.
-stringyHelper([C1, C2|Cs]) --> [C1, C2], { char_code('\\', C1), char_code('\"', C2)}, !,
- stringyHelper(Cs).
-stringyHelper([C]) --> [C], { char_code('\"', C)}.
-stringyHelper([C|Cs]) --> [C], stringyHelper(Cs).
-
-header([C|Cs]) --> [C], {char_code('<', C)}, !,
- headerHelper(Cs).
-
-headerHelper([C|Cs]) --> [C],
- {char_type(C, csymf); char_code('.', C); char_code('/', C); char_code('+', C)},
- headerHelper(Cs).
-headerHelper([C]) --> [C], {char_code('>', C)}.
-
-
-comment1([C1,C2|Cs]) --> [C1,C2], {char_code('/', C1), char_code('*', C2)}, !,
- anythingButStarSlash(Cs).
-
-comment2([C1,C2|Cs]) --> [C1,C2], {char_code('/', C1), char_code('/', C2)}, !,
- anythingButNL(Cs).
-
-anything([C|Cs]) --> [C], anything(Cs).
-anything([]) --> [].
-
-allThatIsNotAToken([C|Cs]) --> [C|Cs], \+ tokens(C), \+ tokens([C|Cs]),
- allThatIsNotAToken(Cs).
-allThatIsNotAToken([]) --> [].
-
-anythingButNL([C|Cs]) --> [C],
- {\+ char_code('\r', C), \+ char_code('\n', C)},
- anythingButNL(Cs).
-anythingButNL([C1,C2]) --> [C1,C2],
- {(char_code('\r', C1), char_code('\n', C2));
- (\+ char_code('\r', C1), char_code('\n', C2))}.
-
-anythingButStarSlash([C1,C2]) --> [C1, C2],
- {char_code('*', C1), char_code('/', C2)}.
-anythingButStarSlash([C|Cs]) --> [C],
- anythingButStarSlash(Cs).
-
-
-
-%% Definitions of lists of different types of tokens
-is_keyWord([H,_]):- member(H, [tauto, tbreak, tcase, tchar, tconst, tcontinue,
- tdefault, tdo, tdouble, telse, tenum, textern, tfloat, tfor, tgoto, tif,
- tint, tlong, tregister, treturn, tshort, tsigned, tstatic, tstruct,
- tswitch, ttypedef, tunion, tunsigned, twhile, tvoid, tvolatile, tinclude]).
-
-is_operator([H,_]):- member(H, [tmultiply, tdivide, tmod, tadd, tsubtract, tless,
- tlessEqual, tgreater, tgreaterEqual, tequal, tnotequal, tnot, tassign, tlogicalOr,
- tlogicalAnd, tbitwiseOr, tbitwiseAnd, tpp, tmm, tptr, tsizeof, tbinShiftLeftAssign,
- tbinShiftRightAssign, tplusAssign, tminusAssign, tmultAssign, tdivAssign, tbinShiftLeft,
- tbinShiftRight, tbinAndAssign, tbinXOrAssign, tbinOrAssign, tbitwiseXOr, tbinCompliment]).
-
-is_parenth([H,_]):- member(H, [tleftParen, trightParen, tleftBrace, trightBrace,
- tleftSqParen, trightSqParen, tsemicolon, ttwodots]).
-
-is_quotation([H,_]):- member(H, [tquot, tdoubleQuot, tcomma, tdot, tquestion]).
-
-is_unknown([H,_]):- member(H, [tunknown]).
-
-is_number([H,_]):- member(H, [tnumber]).
-
-is_function([H,_]):- member(H, [tfunction]).
-
-is_controlStructureBody([H|_]):-
- member(Token, [tdo, tfor, twhile, tif, telse, tswitch, tfunction, tstruct]),
- append(_, [[Token|_]|_], H).
-
-is_packedFunction([H|_]):- append(_, [[tfunction|_]|_], H).
-
-is_packedStructure([H|_]):- append(_, [[tstruct|_]|_], H).
-
-% experimental is_functionWithCC([H|_]):- H = [[tCC]|_].
-
-is_identifier([H,_]):- member(H, [tidentifier, tnl, ttab, tspace]).
-
-is_blank([H,_]):- member(H, [execTAB, execSpace, execNL]).
-
-is_comment([H,_]):-member(H, [tcomment1, tcomment2]).
-
-is_string([H,_]):- member(H, [tstring]).
-
-is_header([H,_]):- member(H, [theader]).
diff --git a/homework/81319/bfinterpreter/Makefile b/homework/81319/bfinterpreter/Makefile
deleted file mode 100644
index 00d7439..0000000
--- a/homework/81319/bfinterpreter/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-CURRENT_DIR = $(shell pwd)
-GOPATH=$(CURRENT_DIR)/.tmp/
-
-interpreter: tmp
- $(cd .tmp/src/bfinterpreter)
- @echo $(CURRENT_DIR)
- go build
-
-tmp:
- $(shell ./make_temp_folders.sh)
-
-clean:
- rm -rf .tmp
- rm -rf bfinterpreter
-
diff --git a/homework/81319/bfinterpreter/README.md b/homework/81319/bfinterpreter/README.md
deleted file mode 100644
index 7f65de0..0000000
--- a/homework/81319/bfinterpreter/README.md
+++ /dev/null
@@ -1,19 +0,0 @@
-# Brainfuck Interpreter in Golang
-
-### Steps
-#### 1. Install Go compiler
-#### 2. Run:
-```
-make
-```
-#### 3. Run:
-```
-./bfinterpreter
-```
-#### 4. Enjoy!
-
-
-
-#### Make sure to read the language specification of Brainfuck.
-
-#### You can find it [here](https://en.wikipedia.org/wiki/Brainfuck#Commands). \ No newline at end of file
diff --git a/homework/81319/bfinterpreter/bf/cell.go b/homework/81319/bfinterpreter/bf/cell.go
deleted file mode 100644
index 9767bbb..0000000
--- a/homework/81319/bfinterpreter/bf/cell.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package bf
-
-type cell struct {
- value byte
-}
-
-func (c *cell) increment() {
- c.value = byte(int(c.value) + 1)
-}
-
-func (c *cell) decrement() {
- c.value = byte(int(c.value) - 1)
-}
-
-func (c *cell) getValue() byte {
- return c.value
-}
-
-func (c *cell) setValue(value byte) {
- c.value = value
-}
diff --git a/homework/81319/bfinterpreter/bf/interpreter.go b/homework/81319/bfinterpreter/bf/interpreter.go
deleted file mode 100644
index 87c9870..0000000
--- a/homework/81319/bfinterpreter/bf/interpreter.go
+++ /dev/null
@@ -1,189 +0,0 @@
-package bf
-
-import (
- "bufio"
- "errors"
- "fmt"
- "io"
- "os"
- "strconv"
-)
-
-type instruction struct {
- idx uint
- instructionType token
-
- matchingBracketIdx uint
-}
-
-type state struct {
- mem memoryState
- src []instruction
- instructionPtr uint
-
- buffer []byte
- reader io.Reader
- writer io.Writer
-}
-
-func (s *state) moveRight() {
- s.mem.incrementPtr()
-}
-
-func (s *state) moveLeft() {
- s.mem.decrementPtr()
-}
-
-func (s *state) incrementValue() {
- s.mem.incrementCell()
-}
-
-func (s *state) decrementValue() {
- s.mem.decerementCell()
-}
-
-func (s *state) readCellValue() error {
- count, err := s.reader.Read(s.buffer)
- if err == io.EOF {
- return nil
- }
-
- if err != nil {
- return errors.New("couldn't read from input")
- }
-
- if count < 1 {
- return errors.New("couldn't read from input")
- }
-
- s.mem.setCell(s.buffer[0])
-
- return nil
-}
-
-func (s *state) writeCellValue() error {
- count, err := s.writer.Write([]byte{s.mem.getCell()})
-
- if err != nil {
- return errors.New("couldn't write to output")
- }
-
- if count != 1 {
- return errors.New("couldn't write to output")
- }
-
- return nil
-}
-
-func (s *state) interpretInstruction() {
- instr := s.src[s.instructionPtr]
-
- switch instr.instructionType {
- case movR:
- s.moveRight()
- case movL:
- s.moveLeft()
- case incD:
- s.incrementValue()
- case decD:
- s.decrementValue()
- case outD:
- s.writeCellValue()
- case inD:
- s.readCellValue()
- case loopS:
- if s.mem.getCell() == 0 {
- s.instructionPtr = instr.matchingBracketIdx
- }
- case loopE:
- if s.mem.getCell() != 0 {
- s.instructionPtr = instr.matchingBracketIdx
- }
- }
- s.instructionPtr += 1
-}
-
-func (s *state) addInstructions(src string) {
- instructions := parseInput(tokenizeInput(src))
-
- s.src = append(s.src, instructions...)
-}
-
-type flushingWriter struct {
- w *bufio.Writer
-}
-
-func newFlushingWriter() io.Writer {
- writer := &flushingWriter{
- w: bufio.NewWriter(os.Stdout),
- }
-
- return writer
-}
-
-func (w *flushingWriter) Write(p []byte) (int, error) {
- fmt.Print("#=> ")
- count, err := w.w.Write(p)
- if err != nil {
- return 0, err
- }
- w.w.Flush()
-
- fmt.Println()
-
- return count, nil
-}
-
-type lineReader struct {
- r *bufio.Reader
-}
-
-func newLineReader() io.Reader {
- reader := &lineReader{
- r: bufio.NewReader(os.Stdin),
- }
-
- return reader
-}
-
-func (r *lineReader) Read(buffer []byte) (int, error) {
- stringVal, err := r.r.ReadString('\n')
-
- if err != nil {
- return 0, err
- }
-
- result, err := strconv.ParseInt(stringVal[:len(stringVal)-1], 10, 8)
-
- if err != nil {
- return 0, err
- }
-
- buffer[0] = byte(result)
-
- return 1, nil
-}
-
-func NewInterpreter(src string) state {
- instructions := parseInput(tokenizeInput(src))
-
- state := state{
- instructionPtr: 0,
- src: instructions,
- buffer: make([]byte, 1),
- writer: newFlushingWriter(),
- reader: newLineReader(),
- }
-
- return state
-}
-
-func (s *state) Run() {
- for {
- if int(s.instructionPtr) == len(s.src) {
- return
- }
-
- s.interpretInstruction()
- }
-}
diff --git a/homework/81319/bfinterpreter/bf/interpreter_test.go b/homework/81319/bfinterpreter/bf/interpreter_test.go
deleted file mode 100644
index a798669..0000000
--- a/homework/81319/bfinterpreter/bf/interpreter_test.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package bf
-
-import (
- "bufio"
- "io"
- "os"
- "testing"
-)
-
-func TestInterpretInstruction(t *testing.T) {
- var writer io.Writer
-
- writer = flushingWriter{
- w: bufio.NewWriter(os.Stdout),
- }
-
- src := []instruction{
- {
- idx: 0,
- instructionType: incD,
- },
- }
-
- for i := 0; i < 65; i++ {
- src = append(src, instruction{
- idx: uint(i),
- instructionType: incD,
- })
- }
-
- src = append(src, instruction{
- idx: 65,
- instructionType: outD,
- })
-
- intepreterState := state{
- src: src,
- buffer: make([]byte, 1),
- writer: writer,
- }
-
- writer.Write([]byte("hello\n"))
-
- for i := 0; i < 66; i++ {
- intepreterState.interpretInstruction()
- }
-
- intepreterState.interpretInstruction()
-
-}
-
-func TestInterpreter(t *testing.T) {
- input := ","
- interpreter := NewInterpreter(input)
-
- Run(interpreter)
-
-}
diff --git a/homework/81319/bfinterpreter/bf/mem.go b/homework/81319/bfinterpreter/bf/mem.go
deleted file mode 100644
index 8679584..0000000
--- a/homework/81319/bfinterpreter/bf/mem.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package bf
-
-const (
- MEMORY_SIZE uint = 1024
-)
-
-type memoryState struct {
- memory [MEMORY_SIZE]cell
- currentCellIdx uint
-}
-
-func (m *memoryState) incrementPtr() {
- if m.currentCellIdx == MEMORY_SIZE {
- return
- }
- m.currentCellIdx += 1
-}
-
-func (m *memoryState) decrementPtr() {
- if m.currentCellIdx == 0 {
- return
- }
- m.currentCellIdx -= 1
-}
-
-func (m *memoryState) incrementCell() {
- m.memory[m.currentCellIdx].increment()
-}
-
-func (m *memoryState) decerementCell() {
- m.memory[m.currentCellIdx].decrement()
-}
-
-func (m *memoryState) setCell(value byte) {
- m.memory[m.currentCellIdx].setValue(value)
-}
-
-func (m *memoryState) getCell() byte {
- return m.memory[m.currentCellIdx].getValue()
-}
diff --git a/homework/81319/bfinterpreter/bf/repl.go b/homework/81319/bfinterpreter/bf/repl.go
deleted file mode 100644
index e09bcea..0000000
--- a/homework/81319/bfinterpreter/bf/repl.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package bf
-
-import (
- "bufio"
- "fmt"
- "os"
-)
-
-type repl struct {
- interpreter *state
- reader *bufio.Reader
- writer *bufio.Writer
-}
-
-func NewRepl() repl {
- intepreter := NewInterpreter("")
- return repl{
- interpreter: &intepreter,
- reader: bufio.NewReader(os.Stdin),
- writer: bufio.NewWriter(os.Stdout),
- }
-}
-
-func (r *repl) read() {
- fmt.Print(">>")
- instructions, err := r.reader.ReadString('\n')
- instructions = instructions[:len(instructions)-1]
- if err != nil {
- panic("not implemented")
- }
-
- r.interpreter.addInstructions(instructions)
-}
-
-func (r *repl) eval() {
- r.interpreter.Run()
-}
-
-func (r *repl) Start() {
- for {
- r.read()
- r.eval()
- }
-}
diff --git a/homework/81319/bfinterpreter/bf/tokenizer.go b/homework/81319/bfinterpreter/bf/tokenizer.go
deleted file mode 100644
index 10a0342..0000000
--- a/homework/81319/bfinterpreter/bf/tokenizer.go
+++ /dev/null
@@ -1,124 +0,0 @@
-package bf
-
-import (
- "bytes"
- "io"
-)
-
-type token int
-
-const (
- unkwn token = iota
- movR
- movL
- incD
- decD
- outD
- inD
- loopS
- loopE
-)
-
-func tokenize(symbol string) token {
- switch symbol {
- case ">":
- return movR
- case "<":
- return movL
- case ".":
- return outD
- case ",":
- return inD
- case "+":
- return incD
- case "-":
- return decD
- case "[":
- return loopS
- case "]":
- return loopE
- }
-
- return 0
-}
-
-type tokenizingStream struct {
- reader io.Reader
-}
-
-func (s *tokenizingStream) Read(p []byte) (int, error) {
- buffer := make([]byte, len(p))
-
- count, err := s.reader.Read(buffer)
- if err != nil {
- return 0, err
- }
-
- for i := 0; i < count; i++ {
- p[i] = byte(tokenize(string(buffer[i])))
- }
-
- return count, nil
-}
-
-func tokenizeInput(input string) []instruction {
- byteBuff := []byte(input)
- reader := bytes.NewReader(byteBuff)
- tokenizingReader := tokenizingStream{
- reader: reader,
- }
-
- bytesRead := make([]byte, 1)
- instructions := make([]instruction, 0)
-
- for {
- _, ok := tokenizingReader.Read(bytesRead)
- if ok == io.EOF {
- break
- }
- if ok == nil {
- inst := instruction{
- instructionType: token(bytesRead[0]),
- }
-
- instructions = append(instructions, inst)
- }
- }
-
- return instructions
-}
-
-func parseInput(instructions []instruction) []instruction {
- stack := make([]instruction, 0)
-
- for idx, inst := range instructions {
- instructions[idx].idx = uint(idx)
-
- if inst.instructionType != loopS && inst.instructionType != loopE {
- continue
- }
-
- if inst.instructionType == loopS {
- inst.idx = uint(idx)
- stack = append(stack, inst)
-
- continue
- }
-
- if len(stack) < 1 {
- panic("input data invalid!")
- }
-
- prevInst := stack[len(stack)-1]
- prevInst.matchingBracketIdx = uint(idx)
- instructions[prevInst.idx] = prevInst
-
- inst.idx = uint(idx)
- inst.matchingBracketIdx = prevInst.idx
- instructions[idx] = inst
-
- stack = stack[:len(stack)-1]
- }
-
- return instructions
-}
diff --git a/homework/81319/bfinterpreter/main.go b/homework/81319/bfinterpreter/main.go
deleted file mode 100644
index 2e76424..0000000
--- a/homework/81319/bfinterpreter/main.go
+++ /dev/null
@@ -1,8 +0,0 @@
-package main
-
-import "github.com/geosteffanov/bfinterpreter/bf"
-
-func main() {
- repl := bf.NewRepl()
- repl.Start()
-}
diff --git a/homework/81319/bfinterpreter/make_temp_folders.sh b/homework/81319/bfinterpreter/make_temp_folders.sh
deleted file mode 100755
index dc6ac77..0000000
--- a/homework/81319/bfinterpreter/make_temp_folders.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-
-mkdir -p .tmp/src/github.com/geosteffanov/bfinterpreter
-cp -rf bf .tmp/src/github.com/geosteffanov/bfinterpreter
-cp main.go .tmp/src/github.com/geosteffanov/bfinterpreter \ No newline at end of file
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
diff --git a/homework/81319/golang2html_code_fold/Makefile b/homework/81319/golang2html_code_fold/Makefile
deleted file mode 100644
index 7367df5..0000000
--- a/homework/81319/golang2html_code_fold/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-all: parser
-
-lexer_code.c: lexer.lex
- flex -o lexer_code.c lexer.lex
-
-lexer: lexer_code.c
- gcc lexer_code.c -o lexer
-
-parser.tab.c: parser.y
- bison -d -v parser.y
-
-parser.tab.h: parser.tab.c
-
-parser: parser.tab.c parser.tab.h lexer_code.c
- ${CC} ${CFLAGS} lexer_code.c parser.tab.c -o parser
diff --git a/homework/81319/golang2html_code_fold/README.md b/homework/81319/golang2html_code_fold/README.md
deleted file mode 100644
index e8c8334..0000000
--- a/homework/81319/golang2html_code_fold/README.md
+++ /dev/null
@@ -1,18 +0,0 @@
-# How-to guide
-
-1. Place your code in the input.go file.
-2. Run make:
-
-```
-make
-```
-
-3. Run stylizer
-
-```
-./stylize.sh
-```
-
-
-This will add syntax highlighting to your code and will add collapsable
-blocks. \ No newline at end of file
diff --git a/homework/81319/golang2html_code_fold/input.go b/homework/81319/golang2html_code_fold/input.go
deleted file mode 100644
index 0a31497..0000000
--- a/homework/81319/golang2html_code_fold/input.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
diff --git a/homework/81319/golang2html_code_fold/lexer.lex b/homework/81319/golang2html_code_fold/lexer.lex
deleted file mode 100644
index 33f27c9..0000000
--- a/homework/81319/golang2html_code_fold/lexer.lex
+++ /dev/null
@@ -1,100 +0,0 @@
-
-%{
-#include "parser.tab.h"
-#include <stdlib.h>
-int current_line = 0;
-#define YY_NO_UNISTD_H
-%}
-
-
-digit [0-9]
-id [a-zA-Z_][a-zA-Z0-9_]*
-strq '([^\']|(\\\'))*'
-strdq \"([^\"]|(\\\"))*\"
-number [1-9]{number}*
-fnumber {digit}+"."{digit}*
-
-
-%%
-
-
-{digit}+|{digit}+"."{digit}* {
- yylval.strval = yytext;
- return NUMBER;
-}
-
-break|default|func|interface|select|case|defer|go|map|struct {
- yylval.strval = yytext;
- return KEYWORD;
-}
-
-chan|else|goto|package|switch|const|fallthrough|if|range|type|continue|for|import|return|var {
- yylval.strval = yytext;
- return KEYWORD;
-}
-
-{id} {
- yylval.strval = yytext;
- return IDENTIFIER;
-}
-
-{strq} {
- yylval.strval = yytext;
- return STRING;
-}
-
-{strdq} {
- yylval.strval = yytext;
- return STRING_DQ;
-}
-
-
-"+"|"&"|"+="|"&="|"&&"|"=="|"!="|"-"|"|"|"-="|"|="|"||"|"<" {
- yylval.strval = yytext;
- return OPERATOR;
-}
-
-"<="|"["|"]"|"*"|"^"|"*="|"^="|"<-"|">"|">="|"/"|"<<"|"/=" {
- yylval.strval = yytext;
- return OPERATOR;
-}
-
-"<<="|"++"|"="|":="|","|";"|"%"|">>"|"%="|">>="|"--"|"!"|"..."|"."|":"|"&^"|"&^=" {
- yylval.strval = yytext;
- return OPERATOR;
-}
-
-[;()? \t]+ {
- yylval.strval = yytext;
- return MISC;
-}
-
-"{" {
- yylval.strval = yytext;
- return LCURLY;
-}
-
-"}" {
- yylval.strval = yytext;
- return RCURLY;
-}
-
-\n {
- ++current_line;
- yylval.strval = yytext;
- return MISC;
-}
-
-. {
- yylval.strval = yytext;
- return UNRECOGNIZED;
-}
-
-
-%%
-
-int yywrap()
-{
- return 1;
-}
-
diff --git a/homework/81319/golang2html_code_fold/lexer_code.c b/homework/81319/golang2html_code_fold/lexer_code.c
deleted file mode 100644
index 39b11c5..0000000
--- a/homework/81319/golang2html_code_fold/lexer_code.c
+++ /dev/null
@@ -1,1953 +0,0 @@
-#line 2 "lexer_code.c"
-
-#line 4 "lexer_code.c"
-
-#define YY_INT_ALIGNED short int
-
-/* A lexical scanner generated by flex */
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 35
-#if YY_FLEX_SUBMINOR_VERSION > 0
-#define FLEX_BETA
-#endif
-
-/* First, we deal with platform-specific or compiler-specific issues. */
-
-/* begin standard C headers. */
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/* end standard C headers. */
-
-/* flex integer type definitions */
-
-#ifndef FLEXINT_H
-#define FLEXINT_H
-
-/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-
-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-
-/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
- * if you want the limit (max/min) macros for int types.
- */
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS 1
-#endif
-
-#include <inttypes.h>
-typedef int8_t flex_int8_t;
-typedef uint8_t flex_uint8_t;
-typedef int16_t flex_int16_t;
-typedef uint16_t flex_uint16_t;
-typedef int32_t flex_int32_t;
-typedef uint32_t flex_uint32_t;
-typedef uint64_t flex_uint64_t;
-#else
-typedef signed char flex_int8_t;
-typedef short int flex_int16_t;
-typedef int flex_int32_t;
-typedef unsigned char flex_uint8_t;
-typedef unsigned short int flex_uint16_t;
-typedef unsigned int flex_uint32_t;
-#endif /* ! C99 */
-
-/* Limits of integral types. */
-#ifndef INT8_MIN
-#define INT8_MIN (-128)
-#endif
-#ifndef INT16_MIN
-#define INT16_MIN (-32767-1)
-#endif
-#ifndef INT32_MIN
-#define INT32_MIN (-2147483647-1)
-#endif
-#ifndef INT8_MAX
-#define INT8_MAX (127)
-#endif
-#ifndef INT16_MAX
-#define INT16_MAX (32767)
-#endif
-#ifndef INT32_MAX
-#define INT32_MAX (2147483647)
-#endif
-#ifndef UINT8_MAX
-#define UINT8_MAX (255U)
-#endif
-#ifndef UINT16_MAX
-#define UINT16_MAX (65535U)
-#endif
-#ifndef UINT32_MAX
-#define UINT32_MAX (4294967295U)
-#endif
-
-#endif /* ! FLEXINT_H */
-
-#ifdef __cplusplus
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-/* C99 requires __STDC__ to be defined as 1. */
-#if defined (__STDC__)
-
-#define YY_USE_CONST
-
-#endif /* defined (__STDC__) */
-#endif /* ! __cplusplus */
-
-#ifdef YY_USE_CONST
-#define yyconst const
-#else
-#define yyconst
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN (yy_start) = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state. The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START (((yy_start) - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart(yyin )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#ifndef YY_BUF_SIZE
-#define YY_BUF_SIZE 16384
-#endif
-
-/* The state buf must be large enough to hold one state per character in the main buffer.
- */
-#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
-
-#ifndef YY_TYPEDEF_YY_BUFFER_STATE
-#define YY_TYPEDEF_YY_BUFFER_STATE
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-#endif
-
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef size_t yy_size_t;
-#endif
-
-extern yy_size_t yyleng;
-
-extern FILE *yyin, *yyout;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
- #define YY_LESS_LINENO(n)
-
-/* Return all but the first "n" matched characters back to the input stream. */
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- *yy_cp = (yy_hold_char); \
- YY_RESTORE_YY_MORE_OFFSET \
- (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up yytext again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, (yytext_ptr) )
-
-#ifndef YY_STRUCT_YY_BUFFER_STATE
-#define YY_STRUCT_YY_BUFFER_STATE
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- yy_size_t yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- yy_size_t yy_n_chars;
-
- /* Whether we "own" the buffer - i.e., we know we created it,
- * and can realloc() it to grow it, and should free() it to
- * delete it.
- */
- int yy_is_our_buffer;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether we're considered to be at the beginning of a line.
- * If so, '^' rules will be active on the next match, otherwise
- * not.
- */
- int yy_at_bol;
-
- int yy_bs_lineno; /**< The line count. */
- int yy_bs_column; /**< The column count. */
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via yyrestart()), so that the user can continue scanning by
- * just pointing yyin at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
-
- };
-#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-
-/* Stack of input buffers. */
-static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
-static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
-static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- *
- * Returns the top of the stack, or NULL.
- */
-#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
- ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
- : NULL)
-
-/* Same as previous macro, but useful when we know that the buffer stack is not
- * NULL or when we need an lvalue. For internal use only.
- */
-#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
-
-/* yy_hold_char holds the character lost when yytext is formed. */
-static char yy_hold_char;
-static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
-yy_size_t yyleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 0; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow yywrap()'s to do buffer switches
- * instead of setting up a fresh yyin. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void yyrestart (FILE *input_file );
-void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
-YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
-void yy_delete_buffer (YY_BUFFER_STATE b );
-void yy_flush_buffer (YY_BUFFER_STATE b );
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
-void yypop_buffer_state (void );
-
-static void yyensure_buffer_stack (void );
-static void yy_load_buffer_state (void );
-static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
-
-#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
-
-YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
-YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );
-
-void *yyalloc (yy_size_t );
-void *yyrealloc (void *,yy_size_t );
-void yyfree (void * );
-
-#define yy_new_buffer yy_create_buffer
-
-#define yy_set_interactive(is_interactive) \
- { \
- if ( ! YY_CURRENT_BUFFER ){ \
- yyensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- yy_create_buffer(yyin,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
- }
-
-#define yy_set_bol(at_bol) \
- { \
- if ( ! YY_CURRENT_BUFFER ){\
- yyensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- yy_create_buffer(yyin,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
- }
-
-#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
-
-/* Begin user sect3 */
-
-typedef unsigned char YY_CHAR;
-
-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
-
-typedef int yy_state_type;
-
-extern int yylineno;
-
-int yylineno = 1;
-
-extern char *yytext;
-#define yytext_ptr yytext
-
-static yy_state_type yy_get_previous_state (void );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
-static int yy_get_next_buffer (void );
-static void yy_fatal_error (yyconst char msg[] );
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up yytext.
- */
-#define YY_DO_BEFORE_ACTION \
- (yytext_ptr) = yy_bp; \
- yyleng = (yy_size_t) (yy_cp - yy_bp); \
- (yy_hold_char) = *yy_cp; \
- *yy_cp = '\0'; \
- (yy_c_buf_p) = yy_cp;
-
-#define YY_NUM_RULES 15
-#define YY_END_OF_BUFFER 16
-/* This struct is not used in this scanner,
- but its presence is necessary. */
-struct yy_trans_info
- {
- flex_int32_t yy_verify;
- flex_int32_t yy_nxt;
- };
-static yyconst flex_int16_t yy_accept[141] =
- { 0,
- 0, 0, 16, 14, 10, 13, 9, 14, 9, 7,
- 14, 8, 7, 9, 7, 9, 8, 1, 9, 9,
- 7, 9, 8, 4, 8, 8, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 11,
- 7, 12, 10, 7, 0, 6, 0, 9, 9, 0,
- 5, 0, 8, 0, 1, 1, 8, 9, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 2, 3,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 6, 5, 1, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 2, 4, 4, 4, 4,
-
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 0
- } ;
-
-static yyconst flex_int32_t yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 4, 5, 1, 1, 6, 7, 8, 2,
- 2, 9, 10, 11, 12, 13, 14, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 16, 17, 18,
- 19, 20, 2, 1, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 22, 23, 24, 25, 21, 1, 26, 27, 28, 29,
-
- 30, 31, 32, 33, 34, 21, 35, 36, 37, 38,
- 39, 40, 21, 41, 42, 43, 44, 45, 46, 21,
- 47, 21, 48, 49, 50, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-static yyconst flex_int32_t yy_meta[51] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 2, 1, 1, 1, 1, 1,
- 2, 1, 1, 1, 1, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 1, 1, 1
- } ;
-
-static yyconst flex_int16_t yy_base[144] =
- { 0,
- 0, 0, 209, 210, 49, 210, 189, 47, 188, 46,
- 46, 187, 45, 210, 44, 192, 185, 44, 184, 56,
- 49, 183, 55, 0, 210, 182, 159, 46, 169, 162,
- 50, 158, 46, 170, 169, 52, 50, 147, 167, 210,
- 41, 210, 84, 210, 76, 210, 82, 210, 173, 80,
- 210, 83, 210, 178, 175, 82, 170, 169, 0, 157,
- 144, 159, 146, 152, 140, 145, 139, 141, 135, 0,
- 137, 133, 135, 146, 135, 129, 135, 129, 135, 128,
- 126, 87, 90, 151, 139, 134, 125, 65, 74, 132,
- 125, 132, 120, 119, 127, 0, 121, 123, 110, 123,
-
- 108, 108, 120, 114, 105, 113, 102, 104, 101, 102,
- 101, 115, 110, 98, 110, 109, 108, 97, 98, 100,
- 89, 100, 98, 91, 85, 84, 93, 81, 81, 82,
- 96, 91, 90, 80, 90, 68, 81, 77, 69, 210,
- 113, 115, 60
- } ;
-
-static yyconst flex_int16_t yy_def[144] =
- { 0,
- 140, 1, 140, 140, 140, 140, 140, 141, 140, 140,
- 142, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 143, 140, 140, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 140,
- 140, 140, 140, 140, 141, 140, 141, 140, 140, 142,
- 140, 142, 140, 140, 140, 140, 140, 140, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 141, 142, 140, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
-
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 0,
- 140, 140, 140
- } ;
-
-static yyconst flex_int16_t yy_nxt[261] =
- { 0,
- 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
- 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 4, 25, 26, 24, 27, 28, 29, 30,
- 31, 32, 24, 33, 24, 24, 34, 24, 24, 35,
- 36, 37, 38, 24, 39, 24, 24, 40, 41, 42,
- 43, 46, 44, 51, 48, 48, 55, 43, 56, 44,
- 53, 59, 44, 44, 44, 43, 57, 53, 52, 47,
- 49, 61, 43, 53, 58, 66, 70, 75, 62, 77,
- 46, 76, 71, 72, 63, 43, 82, 51, 67, 44,
- 83, 46, 78, 68, 55, 79, 56, 51, 47, 107,
-
- 43, 70, 52, 108, 47, 52, 105, 106, 139, 47,
- 96, 138, 52, 45, 45, 50, 50, 137, 136, 70,
- 70, 135, 134, 96, 133, 70, 96, 96, 70, 132,
- 131, 70, 130, 129, 128, 127, 126, 125, 124, 70,
- 123, 122, 121, 120, 96, 119, 118, 70, 96, 70,
- 117, 116, 115, 114, 113, 112, 111, 110, 70, 96,
- 109, 70, 70, 96, 104, 84, 70, 103, 102, 101,
- 100, 99, 98, 97, 96, 95, 94, 93, 92, 70,
- 91, 90, 89, 88, 87, 86, 85, 48, 48, 84,
- 48, 48, 81, 80, 74, 73, 69, 65, 64, 60,
-
- 53, 44, 48, 53, 54, 53, 48, 44, 140, 3,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140
- } ;
-
-static yyconst flex_int16_t yy_chk[261] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 5, 8, 10, 11, 13, 15, 18, 20, 18, 41,
- 21, 143, 15, 13, 10, 5, 21, 21, 11, 8,
- 10, 28, 20, 23, 23, 31, 33, 36, 28, 37,
- 45, 36, 33, 33, 28, 43, 47, 50, 31, 41,
- 52, 82, 37, 31, 56, 37, 56, 83, 45, 89,
-
- 43, 139, 50, 89, 47, 52, 88, 88, 138, 82,
- 137, 136, 83, 141, 141, 142, 142, 135, 134, 133,
- 132, 131, 130, 129, 128, 127, 126, 125, 124, 123,
- 122, 121, 120, 119, 118, 117, 116, 115, 114, 113,
- 112, 111, 110, 109, 108, 107, 106, 105, 104, 103,
- 102, 101, 100, 99, 98, 97, 95, 94, 93, 92,
- 91, 90, 87, 86, 85, 84, 81, 80, 79, 78,
- 77, 76, 75, 74, 73, 72, 71, 69, 68, 67,
- 66, 65, 64, 63, 62, 61, 60, 58, 57, 55,
- 54, 49, 39, 38, 35, 34, 32, 30, 29, 27,
-
- 26, 22, 19, 17, 16, 12, 9, 7, 3, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140
- } ;
-
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-extern int yy_flex_debug;
-int yy_flex_debug = 0;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-char *yytext;
-#line 1 "lexer.lex"
-#line 3 "lexer.lex"
-#include "parser.tab.h"
-#include <stdlib.h>
-int current_line = 0;
-#define YY_NO_UNISTD_H
-#line 558 "lexer_code.c"
-
-#define INITIAL 0
-
-#ifndef YY_NO_UNISTD_H
-/* Special case for "unistd.h", since it is non-ANSI. We include it way
- * down here because we want the user's section 1 to have been scanned first.
- * The user has a chance to override it with an option.
- */
-#include <unistd.h>
-#endif
-
-#ifndef YY_EXTRA_TYPE
-#define YY_EXTRA_TYPE void *
-#endif
-
-static int yy_init_globals (void );
-
-/* Accessor methods to globals.
- These are made visible to non-reentrant scanners for convenience. */
-
-int yylex_destroy (void );
-
-int yyget_debug (void );
-
-void yyset_debug (int debug_flag );
-
-YY_EXTRA_TYPE yyget_extra (void );
-
-void yyset_extra (YY_EXTRA_TYPE user_defined );
-
-FILE *yyget_in (void );
-
-void yyset_in (FILE * in_str );
-
-FILE *yyget_out (void );
-
-void yyset_out (FILE * out_str );
-
-yy_size_t yyget_leng (void );
-
-char *yyget_text (void );
-
-int yyget_lineno (void );
-
-void yyset_lineno (int line_number );
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int yywrap (void );
-#else
-extern int yywrap (void );
-#endif
-#endif
-
- static void yyunput (int c,char *buf_ptr );
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int );
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * );
-#endif
-
-#ifndef YY_NO_INPUT
-
-#ifdef __cplusplus
-static int yyinput (void );
-#else
-static int input (void );
-#endif
-
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 8192
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO fwrite( yytext, yyleng, 1, yyout )
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
- { \
- int c = '*'; \
- yy_size_t n; \
- for ( n = 0; n < max_size && \
- (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
- buf[n] = (char) c; \
- if ( c == '\n' ) \
- buf[n++] = (char) c; \
- if ( c == EOF && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- result = n; \
- } \
- else \
- { \
- errno=0; \
- while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
- { \
- if( errno != EINTR) \
- { \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- break; \
- } \
- errno=0; \
- clearerr(yyin); \
- } \
- }\
-\
-
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* end tables serialization structures and prototypes */
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL_IS_OURS 1
-
-extern int yylex (void);
-
-#define YY_DECL int yylex (void)
-#endif /* !YY_DECL */
-
-/* Code executed at the beginning of each rule, after yytext and yyleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK break;
-#endif
-
-#define YY_RULE_SETUP \
- YY_USER_ACTION
-
-/** The main scanner function which does all the work.
- */
-YY_DECL
-{
- register yy_state_type yy_current_state;
- register char *yy_cp, *yy_bp;
- register int yy_act;
-
-#line 18 "lexer.lex"
-
-
-
-#line 744 "lexer_code.c"
-
- if ( !(yy_init) )
- {
- (yy_init) = 1;
-
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! (yy_start) )
- (yy_start) = 1; /* first start state */
-
- if ( ! yyin )
- yyin = stdin;
-
- if ( ! yyout )
- yyout = stdout;
-
- if ( ! YY_CURRENT_BUFFER ) {
- yyensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- yy_create_buffer(yyin,YY_BUF_SIZE );
- }
-
- yy_load_buffer_state( );
- }
-
- while ( 1 ) /* loops until end-of-file is reached */
- {
- yy_cp = (yy_c_buf_p);
-
- /* Support of yytext. */
- *yy_cp = (yy_hold_char);
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = (yy_start);
-yy_match:
- do
- {
- register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 141 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- ++yy_cp;
- }
- while ( yy_base[yy_current_state] != 210 );
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
- if ( yy_act == 0 )
- { /* have to back up */
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- yy_act = yy_accept[yy_current_state];
- }
-
- YY_DO_BEFORE_ACTION;
-
-do_action: /* This label is used only to access EOF actions. */
-
- switch ( yy_act )
- { /* beginning of action switch */
- case 0: /* must back up */
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = (yy_hold_char);
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- goto yy_find_action;
-
-case 1:
-YY_RULE_SETUP
-#line 21 "lexer.lex"
-{
- yylval.strval = yytext;
- return NUMBER;
-}
- YY_BREAK
-case 2:
-YY_RULE_SETUP
-#line 26 "lexer.lex"
-{
- yylval.strval = yytext;
- return KEYWORD;
-}
- YY_BREAK
-case 3:
-YY_RULE_SETUP
-#line 31 "lexer.lex"
-{
- yylval.strval = yytext;
- return KEYWORD;
-}
- YY_BREAK
-case 4:
-YY_RULE_SETUP
-#line 36 "lexer.lex"
-{
- yylval.strval = yytext;
- return IDENTIFIER;
-}
- YY_BREAK
-case 5:
-/* rule 5 can match eol */
-YY_RULE_SETUP
-#line 41 "lexer.lex"
-{
- yylval.strval = yytext;
- return STRING;
-}
- YY_BREAK
-case 6:
-/* rule 6 can match eol */
-YY_RULE_SETUP
-#line 46 "lexer.lex"
-{
- yylval.strval = yytext;
- return STRING_DQ;
-}
- YY_BREAK
-case 7:
-YY_RULE_SETUP
-#line 52 "lexer.lex"
-{
- yylval.strval = yytext;
- return OPERATOR;
-}
- YY_BREAK
-case 8:
-YY_RULE_SETUP
-#line 57 "lexer.lex"
-{
- yylval.strval = yytext;
- return OPERATOR;
-}
- YY_BREAK
-case 9:
-YY_RULE_SETUP
-#line 62 "lexer.lex"
-{
- yylval.strval = yytext;
- return OPERATOR;
-}
- YY_BREAK
-case 10:
-YY_RULE_SETUP
-#line 67 "lexer.lex"
-{
- yylval.strval = yytext;
- return MISC;
-}
- YY_BREAK
-case 11:
-YY_RULE_SETUP
-#line 72 "lexer.lex"
-{
- yylval.strval = yytext;
- return LCURLY;
-}
- YY_BREAK
-case 12:
-YY_RULE_SETUP
-#line 77 "lexer.lex"
-{
- yylval.strval = yytext;
- return RCURLY;
-}
- YY_BREAK
-case 13:
-/* rule 13 can match eol */
-YY_RULE_SETUP
-#line 82 "lexer.lex"
-{
- ++current_line;
- yylval.strval = yytext;
- return MISC;
-}
- YY_BREAK
-case 14:
-YY_RULE_SETUP
-#line 88 "lexer.lex"
-{
- yylval.strval = yytext;
- return UNRECOGNIZED;
-}
- YY_BREAK
-case 15:
-YY_RULE_SETUP
-#line 94 "lexer.lex"
-ECHO;
- YY_BREAK
-#line 948 "lexer_code.c"
-case YY_STATE_EOF(INITIAL):
- yyterminate();
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = (yy_hold_char);
- YY_RESTORE_YY_MORE_OFFSET
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed yyin at a new source and called
- * yylex(). If so, then we have to assure
- * consistency between YY_CURRENT_BUFFER and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++(yy_c_buf_p);
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = (yy_c_buf_p);
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_END_OF_FILE:
- {
- (yy_did_buffer_switch_on_eof) = 0;
-
- if ( yywrap( ) )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * yytext, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) =
- (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- (yy_c_buf_p) =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
-} /* end of yylex */
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-static int yy_get_next_buffer (void)
-{
- register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
- register char *source = (yytext_ptr);
- register int number_to_move, i;
- int ret_val;
-
- if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
- {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
-
- else
- {
- yy_size_t num_to_read =
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
-
- int yy_c_buf_p_offset =
- (int) ((yy_c_buf_p) - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer )
- {
- yy_size_t new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 )
- b->yy_buf_size += b->yy_buf_size / 8;
- else
- b->yy_buf_size *= 2;
-
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
- }
- else
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
- number_to_move - 1;
-
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- (yy_n_chars), num_to_read );
-
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- if ( (yy_n_chars) == 0 )
- {
- if ( number_to_move == YY_MORE_ADJ )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- yyrestart(yyin );
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
- /* Extend the array by 50%, plus the number we really need. */
- yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
- if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
- }
-
- (yy_n_chars) += number_to_move;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
-
- (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
-
- return ret_val;
-}
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
- static yy_state_type yy_get_previous_state (void)
-{
- register yy_state_type yy_current_state;
- register char *yy_cp;
-
- yy_current_state = (yy_start);
-
- for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
- {
- register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 141 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- }
-
- return yy_current_state;
-}
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
- static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
-{
- register int yy_is_jam;
- register char *yy_cp = (yy_c_buf_p);
-
- register YY_CHAR yy_c = 1;
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 141 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 140);
-
- return yy_is_jam ? 0 : yy_current_state;
-}
-
- static void yyunput (int c, register char * yy_bp )
-{
- register char *yy_cp;
-
- yy_cp = (yy_c_buf_p);
-
- /* undo effects of setting up yytext */
- *yy_cp = (yy_hold_char);
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- /* +2 for EOB chars. */
- register yy_size_t number_to_move = (yy_n_chars) + 2;
- register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
- register char *source =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
-
- while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += (int) (dest - source);
- yy_bp += (int) (dest - source);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- *--yy_cp = (char) c;
-
- (yytext_ptr) = yy_bp;
- (yy_hold_char) = *yy_cp;
- (yy_c_buf_p) = yy_cp;
-}
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
- static int yyinput (void)
-#else
- static int input (void)
-#endif
-
-{
- int c;
-
- *(yy_c_buf_p) = (yy_hold_char);
-
- if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- /* This was really a NUL. */
- *(yy_c_buf_p) = '\0';
-
- else
- { /* need more input */
- yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
- ++(yy_c_buf_p);
-
- switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_LAST_MATCH:
- /* This happens because yy_g_n_b()
- * sees that we've accumulated a
- * token and flags that we need to
- * try matching the token before
- * proceeding. But for input(),
- * there's no matching to consider.
- * So convert the EOB_ACT_LAST_MATCH
- * to EOB_ACT_END_OF_FILE.
- */
-
- /* Reset buffer status. */
- yyrestart(yyin );
-
- /*FALLTHROUGH*/
-
- case EOB_ACT_END_OF_FILE:
- {
- if ( yywrap( ) )
- return 0;
-
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) = (yytext_ptr) + offset;
- break;
- }
- }
- }
-
- c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
- *(yy_c_buf_p) = '\0'; /* preserve yytext */
- (yy_hold_char) = *++(yy_c_buf_p);
-
- return c;
-}
-#endif /* ifndef YY_NO_INPUT */
-
-/** Immediately switch to a different input stream.
- * @param input_file A readable stream.
- *
- * @note This function does not reset the start condition to @c INITIAL .
- */
- void yyrestart (FILE * input_file )
-{
-
- if ( ! YY_CURRENT_BUFFER ){
- yyensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- yy_create_buffer(yyin,YY_BUF_SIZE );
- }
-
- yy_init_buffer(YY_CURRENT_BUFFER,input_file );
- yy_load_buffer_state( );
-}
-
-/** Switch to a different input buffer.
- * @param new_buffer The new input buffer.
- *
- */
- void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
-{
-
- /* TODO. We should be able to replace this entire function body
- * with
- * yypop_buffer_state();
- * yypush_buffer_state(new_buffer);
- */
- yyensure_buffer_stack ();
- if ( YY_CURRENT_BUFFER == new_buffer )
- return;
-
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
- yy_load_buffer_state( );
-
- /* We don't actually know whether we did this switch during
- * EOF (yywrap()) processing, but the only time this flag
- * is looked at is after yywrap() is called, so it's safe
- * to go ahead and always set it.
- */
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-static void yy_load_buffer_state (void)
-{
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
- yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
- (yy_hold_char) = *(yy_c_buf_p);
-}
-
-/** Allocate and initialize an input buffer state.
- * @param file A readable stream.
- * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
- *
- * @return the allocated buffer state.
- */
- YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
-{
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_buf_size = size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_is_our_buffer = 1;
-
- yy_init_buffer(b,file );
-
- return b;
-}
-
-/** Destroy the buffer.
- * @param b a buffer created with yy_create_buffer()
- *
- */
- void yy_delete_buffer (YY_BUFFER_STATE b )
-{
-
- if ( ! b )
- return;
-
- if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
- YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
-
- if ( b->yy_is_our_buffer )
- yyfree((void *) b->yy_ch_buf );
-
- yyfree((void *) b );
-}
-
-#ifndef __cplusplus
-extern int isatty (int );
-#endif /* __cplusplus */
-
-/* Initializes or reinitializes a buffer.
- * This function is sometimes called more than once on the same buffer,
- * such as during a yyrestart() or at EOF.
- */
- static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
-
-{
- int oerrno = errno;
-
- yy_flush_buffer(b );
-
- b->yy_input_file = file;
- b->yy_fill_buffer = 1;
-
- /* If b is the current buffer, then yy_init_buffer was _probably_
- * called from yyrestart() or through yy_get_next_buffer.
- * In that case, we don't want to reset the lineno or column.
- */
- if (b != YY_CURRENT_BUFFER){
- b->yy_bs_lineno = 1;
- b->yy_bs_column = 0;
- }
-
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-
- errno = oerrno;
-}
-
-/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
- * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
- *
- */
- void yy_flush_buffer (YY_BUFFER_STATE b )
-{
- if ( ! b )
- return;
-
- b->yy_n_chars = 0;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[0];
-
- b->yy_at_bol = 1;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- if ( b == YY_CURRENT_BUFFER )
- yy_load_buffer_state( );
-}
-
-/** Pushes the new state onto the stack. The new state becomes
- * the current state. This function will allocate the stack
- * if necessary.
- * @param new_buffer The new state.
- *
- */
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
-{
- if (new_buffer == NULL)
- return;
-
- yyensure_buffer_stack();
-
- /* This block is copied from yy_switch_to_buffer. */
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- /* Only push if top exists. Otherwise, replace top. */
- if (YY_CURRENT_BUFFER)
- (yy_buffer_stack_top)++;
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
-
- /* copied from yy_switch_to_buffer. */
- yy_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-/** Removes and deletes the top of the stack, if present.
- * The next element becomes the new top.
- *
- */
-void yypop_buffer_state (void)
-{
- if (!YY_CURRENT_BUFFER)
- return;
-
- yy_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- if ((yy_buffer_stack_top) > 0)
- --(yy_buffer_stack_top);
-
- if (YY_CURRENT_BUFFER) {
- yy_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
- }
-}
-
-/* Allocates the stack if it does not exist.
- * Guarantees space for at least one push.
- */
-static void yyensure_buffer_stack (void)
-{
- yy_size_t num_to_alloc;
-
- if (!(yy_buffer_stack)) {
-
- /* First allocation is just for 2 elements, since we don't know if this
- * scanner will even need a stack. We use 2 instead of 1 to avoid an
- * immediate realloc on the next call.
- */
- num_to_alloc = 1;
- (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
- (num_to_alloc * sizeof(struct yy_buffer_state*)
- );
- if ( ! (yy_buffer_stack) )
- YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
-
- memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-
- (yy_buffer_stack_max) = num_to_alloc;
- (yy_buffer_stack_top) = 0;
- return;
- }
-
- if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
-
- /* Increase the buffer to prepare for a possible push. */
- int grow_size = 8 /* arbitrary grow size */;
-
- num_to_alloc = (yy_buffer_stack_max) + grow_size;
- (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
- ((yy_buffer_stack),
- num_to_alloc * sizeof(struct yy_buffer_state*)
- );
- if ( ! (yy_buffer_stack) )
- YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
-
- /* zero only the new slots.*/
- memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
- (yy_buffer_stack_max) = num_to_alloc;
- }
-}
-
-/** Setup the input buffer state to scan directly from a user-specified character buffer.
- * @param base the character buffer
- * @param size the size in bytes of the character buffer
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
-{
- YY_BUFFER_STATE b;
-
- if ( size < 2 ||
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
- base[size-1] != YY_END_OF_BUFFER_CHAR )
- /* They forgot to leave room for the EOB's. */
- return 0;
-
- b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
-
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
- b->yy_buf_pos = b->yy_ch_buf = base;
- b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
- b->yy_n_chars = b->yy_buf_size;
- b->yy_is_interactive = 0;
- b->yy_at_bol = 1;
- b->yy_fill_buffer = 0;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- yy_switch_to_buffer(b );
-
- return b;
-}
-
-/** Setup the input buffer state to scan a string. The next call to yylex() will
- * scan from a @e copy of @a str.
- * @param yystr a NUL-terminated string to scan
- *
- * @return the newly allocated buffer state object.
- * @note If you want to scan bytes that may contain NUL values, then use
- * yy_scan_bytes() instead.
- */
-YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
-{
-
- return yy_scan_bytes(yystr,strlen(yystr) );
-}
-
-/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
- * scan from a @e copy of @a bytes.
- * @param bytes the byte buffer to scan
- * @param len the number of bytes in the buffer pointed to by @a bytes.
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
-{
- YY_BUFFER_STATE b;
- char *buf;
- yy_size_t n, i;
-
- /* Get memory for full buffer, including space for trailing EOB's. */
- n = _yybytes_len + 2;
- buf = (char *) yyalloc(n );
- if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
-
- for ( i = 0; i < _yybytes_len; ++i )
- buf[i] = yybytes[i];
-
- buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
-
- b = yy_scan_buffer(buf,n );
- if ( ! b )
- YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
-
- /* It's okay to grow etc. this buffer, and we should throw it
- * away when we're done.
- */
- b->yy_is_our_buffer = 1;
-
- return b;
-}
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-static void yy_fatal_error (yyconst char* msg )
-{
- (void) fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
-}
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- yytext[yyleng] = (yy_hold_char); \
- (yy_c_buf_p) = yytext + yyless_macro_arg; \
- (yy_hold_char) = *(yy_c_buf_p); \
- *(yy_c_buf_p) = '\0'; \
- yyleng = yyless_macro_arg; \
- } \
- while ( 0 )
-
-/* Accessor methods (get/set functions) to struct members. */
-
-/** Get the current line number.
- *
- */
-int yyget_lineno (void)
-{
-
- return yylineno;
-}
-
-/** Get the input stream.
- *
- */
-FILE *yyget_in (void)
-{
- return yyin;
-}
-
-/** Get the output stream.
- *
- */
-FILE *yyget_out (void)
-{
- return yyout;
-}
-
-/** Get the length of the current token.
- *
- */
-yy_size_t yyget_leng (void)
-{
- return yyleng;
-}
-
-/** Get the current token.
- *
- */
-
-char *yyget_text (void)
-{
- return yytext;
-}
-
-/** Set the current line number.
- * @param line_number
- *
- */
-void yyset_lineno (int line_number )
-{
-
- yylineno = line_number;
-}
-
-/** Set the input stream. This does not discard the current
- * input buffer.
- * @param in_str A readable stream.
- *
- * @see yy_switch_to_buffer
- */
-void yyset_in (FILE * in_str )
-{
- yyin = in_str ;
-}
-
-void yyset_out (FILE * out_str )
-{
- yyout = out_str ;
-}
-
-int yyget_debug (void)
-{
- return yy_flex_debug;
-}
-
-void yyset_debug (int bdebug )
-{
- yy_flex_debug = bdebug ;
-}
-
-static int yy_init_globals (void)
-{
- /* Initialization is the same as for the non-reentrant scanner.
- * This function is called from yylex_destroy(), so don't allocate here.
- */
-
- (yy_buffer_stack) = 0;
- (yy_buffer_stack_top) = 0;
- (yy_buffer_stack_max) = 0;
- (yy_c_buf_p) = (char *) 0;
- (yy_init) = 0;
- (yy_start) = 0;
-
-/* Defined in main.c */
-#ifdef YY_STDINIT
- yyin = stdin;
- yyout = stdout;
-#else
- yyin = (FILE *) 0;
- yyout = (FILE *) 0;
-#endif
-
- /* For future reference: Set errno on error, since we are called by
- * yylex_init()
- */
- return 0;
-}
-
-/* yylex_destroy is for both reentrant and non-reentrant scanners. */
-int yylex_destroy (void)
-{
-
- /* Pop the buffer stack, destroying each element. */
- while(YY_CURRENT_BUFFER){
- yy_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- yypop_buffer_state();
- }
-
- /* Destroy the stack itself. */
- yyfree((yy_buffer_stack) );
- (yy_buffer_stack) = NULL;
-
- /* Reset the globals. This is important in a non-reentrant scanner so the next time
- * yylex() is called, initialization will occur. */
- yy_init_globals( );
-
- return 0;
-}
-
-/*
- * Internal utility routines.
- */
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
-{
- register int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
-}
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s )
-{
- register int n;
- for ( n = 0; s[n]; ++n )
- ;
-
- return n;
-}
-#endif
-
-void *yyalloc (yy_size_t size )
-{
- return (void *) malloc( size );
-}
-
-void *yyrealloc (void * ptr, yy_size_t size )
-{
- /* The cast to (char *) in the following accommodates both
- * implementations that use char* generic pointers, and those
- * that use void* generic pointers. It works with the latter
- * because both ANSI C and C++ allow castless assignment from
- * any pointer type to void*, and deal with argument conversions
- * as though doing an assignment.
- */
- return (void *) realloc( (char *) ptr, size );
-}
-
-void yyfree (void * ptr )
-{
- free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
-}
-
-#define YYTABLES_NAME "yytables"
-
-#line 94 "lexer.lex"
-
-
-
-int yywrap()
-{
- return 1;
-}
-
-
diff --git a/homework/81319/golang2html_code_fold/output.html b/homework/81319/golang2html_code_fold/output.html
deleted file mode 100644
index 5a8f88c..0000000
--- a/homework/81319/golang2html_code_fold/output.html
+++ /dev/null
@@ -1,45 +0,0 @@
-<!doctype><html>
-<head> <title>hello_world.go</title>
- <style> .identifier { color: brown; } .keyword { color: #1fbfe2; } .number { color: blue; } .string { color: green; } .operator { color: #db184c; font-style: bold; } .collapsible { background-color: #777; color: white; cursor: pointer; padding: 2px; width: 2%; border: none; text-align: center; outline: none; font-size: 15px; } .active, .collapsible:hover { background-color: #555; } </style>
-</head>
-<body bgcolor="#e2cdb7"> <pre class="code">
-<span class="keyword">package</span> <span class="identifier">main</span>
-
-<span class="keyword">import</span> (
- <span class="string">"fmt"</span>
-)
-
-<span class="keyword">type</span> <span class="identifier">HelloWorlder</span> <span class="keyword">struct</span> {<button class="collapsible">+</button><div class="content">
- <span class="identifier">message</span> <span class="identifier">string</span>
-</div>}
-
-
-<span class="keyword">func</span> (<span class="identifier">hw</span> <span class="operator">*</span><span class="identifier">HelloWorlder</span>) <span class="identifier">greet</span>() {<button class="collapsible">+</button><div class="content">
- <span class="identifier">fmt</span><span class="operator">.</span><span class="identifier">Println</span>(<span class="identifier">hw</span><span class="operator">.</span><span class="identifier">message</span>)
-</div>}
-
-
-<span class="keyword">func</span> <span class="identifier">main</span>() {<button class="collapsible">+</button><div class="content">
- <span class="identifier">helloWorlder</span> <span class="operator">:=</span> <span class="operator">&</span><span class="identifier">HelloWorlder</span>{<button class="collapsible">+</button><div class="content">
- <span class="identifier">message</span><span class="operator">:</span> <span class="string">"Hello, world!"</span><span class="operator">,</span>
- </div>}
-
-
- <span class="identifier">helloWorlder</span><span class="operator">.</span><span class="identifier">greet</span>()
-</div>}</pre></body>
-<script>var coll = document.getElementsByClassName("collapsible");
-var i;
-
-for (i = 0; i < coll.length; i++) {
-coll[i].addEventListener("click", function() {
-this.classList.toggle("active");
-var content = this.nextElementSibling;
-if (content.style.display === "block") {
-content.style.display = "none";
-this.innerHTML="+"} else {
-content.style.display = "block";
-this.innerHTML="-"}
-});
-}
-</script>
-</html>
diff --git a/homework/81319/golang2html_code_fold/parser.output b/homework/81319/golang2html_code_fold/parser.output
deleted file mode 100644
index 8722eaf..0000000
--- a/homework/81319/golang2html_code_fold/parser.output
+++ /dev/null
@@ -1,274 +0,0 @@
-State 13 conflicts: 8 shift/reduce
-
-
-Grammar
-
- 0 $accept: input $end
-
- 1 input: /* empty */
- 2 | expr_list
-
- 3 expr_list: expr expr_list
- 4 | expr
-
- 5 expr: token_sequence
- 6 | LCURLY expr_list RCURLY
- 7 | LCURLY RCURLY
-
- 8 token_sequence: token_sequence token
- 9 | token
-
- 10 token: NUMBER
- 11 | KEYWORD
- 12 | STRING
- 13 | STRING_DQ
- 14 | IDENTIFIER
- 15 | OPERATOR
- 16 | MISC
- 17 | UNRECOGNIZED
-
-
-Terminals, with rules where they appear
-
-$end (0) 0
-error (256)
-NUMBER (258) 10
-KEYWORD (259) 11
-STRING (260) 12
-STRING_DQ (261) 13
-IDENTIFIER (262) 14
-OPERATOR (263) 15
-MISC (264) 16
-UNRECOGNIZED (265) 17
-LCURLY (266) 6 7
-RCURLY (267) 6 7
-
-
-Nonterminals, with rules where they appear
-
-$accept (13)
- on left: 0
-input (14)
- on left: 1 2, on right: 0
-expr_list (15)
- on left: 3 4, on right: 2 3 6
-expr (16)
- on left: 5 6 7, on right: 3 4
-token_sequence (17)
- on left: 8 9, on right: 5 8
-token (18)
- on left: 10 11 12 13 14 15 16 17, on right: 8 9
-
-
-state 0
-
- 0 $accept: . input $end
-
- NUMBER shift, and go to state 1
- KEYWORD shift, and go to state 2
- STRING shift, and go to state 3
- STRING_DQ shift, and go to state 4
- IDENTIFIER shift, and go to state 5
- OPERATOR shift, and go to state 6
- MISC shift, and go to state 7
- UNRECOGNIZED shift, and go to state 8
- LCURLY shift, and go to state 9
-
- $default reduce using rule 1 (input)
-
- input go to state 10
- expr_list go to state 11
- expr go to state 12
- token_sequence go to state 13
- token go to state 14
-
-
-state 1
-
- 10 token: NUMBER .
-
- $default reduce using rule 10 (token)
-
-
-state 2
-
- 11 token: KEYWORD .
-
- $default reduce using rule 11 (token)
-
-
-state 3
-
- 12 token: STRING .
-
- $default reduce using rule 12 (token)
-
-
-state 4
-
- 13 token: STRING_DQ .
-
- $default reduce using rule 13 (token)
-
-
-state 5
-
- 14 token: IDENTIFIER .
-
- $default reduce using rule 14 (token)
-
-
-state 6
-
- 15 token: OPERATOR .
-
- $default reduce using rule 15 (token)
-
-
-state 7
-
- 16 token: MISC .
-
- $default reduce using rule 16 (token)
-
-
-state 8
-
- 17 token: UNRECOGNIZED .
-
- $default reduce using rule 17 (token)
-
-
-state 9
-
- 6 expr: LCURLY . expr_list RCURLY
- 7 | LCURLY . RCURLY
-
- NUMBER shift, and go to state 1
- KEYWORD shift, and go to state 2
- STRING shift, and go to state 3
- STRING_DQ shift, and go to state 4
- IDENTIFIER shift, and go to state 5
- OPERATOR shift, and go to state 6
- MISC shift, and go to state 7
- UNRECOGNIZED shift, and go to state 8
- LCURLY shift, and go to state 9
- RCURLY shift, and go to state 15
-
- expr_list go to state 16
- expr go to state 12
- token_sequence go to state 13
- token go to state 14
-
-
-state 10
-
- 0 $accept: input . $end
-
- $end shift, and go to state 17
-
-
-state 11
-
- 2 input: expr_list .
-
- $default reduce using rule 2 (input)
-
-
-state 12
-
- 3 expr_list: expr . expr_list
- 4 | expr .
-
- NUMBER shift, and go to state 1
- KEYWORD shift, and go to state 2
- STRING shift, and go to state 3
- STRING_DQ shift, and go to state 4
- IDENTIFIER shift, and go to state 5
- OPERATOR shift, and go to state 6
- MISC shift, and go to state 7
- UNRECOGNIZED shift, and go to state 8
- LCURLY shift, and go to state 9
-
- $default reduce using rule 4 (expr_list)
-
- expr_list go to state 18
- expr go to state 12
- token_sequence go to state 13
- token go to state 14
-
-
-state 13
-
- 5 expr: token_sequence .
- 8 token_sequence: token_sequence . token
-
- NUMBER shift, and go to state 1
- KEYWORD shift, and go to state 2
- STRING shift, and go to state 3
- STRING_DQ shift, and go to state 4
- IDENTIFIER shift, and go to state 5
- OPERATOR shift, and go to state 6
- MISC shift, and go to state 7
- UNRECOGNIZED shift, and go to state 8
-
- NUMBER [reduce using rule 5 (expr)]
- KEYWORD [reduce using rule 5 (expr)]
- STRING [reduce using rule 5 (expr)]
- STRING_DQ [reduce using rule 5 (expr)]
- IDENTIFIER [reduce using rule 5 (expr)]
- OPERATOR [reduce using rule 5 (expr)]
- MISC [reduce using rule 5 (expr)]
- UNRECOGNIZED [reduce using rule 5 (expr)]
- $default reduce using rule 5 (expr)
-
- token go to state 19
-
-
-state 14
-
- 9 token_sequence: token .
-
- $default reduce using rule 9 (token_sequence)
-
-
-state 15
-
- 7 expr: LCURLY RCURLY .
-
- $default reduce using rule 7 (expr)
-
-
-state 16
-
- 6 expr: LCURLY expr_list . RCURLY
-
- RCURLY shift, and go to state 20
-
-
-state 17
-
- 0 $accept: input $end .
-
- $default accept
-
-
-state 18
-
- 3 expr_list: expr expr_list .
-
- $default reduce using rule 3 (expr_list)
-
-
-state 19
-
- 8 token_sequence: token_sequence token .
-
- $default reduce using rule 8 (token_sequence)
-
-
-state 20
-
- 6 expr: LCURLY expr_list RCURLY .
-
- $default reduce using rule 6 (expr)
diff --git a/homework/81319/golang2html_code_fold/parser.tab.c b/homework/81319/golang2html_code_fold/parser.tab.c
deleted file mode 100644
index 1d259ab..0000000
--- a/homework/81319/golang2html_code_fold/parser.tab.c
+++ /dev/null
@@ -1,1826 +0,0 @@
-/* A Bison parser, made by GNU Bison 2.3. */
-
-/* Skeleton implementation for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-/* C LALR(1) parser skeleton written by Richard Stallman, by
- simplifying the original so-called "semantic" parser. */
-
-/* All symbols defined below should begin with yy or YY, to avoid
- infringing on user name space. This should be done even for local
- variables, as they might otherwise be expanded by user macros.
- There are some unavoidable exceptions within include files to
- define necessary library symbols; they are noted "INFRINGES ON
- USER NAME SPACE" below. */
-
-/* Identify Bison output. */
-#define YYBISON 1
-
-/* Bison version. */
-#define YYBISON_VERSION "2.3"
-
-/* Skeleton name. */
-#define YYSKELETON_NAME "yacc.c"
-
-/* Pure parsers. */
-#define YYPURE 0
-
-/* Using locations. */
-#define YYLSP_NEEDED 0
-
-
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- NUMBER = 258,
- KEYWORD = 259,
- STRING = 260,
- STRING_DQ = 261,
- IDENTIFIER = 262,
- OPERATOR = 263,
- MISC = 264,
- UNRECOGNIZED = 265,
- LCURLY = 266,
- RCURLY = 267
- };
-#endif
-/* Tokens. */
-#define NUMBER 258
-#define KEYWORD 259
-#define STRING 260
-#define STRING_DQ 261
-#define IDENTIFIER 262
-#define OPERATOR 263
-#define MISC 264
-#define UNRECOGNIZED 265
-#define LCURLY 266
-#define RCURLY 267
-
-
-
-
-/* Copy the first part of user declarations. */
-#line 1 "parser.y"
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-int yylex();
-int yyerror(const char* error);
-#define YYDEBUG 1
-
-char* concatenate(char* first, char* second) {
- int firstlen = strlen(first);
- int secondlen = strlen(second);
- char* result;
- result = malloc(firstlen + secondlen + 1);
- strcpy(result, first);
- strcat(result, second);
-
- return result;
-}
-
-void printStyles() {
- puts(
- " <style>"
- " .identifier {"
- " color: brown;"
- " }"
- " .keyword {"
- " color: #1fbfe2;"
- " }"
- " .number {"
- " color: blue;"
- " }"
- " .string {"
- " color: green;"
- " }"
- " .operator {"
- " color: #db184c;"
- " font-style: bold;"
- " }"
- " .collapsible {"
- " background-color: #777;"
- " color: white;"
- " cursor: pointer;"
- " padding: 2px;"
- " width: 2%;"
- " border: none;"
- " text-align: center;"
- " outline: none;"
- " font-size: 15px;"
- " }"
-
- " .active, .collapsible:hover {"
- " background-color: #555;"
- " }"
-
-
- " </style>"
- );
-}
-
-void printCollapsableScript() {
- puts(
- "<script>"
- "var coll = document.getElementsByClassName(\"collapsible\");\n"
- "var i;\n"
- "\n"
- "for (i = 0; i < coll.length; i++) {\n"
- "coll[i].addEventListener(\"click\", function() {\n"
- "this.classList.toggle(\"active\");\n"
- "var content = this.nextElementSibling;\n"
- "if (content.style.display === \"block\") {\n"
- "content.style.display = \"none\";\n"
- "this.innerHTML=\"+\""
- "} else {\n"
- "content.style.display = \"block\";\n"
- "this.innerHTML=\"-\""
- "}\n"
- "});\n"
- "}\n"
- "</script>"
- );
-}
-
-char* stylize(char* text, char* style) {
- char* result = concatenate("<span class=\"", style);
- result = concatenate(result, "\">");
- result = concatenate(result, text);
- result = concatenate(result, "</span>");
-
- return result;
-}
-
-char* collapsableBlock(char* text) {
- char* result = concatenate("<button class=\"collapsible\">+</button>", "<div class=\"content\">");
- result = concatenate(result, text);
- result = concatenate(result, "</div>");
-
- return result;
-}
-
-void printNumber(char* text) {
- char* style = stylize(text, "number");
- printf("%s", style);
-}
-
-
-void printIdentifier(char* text) {
- char* style = stylize(text, "identifier");
- printf("%s", style);
-}
-
-void printKeyword(char* text) {
- char* style = stylize(text, "keyword");
- printf("%s", style);
-}
-
-void printString(char* text) {
- char* style = stylize(text, "string");
- printf("%s", style);
-}
-
-void printOperator(char* text) {
- char* style = stylize(text, "operator");
- printf("%s", style);
-}
-
-void printMisc(char* text) {
- printf("%s", text);
-}
-
-void printUnrecognized(char* text) {
- printf("Unrecognized token: %s", text);
-}
-
-void printBraces(char* text) {
- printf("%s", text);
-}
-
-
-
-/* Enabling traces. */
-#ifndef YYDEBUG
-# define YYDEBUG 0
-#endif
-
-/* Enabling verbose error messages. */
-#ifdef YYERROR_VERBOSE
-# undef YYERROR_VERBOSE
-# define YYERROR_VERBOSE 1
-#else
-# define YYERROR_VERBOSE 0
-#endif
-
-/* Enabling the token table. */
-#ifndef YYTOKEN_TABLE
-# define YYTOKEN_TABLE 0
-#endif
-
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE
-#line 154 "parser.y"
-{
- char* strval;
-}
-/* Line 193 of yacc.c. */
-#line 263 "parser.tab.c"
- YYSTYPE;
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
-#endif
-
-
-
-/* Copy the second part of user declarations. */
-
-
-/* Line 216 of yacc.c. */
-#line 276 "parser.tab.c"
-
-#ifdef short
-# undef short
-#endif
-
-#ifdef YYTYPE_UINT8
-typedef YYTYPE_UINT8 yytype_uint8;
-#else
-typedef unsigned char yytype_uint8;
-#endif
-
-#ifdef YYTYPE_INT8
-typedef YYTYPE_INT8 yytype_int8;
-#elif (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-typedef signed char yytype_int8;
-#else
-typedef short int yytype_int8;
-#endif
-
-#ifdef YYTYPE_UINT16
-typedef YYTYPE_UINT16 yytype_uint16;
-#else
-typedef unsigned short int yytype_uint16;
-#endif
-
-#ifdef YYTYPE_INT16
-typedef YYTYPE_INT16 yytype_int16;
-#else
-typedef short int yytype_int16;
-#endif
-
-#ifndef YYSIZE_T
-# ifdef __SIZE_TYPE__
-# define YYSIZE_T __SIZE_TYPE__
-# elif defined size_t
-# define YYSIZE_T size_t
-# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# else
-# define YYSIZE_T unsigned int
-# endif
-#endif
-
-#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
-
-#ifndef YY_
-# if defined YYENABLE_NLS && YYENABLE_NLS
-# if ENABLE_NLS
-# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
-# define YY_(msgid) dgettext ("bison-runtime", msgid)
-# endif
-# endif
-# ifndef YY_
-# define YY_(msgid) msgid
-# endif
-#endif
-
-/* Suppress unused-variable warnings by "using" E. */
-#if ! defined lint || defined __GNUC__
-# define YYUSE(e) ((void) (e))
-#else
-# define YYUSE(e) /* empty */
-#endif
-
-/* Identity function, used to suppress warnings about constant conditions. */
-#ifndef lint
-# define YYID(n) (n)
-#else
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static int
-YYID (int i)
-#else
-static int
-YYID (i)
- int i;
-#endif
-{
- return i;
-}
-#endif
-
-#if ! defined yyoverflow || YYERROR_VERBOSE
-
-/* The parser invokes alloca or malloc; define the necessary symbols. */
-
-# ifdef YYSTACK_USE_ALLOCA
-# if YYSTACK_USE_ALLOCA
-# ifdef __GNUC__
-# define YYSTACK_ALLOC __builtin_alloca
-# elif defined __BUILTIN_VA_ARG_INCR
-# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
-# elif defined _AIX
-# define YYSTACK_ALLOC __alloca
-# elif defined _MSC_VER
-# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
-# define alloca _alloca
-# else
-# define YYSTACK_ALLOC alloca
-# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef _STDLIB_H
-# define _STDLIB_H 1
-# endif
-# endif
-# endif
-# endif
-# endif
-
-# ifdef YYSTACK_ALLOC
- /* Pacify GCC's `empty if-body' warning. */
-# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
-# ifndef YYSTACK_ALLOC_MAXIMUM
- /* The OS might guarantee only one guard page at the bottom of the stack,
- and a page size can be as small as 4096 bytes. So we cannot safely
- invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
- to allow for a few compiler-allocated temporary stack slots. */
-# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
-# endif
-# else
-# define YYSTACK_ALLOC YYMALLOC
-# define YYSTACK_FREE YYFREE
-# ifndef YYSTACK_ALLOC_MAXIMUM
-# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
-# endif
-# if (defined __cplusplus && ! defined _STDLIB_H \
- && ! ((defined YYMALLOC || defined malloc) \
- && (defined YYFREE || defined free)))
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef _STDLIB_H
-# define _STDLIB_H 1
-# endif
-# endif
-# ifndef YYMALLOC
-# define YYMALLOC malloc
-# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# ifndef YYFREE
-# define YYFREE free
-# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-void free (void *); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# endif
-#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
-
-
-#if (! defined yyoverflow \
- && (! defined __cplusplus \
- || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
-
-/* A type that is properly aligned for any stack member. */
-union yyalloc
-{
- yytype_int16 yyss;
- YYSTYPE yyvs;
- };
-
-/* The size of the maximum gap between one aligned stack and the next. */
-# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
-
-/* The size of an array large to enough to hold all stacks, each with
- N elements. */
-# define YYSTACK_BYTES(N) \
- ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
- + YYSTACK_GAP_MAXIMUM)
-
-/* Copy COUNT objects from FROM to TO. The source and destination do
- not overlap. */
-# ifndef YYCOPY
-# if defined __GNUC__ && 1 < __GNUC__
-# define YYCOPY(To, From, Count) \
- __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
-# else
-# define YYCOPY(To, From, Count) \
- do \
- { \
- YYSIZE_T yyi; \
- for (yyi = 0; yyi < (Count); yyi++) \
- (To)[yyi] = (From)[yyi]; \
- } \
- while (YYID (0))
-# endif
-# endif
-
-/* Relocate STACK from its old location to the new one. The
- local variables YYSIZE and YYSTACKSIZE give the old and new number of
- elements in the stack, and YYPTR gives the new location of the
- stack. Advance YYPTR to a properly aligned location for the next
- stack. */
-# define YYSTACK_RELOCATE(Stack) \
- do \
- { \
- YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack, Stack, yysize); \
- Stack = &yyptr->Stack; \
- yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
- yyptr += yynewbytes / sizeof (*yyptr); \
- } \
- while (YYID (0))
-
-#endif
-
-/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 17
-/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 32
-
-/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 13
-/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 6
-/* YYNRULES -- Number of rules. */
-#define YYNRULES 18
-/* YYNRULES -- Number of states. */
-#define YYNSTATES 21
-
-/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
-#define YYUNDEFTOK 2
-#define YYMAXUTOK 267
-
-#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
-
-/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
-static const yytype_uint8 yytranslate[] =
-{
- 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
- 5, 6, 7, 8, 9, 10, 11, 12
-};
-
-#if YYDEBUG
-/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
- YYRHS. */
-static const yytype_uint8 yyprhs[] =
-{
- 0, 0, 3, 4, 6, 9, 11, 13, 17, 20,
- 23, 25, 27, 29, 31, 33, 35, 37, 39
-};
-
-/* YYRHS -- A `-1'-separated list of the rules' RHS. */
-static const yytype_int8 yyrhs[] =
-{
- 14, 0, -1, -1, 15, -1, 16, 15, -1, 16,
- -1, 17, -1, 11, 15, 12, -1, 11, 12, -1,
- 17, 18, -1, 18, -1, 3, -1, 4, -1, 5,
- -1, 6, -1, 7, -1, 8, -1, 9, -1, 10,
- -1
-};
-
-/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
-static const yytype_uint8 yyrline[] =
-{
- 0, 163, 163, 164, 167, 168, 171, 172, 177, 181,
- 182, 185, 186, 187, 188, 189, 190, 191, 192
-};
-#endif
-
-#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
-/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
- First, the terminals, then, starting at YYNTOKENS, nonterminals. */
-static const char *const yytname[] =
-{
- "$end", "error", "$undefined", "NUMBER", "KEYWORD", "STRING",
- "STRING_DQ", "IDENTIFIER", "OPERATOR", "MISC", "UNRECOGNIZED", "LCURLY",
- "RCURLY", "$accept", "input", "expr_list", "expr", "token_sequence",
- "token", 0
-};
-#endif
-
-# ifdef YYPRINT
-/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
- token YYLEX-NUM. */
-static const yytype_uint16 yytoknum[] =
-{
- 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
- 265, 266, 267
-};
-# endif
-
-/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
-static const yytype_uint8 yyr1[] =
-{
- 0, 13, 14, 14, 15, 15, 16, 16, 16, 17,
- 17, 18, 18, 18, 18, 18, 18, 18, 18
-};
-
-/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
-static const yytype_uint8 yyr2[] =
-{
- 0, 2, 0, 1, 2, 1, 1, 3, 2, 2,
- 1, 1, 1, 1, 1, 1, 1, 1, 1
-};
-
-/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
- STATE-NUM when YYTABLE doesn't specify something else to do. Zero
- means the default is an error. */
-static const yytype_uint8 yydefact[] =
-{
- 2, 11, 12, 13, 14, 15, 16, 17, 18, 0,
- 0, 3, 5, 6, 10, 8, 0, 1, 4, 9,
- 7
-};
-
-/* YYDEFGOTO[NTERM-NUM]. */
-static const yytype_int8 yydefgoto[] =
-{
- -1, 10, 11, 12, 13, 14
-};
-
-/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
- STATE-NUM. */
-#define YYPACT_NINF -4
-static const yytype_int8 yypact[] =
-{
- 7, -4, -4, -4, -4, -4, -4, -4, -4, -3,
- 28, -4, 7, 16, -4, -4, 17, -4, -4, -4,
- -4
-};
-
-/* YYPGOTO[NTERM-NUM]. */
-static const yytype_int8 yypgoto[] =
-{
- -4, -4, 18, -4, -4, 19
-};
-
-/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
- positive, shift that token. If negative, reduce the rule which
- number is the opposite. If zero, do what YYDEFACT says.
- If YYTABLE_NINF, syntax error. */
-#define YYTABLE_NINF -1
-static const yytype_uint8 yytable[] =
-{
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 15,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 1,
- 2, 3, 4, 5, 6, 7, 8, 16, 17, 20,
- 18, 0, 19
-};
-
-static const yytype_int8 yycheck[] =
-{
- 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
- 3, 4, 5, 6, 7, 8, 9, 10, 11, 3,
- 4, 5, 6, 7, 8, 9, 10, 9, 0, 12,
- 12, -1, 13
-};
-
-/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
- symbol of state STATE-NUM. */
-static const yytype_uint8 yystos[] =
-{
- 0, 3, 4, 5, 6, 7, 8, 9, 10, 11,
- 14, 15, 16, 17, 18, 12, 15, 0, 15, 18,
- 12
-};
-
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY (-2)
-#define YYEOF 0
-
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrorlab
-
-
-/* Like YYERROR except do call yyerror. This remains here temporarily
- to ease the transition to the new meaning of YYERROR, for GCC.
- Once GCC version 2 has supplanted version 1, this can go. */
-
-#define YYFAIL goto yyerrlab
-
-#define YYRECOVERING() (!!yyerrstatus)
-
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY && yylen == 1) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- yytoken = YYTRANSLATE (yychar); \
- YYPOPSTACK (1); \
- goto yybackup; \
- } \
- else \
- { \
- yyerror (YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (YYID (0))
-
-
-#define YYTERROR 1
-#define YYERRCODE 256
-
-
-/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
- If N is 0, then set CURRENT to the empty location which ends
- the previous symbol: RHS[0] (always defined). */
-
-#define YYRHSLOC(Rhs, K) ((Rhs)[K])
-#ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(Current, Rhs, N) \
- do \
- if (YYID (N)) \
- { \
- (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
- (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
- (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
- (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
- } \
- else \
- { \
- (Current).first_line = (Current).last_line = \
- YYRHSLOC (Rhs, 0).last_line; \
- (Current).first_column = (Current).last_column = \
- YYRHSLOC (Rhs, 0).last_column; \
- } \
- while (YYID (0))
-#endif
-
-
-/* YY_LOCATION_PRINT -- Print the location on the stream.
- This macro was not mandated originally: define only if we know
- we won't break user code: when these are the locations we know. */
-
-#ifndef YY_LOCATION_PRINT
-# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
-# define YY_LOCATION_PRINT(File, Loc) \
- fprintf (File, "%d.%d-%d.%d", \
- (Loc).first_line, (Loc).first_column, \
- (Loc).last_line, (Loc).last_column)
-# else
-# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
-# endif
-#endif
-
-
-/* YYLEX -- calling `yylex' with the right arguments. */
-
-#ifdef YYLEX_PARAM
-# define YYLEX yylex (YYLEX_PARAM)
-#else
-# define YYLEX yylex ()
-#endif
-
-/* Enable debugging if requested. */
-#if YYDEBUG
-
-# ifndef YYFPRINTF
-# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
-# define YYFPRINTF fprintf
-# endif
-
-# define YYDPRINTF(Args) \
-do { \
- if (yydebug) \
- YYFPRINTF Args; \
-} while (YYID (0))
-
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
-do { \
- if (yydebug) \
- { \
- YYFPRINTF (stderr, "%s ", Title); \
- yy_symbol_print (stderr, \
- Type, Value); \
- YYFPRINTF (stderr, "\n"); \
- } \
-} while (YYID (0))
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-/*ARGSUSED*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-#else
-static void
-yy_symbol_value_print (yyoutput, yytype, yyvaluep)
- FILE *yyoutput;
- int yytype;
- YYSTYPE const * const yyvaluep;
-#endif
-{
- if (!yyvaluep)
- return;
-# ifdef YYPRINT
- if (yytype < YYNTOKENS)
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# else
- YYUSE (yyoutput);
-# endif
- switch (yytype)
- {
- default:
- break;
- }
-}
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-#else
-static void
-yy_symbol_print (yyoutput, yytype, yyvaluep)
- FILE *yyoutput;
- int yytype;
- YYSTYPE const * const yyvaluep;
-#endif
-{
- if (yytype < YYNTOKENS)
- YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
- else
- YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
-
- yy_symbol_value_print (yyoutput, yytype, yyvaluep);
- YYFPRINTF (yyoutput, ")");
-}
-
-/*------------------------------------------------------------------.
-| yy_stack_print -- Print the state stack from its BOTTOM up to its |
-| TOP (included). |
-`------------------------------------------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
-#else
-static void
-yy_stack_print (bottom, top)
- yytype_int16 *bottom;
- yytype_int16 *top;
-#endif
-{
- YYFPRINTF (stderr, "Stack now");
- for (; bottom <= top; ++bottom)
- YYFPRINTF (stderr, " %d", *bottom);
- YYFPRINTF (stderr, "\n");
-}
-
-# define YY_STACK_PRINT(Bottom, Top) \
-do { \
- if (yydebug) \
- yy_stack_print ((Bottom), (Top)); \
-} while (YYID (0))
-
-
-/*------------------------------------------------.
-| Report that the YYRULE is going to be reduced. |
-`------------------------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
-#else
-static void
-yy_reduce_print (yyvsp, yyrule)
- YYSTYPE *yyvsp;
- int yyrule;
-#endif
-{
- int yynrhs = yyr2[yyrule];
- int yyi;
- unsigned long int yylno = yyrline[yyrule];
- YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
- yyrule - 1, yylno);
- /* The symbols being reduced. */
- for (yyi = 0; yyi < yynrhs; yyi++)
- {
- fprintf (stderr, " $%d = ", yyi + 1);
- yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
- &(yyvsp[(yyi + 1) - (yynrhs)])
- );
- fprintf (stderr, "\n");
- }
-}
-
-# define YY_REDUCE_PRINT(Rule) \
-do { \
- if (yydebug) \
- yy_reduce_print (yyvsp, Rule); \
-} while (YYID (0))
-
-/* Nonzero means print parse trace. It is left uninitialized so that
- multiple parsers can coexist. */
-int yydebug;
-#else /* !YYDEBUG */
-# define YYDPRINTF(Args)
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
-# define YY_STACK_PRINT(Bottom, Top)
-# define YY_REDUCE_PRINT(Rule)
-#endif /* !YYDEBUG */
-
-
-/* YYINITDEPTH -- initial size of the parser's stacks. */
-#ifndef YYINITDEPTH
-# define YYINITDEPTH 200
-#endif
-
-/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
- if the built-in stack extension method is used).
-
- Do not make this value too large; the results are undefined if
- YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
- evaluated with infinite-precision integer arithmetic. */
-
-#ifndef YYMAXDEPTH
-# define YYMAXDEPTH 10000
-#endif
-
-
-
-#if YYERROR_VERBOSE
-
-# ifndef yystrlen
-# if defined __GLIBC__ && defined _STRING_H
-# define yystrlen strlen
-# else
-/* Return the length of YYSTR. */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static YYSIZE_T
-yystrlen (const char *yystr)
-#else
-static YYSIZE_T
-yystrlen (yystr)
- const char *yystr;
-#endif
-{
- YYSIZE_T yylen;
- for (yylen = 0; yystr[yylen]; yylen++)
- continue;
- return yylen;
-}
-# endif
-# endif
-
-# ifndef yystpcpy
-# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
-# define yystpcpy stpcpy
-# else
-/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
- YYDEST. */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static char *
-yystpcpy (char *yydest, const char *yysrc)
-#else
-static char *
-yystpcpy (yydest, yysrc)
- char *yydest;
- const char *yysrc;
-#endif
-{
- char *yyd = yydest;
- const char *yys = yysrc;
-
- while ((*yyd++ = *yys++) != '\0')
- continue;
-
- return yyd - 1;
-}
-# endif
-# endif
-
-# ifndef yytnamerr
-/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
- quotes and backslashes, so that it's suitable for yyerror. The
- heuristic is that double-quoting is unnecessary unless the string
- contains an apostrophe, a comma, or backslash (other than
- backslash-backslash). YYSTR is taken from yytname. If YYRES is
- null, do not copy; instead, return the length of what the result
- would have been. */
-static YYSIZE_T
-yytnamerr (char *yyres, const char *yystr)
-{
- if (*yystr == '"')
- {
- YYSIZE_T yyn = 0;
- char const *yyp = yystr;
-
- for (;;)
- switch (*++yyp)
- {
- case '\'':
- case ',':
- goto do_not_strip_quotes;
-
- case '\\':
- if (*++yyp != '\\')
- goto do_not_strip_quotes;
- /* Fall through. */
- default:
- if (yyres)
- yyres[yyn] = *yyp;
- yyn++;
- break;
-
- case '"':
- if (yyres)
- yyres[yyn] = '\0';
- return yyn;
- }
- do_not_strip_quotes: ;
- }
-
- if (! yyres)
- return yystrlen (yystr);
-
- return yystpcpy (yyres, yystr) - yyres;
-}
-# endif
-
-/* Copy into YYRESULT an error message about the unexpected token
- YYCHAR while in state YYSTATE. Return the number of bytes copied,
- including the terminating null byte. If YYRESULT is null, do not
- copy anything; just return the number of bytes that would be
- copied. As a special case, return 0 if an ordinary "syntax error"
- message will do. Return YYSIZE_MAXIMUM if overflow occurs during
- size calculation. */
-static YYSIZE_T
-yysyntax_error (char *yyresult, int yystate, int yychar)
-{
- int yyn = yypact[yystate];
-
- if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
- return 0;
- else
- {
- int yytype = YYTRANSLATE (yychar);
- YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
- YYSIZE_T yysize = yysize0;
- YYSIZE_T yysize1;
- int yysize_overflow = 0;
- enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
- char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
- int yyx;
-
-# if 0
- /* This is so xgettext sees the translatable formats that are
- constructed on the fly. */
- YY_("syntax error, unexpected %s");
- YY_("syntax error, unexpected %s, expecting %s");
- YY_("syntax error, unexpected %s, expecting %s or %s");
- YY_("syntax error, unexpected %s, expecting %s or %s or %s");
- YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
-# endif
- char *yyfmt;
- char const *yyf;
- static char const yyunexpected[] = "syntax error, unexpected %s";
- static char const yyexpecting[] = ", expecting %s";
- static char const yyor[] = " or %s";
- char yyformat[sizeof yyunexpected
- + sizeof yyexpecting - 1
- + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
- * (sizeof yyor - 1))];
- char const *yyprefix = yyexpecting;
-
- /* Start YYX at -YYN if negative to avoid negative indexes in
- YYCHECK. */
- int yyxbegin = yyn < 0 ? -yyn : 0;
-
- /* Stay within bounds of both yycheck and yytname. */
- int yychecklim = YYLAST - yyn + 1;
- int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
- int yycount = 1;
-
- yyarg[0] = yytname[yytype];
- yyfmt = yystpcpy (yyformat, yyunexpected);
-
- for (yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
- {
- if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
- {
- yycount = 1;
- yysize = yysize0;
- yyformat[sizeof yyunexpected - 1] = '\0';
- break;
- }
- yyarg[yycount++] = yytname[yyx];
- yysize1 = yysize + yytnamerr (0, yytname[yyx]);
- yysize_overflow |= (yysize1 < yysize);
- yysize = yysize1;
- yyfmt = yystpcpy (yyfmt, yyprefix);
- yyprefix = yyor;
- }
-
- yyf = YY_(yyformat);
- yysize1 = yysize + yystrlen (yyf);
- yysize_overflow |= (yysize1 < yysize);
- yysize = yysize1;
-
- if (yysize_overflow)
- return YYSIZE_MAXIMUM;
-
- if (yyresult)
- {
- /* Avoid sprintf, as that infringes on the user's name space.
- Don't have undefined behavior even if the translation
- produced a string with the wrong number of "%s"s. */
- char *yyp = yyresult;
- int yyi = 0;
- while ((*yyp = *yyf) != '\0')
- {
- if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
- {
- yyp += yytnamerr (yyp, yyarg[yyi++]);
- yyf += 2;
- }
- else
- {
- yyp++;
- yyf++;
- }
- }
- }
- return yysize;
- }
-}
-#endif /* YYERROR_VERBOSE */
-
-
-/*-----------------------------------------------.
-| Release the memory associated to this symbol. |
-`-----------------------------------------------*/
-
-/*ARGSUSED*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
-#else
-static void
-yydestruct (yymsg, yytype, yyvaluep)
- const char *yymsg;
- int yytype;
- YYSTYPE *yyvaluep;
-#endif
-{
- YYUSE (yyvaluep);
-
- if (!yymsg)
- yymsg = "Deleting";
- YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
-
- switch (yytype)
- {
-
- default:
- break;
- }
-}
-
-
-/* Prevent warnings from -Wmissing-prototypes. */
-
-#ifdef YYPARSE_PARAM
-#if defined __STDC__ || defined __cplusplus
-int yyparse (void *YYPARSE_PARAM);
-#else
-int yyparse ();
-#endif
-#else /* ! YYPARSE_PARAM */
-#if defined __STDC__ || defined __cplusplus
-int yyparse (void);
-#else
-int yyparse ();
-#endif
-#endif /* ! YYPARSE_PARAM */
-
-
-
-/* The look-ahead symbol. */
-int yychar;
-
-/* The semantic value of the look-ahead symbol. */
-YYSTYPE yylval;
-
-/* Number of syntax errors so far. */
-int yynerrs;
-
-
-
-/*----------.
-| yyparse. |
-`----------*/
-
-#ifdef YYPARSE_PARAM
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-int
-yyparse (void *YYPARSE_PARAM)
-#else
-int
-yyparse (YYPARSE_PARAM)
- void *YYPARSE_PARAM;
-#endif
-#else /* ! YYPARSE_PARAM */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-int
-yyparse (void)
-#else
-int
-yyparse ()
-
-#endif
-#endif
-{
-
- int yystate;
- int yyn;
- int yyresult;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
- /* Look-ahead token as an internal (translated) token number. */
- int yytoken = 0;
-#if YYERROR_VERBOSE
- /* Buffer for error messages, and its allocated size. */
- char yymsgbuf[128];
- char *yymsg = yymsgbuf;
- YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
-#endif
-
- /* Three stacks and their tools:
- `yyss': related to states,
- `yyvs': related to semantic values,
- `yyls': related to locations.
-
- Refer to the stacks thru separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
-
- /* The state stack. */
- yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyss = yyssa;
- yytype_int16 *yyssp;
-
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs = yyvsa;
- YYSTYPE *yyvsp;
-
-
-
-#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
-
- YYSIZE_T yystacksize = YYINITDEPTH;
-
- /* The variables used to return semantic value and location from the
- action routines. */
- YYSTYPE yyval;
-
-
- /* The number of symbols on the RHS of the reduced rule.
- Keep to zero when no symbol should be popped. */
- int yylen = 0;
-
- YYDPRINTF ((stderr, "Starting parse\n"));
-
- yystate = 0;
- yyerrstatus = 0;
- yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
-
- /* Initialize stack pointers.
- Waste one element of value and location stack
- so that they stay on the same level as the state stack.
- The wasted elements are never initialized. */
-
- yyssp = yyss;
- yyvsp = yyvs;
-
- goto yysetstate;
-
-/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
-`------------------------------------------------------------*/
- yynewstate:
- /* In all cases, when you get here, the value and location stacks
- have just been pushed. So pushing a state here evens the stacks. */
- yyssp++;
-
- yysetstate:
- *yyssp = yystate;
-
- if (yyss + yystacksize - 1 <= yyssp)
- {
- /* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
-
-#ifdef yyoverflow
- {
- /* Give user a chance to reallocate the stack. Use copies of
- these so that the &'s don't force the real ones into
- memory. */
- YYSTYPE *yyvs1 = yyvs;
- yytype_int16 *yyss1 = yyss;
-
-
- /* Each stack pointer address is followed by the size of the
- data in use in that stack, in bytes. This used to be a
- conditional around just the two extra args, but that might
- be undefined if yyoverflow is a macro. */
- yyoverflow (YY_("memory exhausted"),
- &yyss1, yysize * sizeof (*yyssp),
- &yyvs1, yysize * sizeof (*yyvsp),
-
- &yystacksize);
-
- yyss = yyss1;
- yyvs = yyvs1;
- }
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyexhaustedlab;
-# else
- /* Extend the stack our own way. */
- if (YYMAXDEPTH <= yystacksize)
- goto yyexhaustedlab;
- yystacksize *= 2;
- if (YYMAXDEPTH < yystacksize)
- yystacksize = YYMAXDEPTH;
-
- {
- yytype_int16 *yyss1 = yyss;
- union yyalloc *yyptr =
- (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
- if (! yyptr)
- goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss);
- YYSTACK_RELOCATE (yyvs);
-
-# undef YYSTACK_RELOCATE
- if (yyss1 != yyssa)
- YYSTACK_FREE (yyss1);
- }
-# endif
-#endif /* no yyoverflow */
-
- yyssp = yyss + yysize - 1;
- yyvsp = yyvs + yysize - 1;
-
-
- YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
-
- if (yyss + yystacksize - 1 <= yyssp)
- YYABORT;
- }
-
- YYDPRINTF ((stderr, "Entering state %d\n", yystate));
-
- goto yybackup;
-
-/*-----------.
-| yybackup. |
-`-----------*/
-yybackup:
-
- /* Do appropriate processing given the current state. Read a
- look-ahead token if we need one and don't already have one. */
-
- /* First try to decide what to do without reference to look-ahead token. */
- yyn = yypact[yystate];
- if (yyn == YYPACT_NINF)
- goto yydefault;
-
- /* Not known => get a look-ahead token if don't already have one. */
-
- /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
- if (yychar == YYEMPTY)
- {
- YYDPRINTF ((stderr, "Reading a token: "));
- yychar = YYLEX;
- }
-
- if (yychar <= YYEOF)
- {
- yychar = yytoken = YYEOF;
- YYDPRINTF ((stderr, "Now at end of input.\n"));
- }
- else
- {
- yytoken = YYTRANSLATE (yychar);
- YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
- }
-
- /* If the proper action on seeing token YYTOKEN is to reduce or to
- detect an error, take that action. */
- yyn += yytoken;
- if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
- goto yydefault;
- yyn = yytable[yyn];
- if (yyn <= 0)
- {
- if (yyn == 0 || yyn == YYTABLE_NINF)
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
- }
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- /* Count tokens shifted since error; after three, turn off error
- status. */
- if (yyerrstatus)
- yyerrstatus--;
-
- /* Shift the look-ahead token. */
- YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
-
- /* Discard the shifted token unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
-
- yystate = yyn;
- *++yyvsp = yylval;
-
- goto yynewstate;
-
-
-/*-----------------------------------------------------------.
-| yydefault -- do the default action for the current state. |
-`-----------------------------------------------------------*/
-yydefault:
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
- goto yyreduce;
-
-
-/*-----------------------------.
-| yyreduce -- Do a reduction. |
-`-----------------------------*/
-yyreduce:
- /* yyn is the number of a rule to reduce with. */
- yylen = yyr2[yyn];
-
- /* If YYLEN is nonzero, implement the default value of the action:
- `$$ = $1'.
-
- Otherwise, the following line sets YYVAL to garbage.
- This behavior is undocumented and Bison
- users should not rely upon it. Assigning to YYVAL
- unconditionally makes the parser a bit smaller, and it avoids a
- GCC warning that YYVAL may be used uninitialized. */
- yyval = yyvsp[1-yylen];
-
-
- YY_REDUCE_PRINT (yyn);
- switch (yyn)
- {
- case 2:
-#line 163 "parser.y"
- { printf("empty\n"); ;}
- break;
-
- case 3:
-#line 164 "parser.y"
- { printf("%s", (yyval.strval)); ;}
- break;
-
- case 4:
-#line 167 "parser.y"
- { (yyval.strval) = concatenate((yyvsp[(1) - (2)].strval), (yyvsp[(2) - (2)].strval)); ;}
- break;
-
- case 5:
-#line 168 "parser.y"
- { (yyval.strval) = (yyvsp[(1) - (1)].strval); ;}
- break;
-
- case 7:
-#line 172 "parser.y"
- {
- char* collapsable = collapsableBlock((yyvsp[(2) - (3)].strval));
- (yyval.strval) = concatenate("{", collapsable);
- (yyval.strval) = concatenate((yyval.strval), "}");
- ;}
- break;
-
- case 8:
-#line 177 "parser.y"
- { (yyval.strval) = concatenate("{", "}"); ;}
- break;
-
- case 9:
-#line 181 "parser.y"
- { (yyval.strval) = concatenate((yyvsp[(1) - (2)].strval), (yyvsp[(2) - (2)].strval)); ;}
- break;
-
- case 10:
-#line 182 "parser.y"
- { (yyval.strval) = (yyvsp[(1) - (1)].strval); ;}
- break;
-
- case 11:
-#line 185 "parser.y"
- { (yyval.strval) = stylize((yyvsp[(1) - (1)].strval), "number"); ;}
- break;
-
- case 12:
-#line 186 "parser.y"
- { (yyval.strval) = stylize((yyvsp[(1) - (1)].strval), "keyword"); ;}
- break;
-
- case 13:
-#line 187 "parser.y"
- { (yyval.strval) = stylize((yyvsp[(1) - (1)].strval), "string"); ;}
- break;
-
- case 14:
-#line 188 "parser.y"
- { (yyval.strval) = stylize((yyvsp[(1) - (1)].strval), "string"); ;}
- break;
-
- case 15:
-#line 189 "parser.y"
- { (yyval.strval) = stylize((yyvsp[(1) - (1)].strval), "identifier"); ;}
- break;
-
- case 16:
-#line 190 "parser.y"
- { (yyval.strval) = stylize((yyvsp[(1) - (1)].strval), "operator"); ;}
- break;
-
- case 17:
-#line 191 "parser.y"
- { (yyval.strval) = (yyvsp[(1) - (1)].strval); ;}
- break;
-
- case 18:
-#line 192 "parser.y"
- { (yyval.strval) = (yyvsp[(1) - (1)].strval) ;}
- break;
-
-
-/* Line 1267 of yacc.c. */
-#line 1563 "parser.tab.c"
- default: break;
- }
- YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
-
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
-
- *++yyvsp = yyval;
-
-
- /* Now `shift' the result of the reduction. Determine what state
- that goes to, based on the state we popped back to and the rule
- number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
-
- goto yynewstate;
-
-
-/*------------------------------------.
-| yyerrlab -- here on detecting error |
-`------------------------------------*/
-yyerrlab:
- /* If not already recovering from an error, report this error. */
- if (!yyerrstatus)
- {
- ++yynerrs;
-#if ! YYERROR_VERBOSE
- yyerror (YY_("syntax error"));
-#else
- {
- YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
- if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
- {
- YYSIZE_T yyalloc = 2 * yysize;
- if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
- yyalloc = YYSTACK_ALLOC_MAXIMUM;
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
- yymsg = (char *) YYSTACK_ALLOC (yyalloc);
- if (yymsg)
- yymsg_alloc = yyalloc;
- else
- {
- yymsg = yymsgbuf;
- yymsg_alloc = sizeof yymsgbuf;
- }
- }
-
- if (0 < yysize && yysize <= yymsg_alloc)
- {
- (void) yysyntax_error (yymsg, yystate, yychar);
- yyerror (yymsg);
- }
- else
- {
- yyerror (YY_("syntax error"));
- if (yysize != 0)
- goto yyexhaustedlab;
- }
- }
-#endif
- }
-
-
-
- if (yyerrstatus == 3)
- {
- /* If just tried and failed to reuse look-ahead token after an
- error, discard it. */
-
- if (yychar <= YYEOF)
- {
- /* Return failure if at end of input. */
- if (yychar == YYEOF)
- YYABORT;
- }
- else
- {
- yydestruct ("Error: discarding",
- yytoken, &yylval);
- yychar = YYEMPTY;
- }
- }
-
- /* Else will try to reuse look-ahead token after shifting the error
- token. */
- goto yyerrlab1;
-
-
-/*---------------------------------------------------.
-| yyerrorlab -- error raised explicitly by YYERROR. |
-`---------------------------------------------------*/
-yyerrorlab:
-
- /* Pacify compilers like GCC when the user code never invokes
- YYERROR and the label yyerrorlab therefore never appears in user
- code. */
- if (/*CONSTCOND*/ 0)
- goto yyerrorlab;
-
- /* Do not reclaim the symbols of the rule which action triggered
- this YYERROR. */
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
- yystate = *yyssp;
- goto yyerrlab1;
-
-
-/*-------------------------------------------------------------.
-| yyerrlab1 -- common code for both syntax error and YYERROR. |
-`-------------------------------------------------------------*/
-yyerrlab1:
- yyerrstatus = 3; /* Each real token shifted decrements this. */
-
- for (;;)
- {
- yyn = yypact[yystate];
- if (yyn != YYPACT_NINF)
- {
- yyn += YYTERROR;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
- {
- yyn = yytable[yyn];
- if (0 < yyn)
- break;
- }
- }
-
- /* Pop the current state because it cannot handle the error token. */
- if (yyssp == yyss)
- YYABORT;
-
-
- yydestruct ("Error: popping",
- yystos[yystate], yyvsp);
- YYPOPSTACK (1);
- yystate = *yyssp;
- YY_STACK_PRINT (yyss, yyssp);
- }
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- *++yyvsp = yylval;
-
-
- /* Shift the error token. */
- YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
-
- yystate = yyn;
- goto yynewstate;
-
-
-/*-------------------------------------.
-| yyacceptlab -- YYACCEPT comes here. |
-`-------------------------------------*/
-yyacceptlab:
- yyresult = 0;
- goto yyreturn;
-
-/*-----------------------------------.
-| yyabortlab -- YYABORT comes here. |
-`-----------------------------------*/
-yyabortlab:
- yyresult = 1;
- goto yyreturn;
-
-#ifndef yyoverflow
-/*-------------------------------------------------.
-| yyexhaustedlab -- memory exhaustion comes here. |
-`-------------------------------------------------*/
-yyexhaustedlab:
- yyerror (YY_("memory exhausted"));
- yyresult = 2;
- /* Fall through. */
-#endif
-
-yyreturn:
- if (yychar != YYEOF && yychar != YYEMPTY)
- yydestruct ("Cleanup: discarding lookahead",
- yytoken, &yylval);
- /* Do not reclaim the symbols of the rule which action triggered
- this YYABORT or YYACCEPT. */
- YYPOPSTACK (yylen);
- YY_STACK_PRINT (yyss, yyssp);
- while (yyssp != yyss)
- {
- yydestruct ("Cleanup: popping",
- yystos[*yyssp], yyvsp);
- YYPOPSTACK (1);
- }
-#ifndef yyoverflow
- if (yyss != yyssa)
- YYSTACK_FREE (yyss);
-#endif
-#if YYERROR_VERBOSE
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
-#endif
- /* Make sure YYID is used. */
- return YYID (yyresult);
-}
-
-
-#line 195 "parser.y"
-
-
-int yyerror(const char* error)
-{
- extern int current_line;
- fprintf(stderr, "input:%d: error: %s\n", current_line, error);
- return 0;
-}
-
-
-void printHtmlHeader() {
- puts(
- "<head>"
- " <title>hello_world.go</title>"
- );
- printStyles();
- puts(
- "</head>"
- );
-}
-
-
-
-void printBody() {
- puts(
- "<body bgcolor=\"#e2cdb7\">"
- " <pre class=\"code\">"
- );
- yyparse();
- puts("</pre></body>");
-}
-
-void printHTML() {
- puts(
- "<!doctype>"
- "<html>"
- );
- printHtmlHeader();
- printBody();
- printCollapsableScript();
- puts("</html>");
-}
-
-
-int main(int argc, const char* argv[])
-{
- printHTML();
- return 0;
-}
-
diff --git a/homework/81319/golang2html_code_fold/parser.tab.h b/homework/81319/golang2html_code_fold/parser.tab.h
deleted file mode 100644
index d04ac31..0000000
--- a/homework/81319/golang2html_code_fold/parser.tab.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* A Bison parser, made by GNU Bison 2.3. */
-
-/* Skeleton interface for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- NUMBER = 258,
- KEYWORD = 259,
- STRING = 260,
- STRING_DQ = 261,
- IDENTIFIER = 262,
- OPERATOR = 263,
- MISC = 264,
- UNRECOGNIZED = 265,
- LCURLY = 266,
- RCURLY = 267
- };
-#endif
-/* Tokens. */
-#define NUMBER 258
-#define KEYWORD 259
-#define STRING 260
-#define STRING_DQ 261
-#define IDENTIFIER 262
-#define OPERATOR 263
-#define MISC 264
-#define UNRECOGNIZED 265
-#define LCURLY 266
-#define RCURLY 267
-
-
-
-
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE
-#line 154 "parser.y"
-{
- char* strval;
-}
-/* Line 1529 of yacc.c. */
-#line 77 "parser.tab.h"
- YYSTYPE;
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
-#endif
-
-extern YYSTYPE yylval;
-
diff --git a/homework/81319/golang2html_code_fold/parser.y b/homework/81319/golang2html_code_fold/parser.y
deleted file mode 100644
index fcd4834..0000000
--- a/homework/81319/golang2html_code_fold/parser.y
+++ /dev/null
@@ -1,243 +0,0 @@
-%{
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-int yylex();
-int yyerror(const char* error);
-#define YYDEBUG 1
-
-char* concatenate(char* first, char* second) {
- int firstlen = strlen(first);
- int secondlen = strlen(second);
- char* result;
- result = malloc(firstlen + secondlen + 1);
- strcpy(result, first);
- strcat(result, second);
-
- return result;
-}
-
-void printStyles() {
- puts(
- " <style>"
- " .identifier {"
- " color: brown;"
- " }"
- " .keyword {"
- " color: #1fbfe2;"
- " }"
- " .number {"
- " color: blue;"
- " }"
- " .string {"
- " color: green;"
- " }"
- " .operator {"
- " color: #db184c;"
- " font-style: bold;"
- " }"
- " .collapsible {"
- " background-color: #777;"
- " color: white;"
- " cursor: pointer;"
- " padding: 2px;"
- " width: 2%;"
- " border: none;"
- " text-align: center;"
- " outline: none;"
- " font-size: 15px;"
- " }"
-
- " .active, .collapsible:hover {"
- " background-color: #555;"
- " }"
-
-
- " </style>"
- );
-}
-
-void printCollapsableScript() {
- puts(
- "<script>"
- "var coll = document.getElementsByClassName(\"collapsible\");\n"
- "var i;\n"
- "\n"
- "for (i = 0; i < coll.length; i++) {\n"
- "coll[i].addEventListener(\"click\", function() {\n"
- "this.classList.toggle(\"active\");\n"
- "var content = this.nextElementSibling;\n"
- "if (content.style.display === \"block\") {\n"
- "content.style.display = \"none\";\n"
- "this.innerHTML=\"+\""
- "} else {\n"
- "content.style.display = \"block\";\n"
- "this.innerHTML=\"-\""
- "}\n"
- "});\n"
- "}\n"
- "</script>"
- );
-}
-
-char* stylize(char* text, char* style) {
- char* result = concatenate("<span class=\"", style);
- result = concatenate(result, "\">");
- result = concatenate(result, text);
- result = concatenate(result, "</span>");
-
- return result;
-}
-
-char* collapsableBlock(char* text) {
- char* result = concatenate("<button class=\"collapsible\">+</button>", "<div class=\"content\">");
- result = concatenate(result, text);
- result = concatenate(result, "</div>");
-
- return result;
-}
-
-void printNumber(char* text) {
- char* style = stylize(text, "number");
- printf("%s", style);
-}
-
-
-void printIdentifier(char* text) {
- char* style = stylize(text, "identifier");
- printf("%s", style);
-}
-
-void printKeyword(char* text) {
- char* style = stylize(text, "keyword");
- printf("%s", style);
-}
-
-void printString(char* text) {
- char* style = stylize(text, "string");
- printf("%s", style);
-}
-
-void printOperator(char* text) {
- char* style = stylize(text, "operator");
- printf("%s", style);
-}
-
-void printMisc(char* text) {
- printf("%s", text);
-}
-
-void printUnrecognized(char* text) {
- printf("Unrecognized token: %s", text);
-}
-
-void printBraces(char* text) {
- printf("%s", text);
-}
-
-%}
-
-%start input
-
-
-%token NUMBER
-%token KEYWORD
-%token STRING
-%token STRING_DQ
-%token IDENTIFIER
-%token OPERATOR
-%token MISC
-%token UNRECOGNIZED
-%token LCURLY
-%token RCURLY
-
-%union {
- char* strval;
-}
-
-%type <strval> input expr_list expr token_sequence token NUMBER KEYWORD STRING STRING_DQ IDENTIFIER OPERATOR MISC UNRECOGNIZED LCURLY RCURLY
-
-
-%%
-
-input: /* empty */ { printf("empty\n"); }
- | expr_list { printf("%s", $$); }
- ;
-
-expr_list: expr expr_list { $$ = concatenate($1, $2); }
- | expr { $$ = $1; }
- ;
-
-expr: token_sequence
- | LCURLY expr_list RCURLY {
- char* collapsable = collapsableBlock($2);
- $$ = concatenate("{", collapsable);
- $$ = concatenate($$, "}");
- }
- | LCURLY RCURLY { $$ = concatenate("{", "}"); }
- ;
-
-
-token_sequence: token_sequence token { $$ = concatenate($1, $2); }
- | token { $$ = $1; }
- ;
-
-token: NUMBER { $$ = stylize($1, "number"); }
- | KEYWORD { $$ = stylize($1, "keyword"); }
- | STRING { $$ = stylize($1, "string"); }
- | STRING_DQ { $$ = stylize($1, "string"); }
- | IDENTIFIER { $$ = stylize($1, "identifier"); }
- | OPERATOR { $$ = stylize($1, "operator"); }
- | MISC { $$ = $1; }
- | UNRECOGNIZED { $$ = $1 }
- ;
-
-%%
-
-int yyerror(const char* error)
-{
- extern int current_line;
- fprintf(stderr, "input:%d: error: %s\n", current_line, error);
- return 0;
-}
-
-
-void printHtmlHeader() {
- puts(
- "<head>"
- " <title>hello_world.go</title>"
- );
- printStyles();
- puts(
- "</head>"
- );
-}
-
-
-
-void printBody() {
- puts(
- "<body bgcolor=\"#e2cdb7\">"
- " <pre class=\"code\">"
- );
- yyparse();
- puts("</pre></body>");
-}
-
-void printHTML() {
- puts(
- "<!doctype>"
- "<html>"
- );
- printHtmlHeader();
- printBody();
- printCollapsableScript();
- puts("</html>");
-}
-
-
-int main(int argc, const char* argv[])
-{
- printHTML();
- return 0;
-}
diff --git a/homework/81319/golang2html_code_fold/stylize.sh b/homework/81319/golang2html_code_fold/stylize.sh
deleted file mode 100755
index 8ba3030..0000000
--- a/homework/81319/golang2html_code_fold/stylize.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env bash
-cat input.go | ./parser > output.html
-open output.html \ No newline at end of file
diff --git a/homework/81333/brainfsck/.gitignore b/homework/81333/brainfsck/.gitignore
deleted file mode 100644
index c8db66d..0000000
--- a/homework/81333/brainfsck/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.stack-work/
-brainfsck.cabal
-*~ \ No newline at end of file
diff --git a/homework/81333/brainfsck/ChangeLog.md b/homework/81333/brainfsck/ChangeLog.md
deleted file mode 100644
index 76c7fe5..0000000
--- a/homework/81333/brainfsck/ChangeLog.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Changelog for brainfsck
-
-## Unreleased changes
diff --git a/homework/81333/brainfsck/LICENSE b/homework/81333/brainfsck/LICENSE
deleted file mode 100644
index c29d4ee..0000000
--- a/homework/81333/brainfsck/LICENSE
+++ /dev/null
@@ -1,232 +0,0 @@
-Copyright Author name here (c) 2018
-
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
- * Neither the name of Author name here nor the names of other
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-=======
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/homework/81333/brainfsck/README.md b/homework/81333/brainfsck/README.md
deleted file mode 100644
index f9ef70c..0000000
--- a/homework/81333/brainfsck/README.md
+++ /dev/null
@@ -1,28 +0,0 @@
-# Brainfsck interpreter
-
-# How to build
-
-Install [stack](https://docs.haskellstack.org/en/stable/README/) build tool
-
-Run following commands from root of project:
-
-Building:
-
-```
-stack build
-```
-
-Executing:
-
-```
-stack exec brainfsck <file_with_code>
-```
-
-# Examples
-
-Examples are in `examples/` folder.
-
-Best ones are:
-
-* `stack exec brainfsck examples/sierpinski.bf` - outputs sierpinski triangle
-* `echo 0123456789 | stack exec brainfsck examples/pretty.bf` - pretty prints numbers
diff --git a/homework/81333/brainfsck/Setup.hs b/homework/81333/brainfsck/Setup.hs
deleted file mode 100644
index 9a994af..0000000
--- a/homework/81333/brainfsck/Setup.hs
+++ /dev/null
@@ -1,2 +0,0 @@
-import Distribution.Simple
-main = defaultMain
diff --git a/homework/81333/brainfsck/app/Main.hs b/homework/81333/brainfsck/app/Main.hs
deleted file mode 100644
index a45882e..0000000
--- a/homework/81333/brainfsck/app/Main.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-
-module Main where
-
-import System.Environment (getArgs)
-
-import qualified Data.ByteString.Char8 as B
-
-import Lib (blocks)
-
-import Text.Brainfsck.Parser (parseText)
-import Text.Brainfsck.Types
-
-main :: IO ()
-main = do
- args <- getArgs
- case args of
- [] -> putStrLn "Usage: stack exec brainfsck-exe <file_with_code>"
- _ -> do
- code <- B.readFile $ args !! 0
- result <- blocks newBlocks $ parseText code
- B.putStrLn $ r result
diff --git a/homework/81333/brainfsck/brainfsck.cabal b/homework/81333/brainfsck/brainfsck.cabal
deleted file mode 100644
index 45f2ba4..0000000
--- a/homework/81333/brainfsck/brainfsck.cabal
+++ /dev/null
@@ -1,74 +0,0 @@
-cabal-version: 1.12
-
--- This file has been generated from package.yaml by hpack version 0.31.1.
---
--- see: https://github.com/sol/hpack
---
--- hash: 6e461fb9377fd9d13efd7b8e322e93ae789d4e0f77c88584498db65aa15f75ea
-
-name: brainfsck
-version: 0.1.0.0
-description: Please see the README on GitHub at <https://github.com/githubuser/brainfsck#readme>
-homepage: https://github.com/githubuser/brainfsck#readme
-bug-reports: https://github.com/githubuser/brainfsck/issues
-author: Author name here
-maintainer: example@example.com
-copyright: 2018 Author name here
-license: BSD3
-license-file: LICENSE
-build-type: Simple
-extra-source-files:
- README.md
- ChangeLog.md
-
-source-repository head
- type: git
- location: https://github.com/githubuser/brainfsck
-
-library
- exposed-modules:
- Lib
- Text.Brainfsck.Parser
- Text.Brainfsck.Types
- Text.Brainfsck.Util
- other-modules:
- Paths_brainfsck
- hs-source-dirs:
- src
- build-depends:
- attoparsec
- , base >=4.7 && <5
- , bytestring
- , haskeline
- default-language: Haskell2010
-
-executable brainfsck
- main-is: Main.hs
- other-modules:
- Paths_brainfsck
- hs-source-dirs:
- app
- ghc-options: -threaded -rtsopts -with-rtsopts=-N
- build-depends:
- attoparsec
- , base >=4.7 && <5
- , brainfsck
- , bytestring
- , haskeline
- default-language: Haskell2010
-
-test-suite brainfsck-test
- type: exitcode-stdio-1.0
- main-is: Spec.hs
- other-modules:
- Paths_brainfsck
- hs-source-dirs:
- test
- ghc-options: -threaded -rtsopts -with-rtsopts=-N
- build-depends:
- attoparsec
- , base >=4.7 && <5
- , brainfsck
- , bytestring
- , haskeline
- default-language: Haskell2010
diff --git a/homework/81333/brainfsck/examples/fact.bf b/homework/81333/brainfsck/examples/fact.bf
deleted file mode 100644
index 197f331..0000000
--- a/homework/81333/brainfsck/examples/fact.bf
+++ /dev/null
@@ -1,42 +0,0 @@
-+++++++++++++++++++++++++++++++++ c1v33 : ASCII code of !
->++++++++++++++++++++++++++++++
-+++++++++++++++++++++++++++++++ c2v61 : ASCII code of =
->++++++++++ c3v10 : ASCII code of EOL
->+++++++ c4v7 : quantity of numbers to be calculated
-> c5v0 : current number (one digit)
->+ c6v1 : current value of factorial (up to three digits)
-<< c4 : loop counter
-[ block : loop to print one line and calculate next
->++++++++++++++++++++++++++++++++++++++++++++++++. c5 : print current number
------------------------------------------------- c5 : back from ASCII to number
-<<<<.-.>.<.+ c1 : print !_=_
-
->>>>> block : print c6 (preserve it)
-> c7v0 : service zero
->++++++++++ c8v10 : divizor
-<< c6 : back to dividend
-[->+>-[>+>>]>[+[-<+>]>+>>]<<<<<<] c6v0 : divmod algo borrowed from esolangs; results in 0 n d_n%d n%d n/d
->[<+>-] c6 : move dividend back to c6 and clear c7
->[-] c8v0 : clear c8
-
->> block : c10 can have two digits; divide it by ten again
->++++++++++ c11v10: divizor
-< c10 : back to dividend
-[->-[>+>>]>[+[-<+>]>+>>]<<<<<] c10v0 : another divmod algo borrowed from esolangs; results in 0 d_n%d n%d n/d
->[-] c11v0 : clear c11
->>[++++++++++++++++++++++++++++++++++++++++++++++++.[-]]c13v0 : print nonzero n/d (first digit) and clear c13
-<[++++++++++++++++++++++++++++++++++++++++++++++++.[-]] c12v0 : print nonzero n%d (second digit) and clear c12
-<<<++++++++++++++++++++++++++++++++++++++++++++++++.[-] c9v0 : print any n%d (last digit) and clear c9
-
-<<<<<<. c3 : EOL
->>+ c5 : increment current number
- block : multiply c6 by c5 (don't preserve c6)
->[>>+<<-] c6v0 : move c6 to c8
->> c8v0 : repeat c8 times
-[
-<<<[>+>+<<-] c5v0 : move c5 to c6 and c7
->>[<<+>>-] c7v0 : move c7 back to c5
->-
-]
-<<<<- c4 : decrement loop counter
-]
diff --git a/homework/81333/brainfsck/examples/hello.bf b/homework/81333/brainfsck/examples/hello.bf
deleted file mode 100644
index 273b209..0000000
--- a/homework/81333/brainfsck/examples/hello.bf
+++ /dev/null
@@ -1,3 +0,0 @@
->+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]
->++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++
-.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.
diff --git a/homework/81333/brainfsck/examples/input.bf b/homework/81333/brainfsck/examples/input.bf
deleted file mode 100644
index 12597fc..0000000
--- a/homework/81333/brainfsck/examples/input.bf
+++ /dev/null
@@ -1,13 +0,0 @@
-> +
-[ - >,>+<
- ----- ----- ; minus 10
- [ ; if enters means it is not a \n
- +++++ +++++ ; restore prev value
- <
- ] >> ; moving forward
-]
- ; numbers are 0 0 49 0 50 0 51
- ; for input 123
-<<<<[<<] ; moving to the beginning
->> ; reaching first char
-[.>>] ; just printing till end
diff --git a/homework/81333/brainfsck/examples/pretty.bf b/homework/81333/brainfsck/examples/pretty.bf
deleted file mode 100644
index 069aa4d..0000000
--- a/homework/81333/brainfsck/examples/pretty.bf
+++ /dev/null
@@ -1,31 +0,0 @@
->>>>+>+++>+++>>>>>+++[
- >,+>++++[>++++<-]>[<<[-[->]]>[<]>-]<<[
- >+>+>>+>+[<<<<]<+>>[+<]<[>]>+[[>>>]>>+[<<<<]>-]+<+>>>-[
- <<+[>]>>+<<<+<+<--------[
- <<-<<+[>]>+<<-<<-[
- <<<+<-[>>]<-<-<<<-<----[
- <<<->>>>+<-[
- <<<+[>]>+<<+<-<-[
- <<+<-<+[>>]<+<<<<+<-[
- <<-[>]>>-<<<-<-<-[
- <<<+<-[>>]<+<<<+<+<-[
- <<<<+[>]<-<<-[
- <<+[>]>>-<<<<-<-[
- >>>>>+<-<<<+<-[
- >>+<<-[
- <<-<-[>]>+<<-<-<-[
- <<+<+[>]<+<+<-[
- >>-<-<-[
- <<-[>]<+<++++[<-------->-]++<[
- <<+[>]>>-<-<<<<-[
- <<-<<->>>>-[
- <<<<+[>]>+<<<<-[
- <<+<<-[>>]<+<<<<<-[
- >>>>-<<<-<-
- ]]]]]]]]]]]]]]]]]]]]]]>[>[[[<<<<]>+>>[>>>>>]<-]<]>>>+>>>>>>>+>]<
-]<[-]<<<<<<<++<+++<+++[
- [>]>>>>>>++++++++[<<++++>++++++>-]<-<<[-[<+>>.<-]]<<<<[
- -[-[>+<-]>]>>>>>[.[>]]<<[<+>-]>>>[<<++[<+>--]>>-]
- <<[->+<[<++>-]]<<<[<+>-]<<<<
- ]>>+>>>--[<+>---]<.>>[[-]<<]<
-]
diff --git a/homework/81333/brainfsck/examples/sierpinski.bf b/homework/81333/brainfsck/examples/sierpinski.bf
deleted file mode 100644
index 4c66685..0000000
--- a/homework/81333/brainfsck/examples/sierpinski.bf
+++ /dev/null
@@ -1,5 +0,0 @@
-++++++++[>+>++++<<-]>++>>+<[-[>>+<<-]+>>]>+[
- -<<<[
- ->[+[-]+>++>>>-<<]<[<]>>++++++[<<+++++>>-]+<<++.[-]<<
- ]>.>+[>>]>+
-]
diff --git a/homework/81333/brainfsck/examples/squares.bf b/homework/81333/brainfsck/examples/squares.bf
deleted file mode 100644
index fa0a6f8..0000000
--- a/homework/81333/brainfsck/examples/squares.bf
+++ /dev/null
@@ -1,5 +0,0 @@
-++++[>+++++<-]>[<+++++>-]+<+[
- >[>+>+<<-]++>>[<<+>>-]>>>[-]++>[-]+
- >>>+[[-]++++++>>>]<<<[[<++++++++<++>>-]+<.<[>----<-]<]
- <<[>>>>>[>>>[-]+++++++++<[>-<-]+++++++++>[-[<->-]+[<<<]]<[>+<-]>]<<-]<<-
-]
diff --git a/homework/81333/brainfsck/examples/sum.bf b/homework/81333/brainfsck/examples/sum.bf
deleted file mode 100644
index df694ec..0000000
--- a/homework/81333/brainfsck/examples/sum.bf
+++ /dev/null
@@ -1,100 +0,0 @@
-[
- A brainfuck program for doing a single digit addition.
-
- Ex. input: '13' -> output: '4'
- input: '99' -> output: '18'
-
- Author: Florian Baierl
-]
-
-initialize #0 with 48 (ASCII char for '0')
->++++ ++++
-[
-<++++ ++
->-
-]
-
-save input to #1 and #2
-,>,
-
-substract value from #0 from #1 and #2
-<<
-[
->-
->-
-<<-
-]
-
-move to #1
->
-
-substract from #1 and add to #2; now the answer is in #2
-[
- ->+<
-]
-
-since we need to modify the answer afterwards write it to #3 and #6
-as well
->
-[>+>>>+<<<<-]
-
-
-Is the answer bigger than 9?
-to continue the memory tape should look like this:
-0 1 0 (a) b 0
-with the pointer pointing to a
-
-<+
->>>+++++ +++++ b is 10
-< point to a
-
-+>+< necessary in case a and b are zero
-
-loop to determine whether a or b reach 0 first
-[->-[>]<<]
-
-<[-
- a was bigger or equals b
- the answer is still stored in #6
-
- subtract 10 from #6 (the answer)
- >>>>> ----- -----
-
- write 48 to #4
- <++++ ++++
- [
- <++++ ++
- >-
- ]
- add 48 to #5 and #6
- <
- [->+>+<<]
-
- print out the results
- >+.>.
-
- leave loop (back to #2)
- <<<<
- ]
- <[-
- a was samller so we can simply print the answer out after adding 48 to it
- the answer is still stored in #6
-
- >>
- ++++ ++++
- [
- <++++ ++
- >-
- ]
-
- <
- [
- ->>>>+<<<<
- ]
-
- print #2
- >>>>.
-
- we want to leave the loop so go somewhere with the value '0'
- >
-]
diff --git a/homework/81333/brainfsck/package.yaml b/homework/81333/brainfsck/package.yaml
deleted file mode 100644
index 44043aa..0000000
--- a/homework/81333/brainfsck/package.yaml
+++ /dev/null
@@ -1,51 +0,0 @@
-name: brainfsck
-version: 0.1.0.0
-github: "githubuser/brainfsck"
-license: BSD3
-author: "Author name here"
-maintainer: "example@example.com"
-copyright: "2018 Author name here"
-
-extra-source-files:
-- README.md
-- ChangeLog.md
-
-# Metadata used when publishing your package
-# synopsis: Short description of your package
-# category: Web
-
-# To avoid duplicated efforts in documentation and dealing with the
-# complications of embedding Haddock markup inside cabal files, it is
-# common to point users to the README.md file.
-description: Please see the README on GitHub at <https://github.com/githubuser/brainfsck#readme>
-
-dependencies:
-- base >= 4.7 && < 5
-- attoparsec
-- bytestring
-- haskeline
-
-library:
- source-dirs: src
-
-executables:
- brainfsck:
- main: Main.hs
- source-dirs: app
- ghc-options:
- - -threaded
- - -rtsopts
- - -with-rtsopts=-N
- dependencies:
- - brainfsck
-
-tests:
- brainfsck-test:
- main: Spec.hs
- source-dirs: test
- ghc-options:
- - -threaded
- - -rtsopts
- - -with-rtsopts=-N
- dependencies:
- - brainfsck
diff --git a/homework/81333/brainfsck/src/Lib.hs b/homework/81333/brainfsck/src/Lib.hs
deleted file mode 100644
index e4cc95c..0000000
--- a/homework/81333/brainfsck/src/Lib.hs
+++ /dev/null
@@ -1,30 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-
-module Lib
- ( blocks
- ) where
-
-import Data.Attoparsec.ByteString.Char8
-import qualified Data.ByteString.Char8 as B
-
-import Data.Char
-import Text.Brainfsck.Types
-import Text.Brainfsck.Util
-
-blocks :: Blocks -> [BFExpr] -> IO Blocks
-blocks b [] = pure b
-blocks (Blocks h b r) (BFRight:es) = blocks (Blocks (h + 1) b r) es
-blocks (Blocks h b r) (BFLeft:es) = blocks (Blocks (max (h - 1) 0) b r) es
-blocks (Blocks h b r) (BFPlus:es) = blocks (Blocks h (inc b h) r) es
-blocks (Blocks h b r) (BFMinus:es) = blocks (Blocks h (dec b h) r) es
-blocks (Blocks h b r) (BFPut:es) =
- blocks (Blocks h b (r <> B.singleton (chr $ b !! h))) es
-blocks (Blocks h b r) (BFGet:es) = do
- v <- getChar
- blocks (Blocks h (load b h $ ord v) r) es
-blocks current@(Blocks h b r) (BFLoop expr:es) = do
- if b !! h == 0
- then blocks current es
- else do
- newBlocks <- blocks current expr
- blocks newBlocks ((BFLoop expr) : es)
diff --git a/homework/81333/brainfsck/src/Text/Brainfsck/Parser.hs b/homework/81333/brainfsck/src/Text/Brainfsck/Parser.hs
deleted file mode 100644
index 28c019a..0000000
--- a/homework/81333/brainfsck/src/Text/Brainfsck/Parser.hs
+++ /dev/null
@@ -1,56 +0,0 @@
-module Text.Brainfsck.Parser
- ( parseText
- ) where
-
-import Control.Applicative
-
-import Data.Attoparsec.ByteString.Char8
-import qualified Data.ByteString.Char8 as B
-import Data.Either (fromRight)
-
-import Text.Brainfsck.Types
-
-goRight :: Parser BFExpr
-goRight = do
- char '>'
- pure BFRight
-
-goLeft :: Parser BFExpr
-goLeft = do
- char '<'
- pure BFLeft
-
-plus :: Parser BFExpr
-plus = do
- char '+'
- pure BFPlus
-
-minus :: Parser BFExpr
-minus = do
- char '-'
- pure BFMinus
-
-get :: Parser BFExpr
-get = do
- char ','
- pure BFGet
-
-put :: Parser BFExpr
-put = do
- char '.'
- pure BFPut
-
-bfsymbol :: Parser BFExpr
-bfsymbol = goRight <|> goLeft <|> plus <|> minus <|> get <|> put <|> loop
-
-loop :: Parser BFExpr
-loop = do
- char '['
- m <- many' bfsymbol
- char ']'
- pure $ BFLoop m
-
-parseText :: B.ByteString -> [BFExpr]
-parseText s =
- fromRight [] $
- parseOnly (many' bfsymbol) $ B.filter ((flip elem) "+-,.<>[]") s
diff --git a/homework/81333/brainfsck/src/Text/Brainfsck/Types.hs b/homework/81333/brainfsck/src/Text/Brainfsck/Types.hs
deleted file mode 100644
index 5dd26f6..0000000
--- a/homework/81333/brainfsck/src/Text/Brainfsck/Types.hs
+++ /dev/null
@@ -1,24 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-
-module Text.Brainfsck.Types where
-
-import qualified Data.ByteString.Char8 as B
-
-data BFExpr
- = BFRight
- | BFLeft
- | BFPlus
- | BFMinus
- | BFGet
- | BFPut
- | BFLoop [BFExpr]
- deriving (Show)
-
-data Blocks = Blocks
- { h :: Int
- , b :: [Int]
- , r :: B.ByteString
- } deriving (Show)
-
-newBlocks :: Blocks
-newBlocks = Blocks {h = 0, b = [0,0 ..], r = ""}
diff --git a/homework/81333/brainfsck/src/Text/Brainfsck/Util.hs b/homework/81333/brainfsck/src/Text/Brainfsck/Util.hs
deleted file mode 100644
index fb2d5ad..0000000
--- a/homework/81333/brainfsck/src/Text/Brainfsck/Util.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Text.Brainfsck.Util where
-
-inc :: [Int] -> Int -> [Int]
-inc b h = take h b <> [b !! h + 1] <> drop (h + 1) b
-
-dec :: [Int] -> Int -> [Int]
-dec b h = take h b <> [b !! h - 1] <> drop (h + 1) b
-
-load :: [Int] -> Int -> Int -> [Int]
-load b h v = take h b <> [v] <> drop (h + 1) b
diff --git a/homework/81333/brainfsck/stack.yaml b/homework/81333/brainfsck/stack.yaml
deleted file mode 100644
index 6ad76a0..0000000
--- a/homework/81333/brainfsck/stack.yaml
+++ /dev/null
@@ -1,64 +0,0 @@
-# This file was automatically generated by 'stack init'
-#
-# Some commonly used options have been documented as comments in this file.
-# For advanced use and comprehensive documentation of the format, please see:
-# https://docs.haskellstack.org/en/stable/yaml_configuration/
-
-# Resolver to choose a 'specific' stackage snapshot or a compiler version.
-# A snapshot resolver dictates the compiler version and the set of packages
-# to be used for project dependencies. For example:
-#
-# resolver: lts-3.5
-# resolver: nightly-2015-09-21
-# resolver: ghc-7.10.2
-#
-# The location of a snapshot can be provided as a file or url. Stack assumes
-# a snapshot provided as a file might change, whereas a url resource does not.
-#
-# resolver: ./custom-snapshot.yaml
-# resolver: https://example.com/snapshots/2018-01-01.yaml
-resolver: lts-12.18
-
-# User packages to be built.
-# Various formats can be used as shown in the example below.
-#
-# packages:
-# - some-directory
-# - https://example.com/foo/bar/baz-0.0.2.tar.gz
-# - location:
-# git: https://github.com/commercialhaskell/stack.git
-# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
-# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a
-# subdirs:
-# - auto-update
-# - wai
-packages:
-- .
-# Dependency packages to be pulled from upstream that are not in the resolver
-# using the same syntax as the packages field.
-# (e.g., acme-missiles-0.3)
-# extra-deps: []
-
-# Override default flag values for local packages and extra-deps
-# flags: {}
-
-# Extra package databases containing global packages
-# extra-package-dbs: []
-
-# Control whether we use the GHC we find on the path
-# system-ghc: true
-#
-# Require a specific version of stack, using version ranges
-# require-stack-version: -any # Default
-# require-stack-version: ">=1.9"
-#
-# Override the architecture used by stack, especially useful on Windows
-# arch: i386
-# arch: x86_64
-#
-# Extra directories used by stack for building
-# extra-include-dirs: [/path/to/dir]
-# extra-lib-dirs: [/path/to/dir]
-#
-# Allow a newer minor version of GHC than the snapshot specifies
-# compiler-check: newer-minor
diff --git a/homework/81333/brainfsck/test/Spec.hs b/homework/81333/brainfsck/test/Spec.hs
deleted file mode 100644
index cd4753f..0000000
--- a/homework/81333/brainfsck/test/Spec.hs
+++ /dev/null
@@ -1,2 +0,0 @@
-main :: IO ()
-main = putStrLn "Test suite not yet implemented"
diff --git a/homework/81333/golang-highlighter/.gitignore b/homework/81333/golang-highlighter/.gitignore
deleted file mode 100644
index 9cd93b8..0000000
--- a/homework/81333/golang-highlighter/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-# stack files
-.stack-work/
-highlighter.cabal
-*~
-
-# test files
-*.txt
-*.html
diff --git a/homework/81333/golang-highlighter/ChangeLog.md b/homework/81333/golang-highlighter/ChangeLog.md
deleted file mode 100644
index 959500a..0000000
--- a/homework/81333/golang-highlighter/ChangeLog.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Changelog for highlighter
-
-## Unreleased changes
diff --git a/homework/81333/golang-highlighter/LICENSE b/homework/81333/golang-highlighter/LICENSE
deleted file mode 100644
index e037c72..0000000
--- a/homework/81333/golang-highlighter/LICENSE
+++ /dev/null
@@ -1,30 +0,0 @@
-Copyright Author name here (c) 2018
-
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
- * Neither the name of Author name here nor the names of other
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/homework/81333/golang-highlighter/README.md b/homework/81333/golang-highlighter/README.md
deleted file mode 100644
index c2666bf..0000000
--- a/homework/81333/golang-highlighter/README.md
+++ /dev/null
@@ -1,23 +0,0 @@
-# Go2Html Highlighter (WIP)
-
-Library that takes in Go code, passes it through a lexer and outputs it highlighted in an html file
-
-# How to build
-
-Install [stack](https://docs.haskellstack.org/en/stable/README/) build tool
-
-Run following commands from root of project:
-
-Building:
-
-```
-stack build
-```
-
-Executing:
-
-```
-stack exec golangToHtml <file_with_code>
-```
-
-Result will be in `source.html`
diff --git a/homework/81333/golang-highlighter/Setup.hs b/homework/81333/golang-highlighter/Setup.hs
deleted file mode 100644
index 9a994af..0000000
--- a/homework/81333/golang-highlighter/Setup.hs
+++ /dev/null
@@ -1,2 +0,0 @@
-import Distribution.Simple
-main = defaultMain
diff --git a/homework/81333/golang-highlighter/app/Main.hs b/homework/81333/golang-highlighter/app/Main.hs
deleted file mode 100644
index c8e0af7..0000000
--- a/homework/81333/golang-highlighter/app/Main.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-module Main where
-
-import qualified Data.Text.IO as TI
-import System.Environment (getArgs)
-
-import Lib (golangToHtml)
-
-main :: IO ()
-main = do
- args <- getArgs
- case args of
- [] -> putStrLn "Usage: ./golangToHtml <file_with_code>"
- _ -> do
- code <- TI.readFile $ args !! 0
- TI.writeFile "source.html" (golangToHtml code)
- putStrLn "Source written."
diff --git a/homework/81333/golang-highlighter/package.yaml b/homework/81333/golang-highlighter/package.yaml
deleted file mode 100644
index 36995a2..0000000
--- a/homework/81333/golang-highlighter/package.yaml
+++ /dev/null
@@ -1,50 +0,0 @@
-name: highlighter
-version: 0.1.0.0
-github: "githubuser/highlighter"
-license: BSD3
-author: "Author name here"
-maintainer: "example@example.com"
-copyright: "2018 Author name here"
-
-extra-source-files:
-- README.md
-- ChangeLog.md
-
-# Metadata used when publishing your package
-# synopsis: Short description of your package
-# category: Web
-
-# To avoid duplicated efforts in documentation and dealing with the
-# complications of embedding Haddock markup inside cabal files, it is
-# common to point users to the README.md file.
-description: Please see the README on GitHub at <https://github.com/githubuser/highlighter#readme>
-
-dependencies:
-- base >= 4.7 && < 5
-- containers
-- text
-
-library:
- source-dirs: src
-
-executables:
- golangToHtml:
- main: Main.hs
- source-dirs: app
- ghc-options:
- - -threaded
- - -rtsopts
- - -with-rtsopts=-N
- dependencies:
- - highlighter
-
-tests:
- highlighter-test:
- main: Spec.hs
- source-dirs: test
- ghc-options:
- - -threaded
- - -rtsopts
- - -with-rtsopts=-N
- dependencies:
- - highlighter
diff --git a/homework/81333/golang-highlighter/src/Data/Highlighter.hs b/homework/81333/golang-highlighter/src/Data/Highlighter.hs
deleted file mode 100644
index 80921f2..0000000
--- a/homework/81333/golang-highlighter/src/Data/Highlighter.hs
+++ /dev/null
@@ -1,54 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-
-module Data.Highlighter
- ( tokensToHtml
- ) where
-
-import qualified Data.Text as T
-import qualified Data.Text.IO as TI
-
-import Data.Token
-import Data.TokenTypes
-
-initialHtml :: T.Text
-initialHtml =
- T.unlines
- [ "<html>"
- , "<head>"
- , "<style>"
- , ".keyword { color: orange; }"
- , ".comment { color: grey; }"
- , ".preident { color: red; }"
- , ".operator { color: black; }"
- , ".ident { color: blue; }"
- , ".string { color: green; }"
- , ".number { color: purple; }"
- , "</style>"
- , "</head>"
- , "<body>"
- ]
-
-toHtml :: Token -> T.Text
-toHtml (Token {tokenType = Space _, lexeme = lex, location = (line, col)}) = lex
-toHtml (Token {tokenType = Comment _, lexeme = lex, location = (line, col)}) =
- "<span class=comment>" <> lex <> "</span>"
-toHtml (Token {tokenType = Keyword _, lexeme = lex, location = (line, col)}) =
- "<span class=keyword>" <> lex <> "</span>"
-toHtml (Token {tokenType = PredeclIdent _, lexeme = lex, location = (line, col)}) =
- "<span class=preident>" <> lex <> "</span>"
-toHtml (Token {tokenType = Operator _, lexeme = lex, location = (line, col)}) =
- "<span class=operator>" <> lex <> "</span>"
-toHtml (Token {tokenType = Ident _, lexeme = lex, location = (line, col)}) =
- "<span class=ident>" <> lex <> "</span>"
-toHtml (Token { tokenType = Literal (StringLiteral _)
- , lexeme = lex
- , location = (line, col)
- }) = "<span class=string>" <> lex <> "</span>"
-toHtml (Token { tokenType = Literal (Number _)
- , lexeme = lex
- , location = (line, col)
- }) = "<span class=number>" <> lex <> "</span>"
-
-tokensToHtml :: [Token] -> T.Text
-tokensToHtml tokens =
- initialHtml <> T.concat (map toHtml tokens) <> "</body><br></html>"
diff --git a/homework/81333/golang-highlighter/src/Data/Lexer.hs b/homework/81333/golang-highlighter/src/Data/Lexer.hs
deleted file mode 100644
index defc73b..0000000
--- a/homework/81333/golang-highlighter/src/Data/Lexer.hs
+++ /dev/null
@@ -1,89 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-
-module Data.Lexer
- ( tokenize
- ) where
-
-import Data.Char (isAlpha, isAlphaNum)
-import qualified Data.Map.Strict as MapS
-import Data.Maps (keywords, operators, predeclIdentifiers)
-import qualified Data.Text as T
-import Data.Token
-import Data.TokenTypes
-import Data.Utils
-import Debug.Trace
-
-parseIdent :: T.Text -> Line -> Column -> Token
-parseIdent ident line column
- | MapS.member ident keywords = token keywords ident line column
- | MapS.member ident predeclIdentifiers =
- token predeclIdentifiers ident line column
- | otherwise =
- Token
- { tokenType = Ident (Identifier ident)
- , lexeme = ident
- , location = (line, column)
- }
-
-parseSingleOperator :: Char -> Line -> Column -> Token
-parseSingleOperator c line column = singleOp
- where
- singleOp = token operators (T.singleton c) line (column + 1)
-
-parseDoubleOperator :: T.Text -> Line -> Column -> Token
-parseDoubleOperator op line column = doubleOp
- where
- doubleOp = token operators op line (column + 2)
-
-parseTripleOperator :: T.Text -> Line -> Column -> Token
-parseTripleOperator op line column = tripleOp
- where
- tripleOp = token operators op line (column + 3)
-
-tokenizeChar :: Char -> T.Text -> Line -> Column -> [Token]
-tokenizeChar c code line column
- | isAlpha c || c == '_' =
- parseIdent (T.strip ident) line (column + T.length ident) :
- tokenize (stripPrefix code) line (column + T.length ident)
- | T.length code >= 2 && twoAhead == "//" =
- tokenSingleComment comment line column :
- tokenize (next comment code) line (column + T.length comment)
- | T.length code >= 3 && isThreePlaceOperator threeAhead =
- parseTripleOperator threeAhead line column :
- tokenize skipThree line (column + 3)
- | T.length code >= 2 && isTwoPlaceOperator twoAhead =
- parseDoubleOperator twoAhead line column :
- tokenize skipTwo line (column + 2)
- | isOnePlaceOperator c =
- parseSingleOperator c line column : tokenize (T.tail code) line (column + 1)
- | isTab c =
- tokenSpace "\t" line column : tokenize (T.tail code) line (column + 1)
- | isWhitespace c =
- tokenSpace " " line column : tokenize (T.tail code) line (column + 1)
- | isNewLine c =
- tokenSpace "\n" line column : tokenize (T.tail code) (line + 1) 0
- | isAlphaNum c =
- tokenNumber num line column :
- tokenize (next num code) line (column + T.length num)
- | c == '"' =
- tokenStringLiteral stringLit line column :
- tokenize (next stringLit code) line (column + T.length stringLit)
- | otherwise = tokenize (T.tail code) line column
- where
- ident = getPrefix code
- next string = T.drop (T.length string)
- twoAhead = T.pack ([c] <> [(T.head (T.tail code))])
- threeAhead = twoAhead <> T.pack ([T.head (T.tail (T.tail code))])
- comment = getSingleLineComment code
- skipTwo = T.tail $ T.tail code
- skipThree = T.tail $ T.tail $ T.tail code
- num = getDecNumber code
- stringLit = getStringLiteral (T.drop 1 code)
-
-tokenize :: T.Text -> Line -> Column -> [Token]
--- tokenize code line column
--- | trace ("\nCode is: " <> (T.unpack code)) False = undefined
-tokenize code line column =
- case safeHead code of
- Nothing -> []
- Just c -> tokenizeChar c code line column
diff --git a/homework/81333/golang-highlighter/src/Data/Maps.hs b/homework/81333/golang-highlighter/src/Data/Maps.hs
deleted file mode 100644
index f444ffb..0000000
--- a/homework/81333/golang-highlighter/src/Data/Maps.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-module Data.Maps where
-
-import qualified Data.Map.Strict as MapS
-import qualified Data.Text as T
-
-import Data.TokenTypes
-
-keywords :: MapS.Map T.Text TokenType
-keywords =
- let keywords = [Break ..]
- in MapS.fromList $ zip (map (T.pack . show) keywords) (map Keyword keywords)
-
-predeclIdentifiers :: MapS.Map T.Text TokenType
-predeclIdentifiers =
- let idents = [Boolean ..]
- in MapS.fromList $ zip (map (T.pack . show) idents) (map PredeclIdent idents)
-
-operators :: MapS.Map T.Text TokenType
-operators =
- let ops = [Plus ..]
- in MapS.fromList $ zip (map (T.pack . show) ops) (map Operator ops)
diff --git a/homework/81333/golang-highlighter/src/Data/Token.hs b/homework/81333/golang-highlighter/src/Data/Token.hs
deleted file mode 100644
index 3683a7f..0000000
--- a/homework/81333/golang-highlighter/src/Data/Token.hs
+++ /dev/null
@@ -1,16 +0,0 @@
-module Data.Token where
-
-import qualified Data.Text as T
-import Data.TokenTypes (TokenType)
-
-type Lexeme = T.Text
-
-type Line = Int
-
-type Column = Int
-
-data Token = Token
- { tokenType :: TokenType
- , lexeme :: Lexeme
- , location :: (Line, Column)
- } deriving (Show)
diff --git a/homework/81333/golang-highlighter/src/Data/TokenTypes.hs b/homework/81333/golang-highlighter/src/Data/TokenTypes.hs
deleted file mode 100644
index e0af38e..0000000
--- a/homework/81333/golang-highlighter/src/Data/TokenTypes.hs
+++ /dev/null
@@ -1,289 +0,0 @@
-{-# LANGUAGE GADTs #-}
-{-# LANGUAGE OverloadedStrings #-}
-
-module Data.TokenTypes where
-
-import qualified Data.Text as T
-
-data TokenKeyword
- = Break
- | Case
- | Chan
- | Const
- | Continue
- | Default
- | Defer
- | Else
- | Fallthrough
- | For
- | Func
- | Go
- | Goto
- | If
- | Import
- | Interface
- | Map
- | Package
- | Range
- | Return
- | Select
- | Struct
- | Switch
- | Type
- | Var
- deriving (Enum)
-
-instance Show TokenKeyword where
- show Break = "break"
- show Case = "case"
- show Chan = "chan"
- show Const = "const"
- show Continue = "continue"
- show Default = "default"
- show Defer = "defer"
- show Else = "else"
- show Fallthrough = "fallthrough"
- show For = "for"
- show Func = "func"
- show Go = "go"
- show Goto = "goto"
- show If = "if"
- show Import = "import"
- show Interface = "interface"
- show Map = "map"
- show Package = "package"
- show Range = "range"
- show Return = "return"
- show Select = "select"
- show Struct = "struct"
- show Switch = "switch"
- show Type = "type"
- show Var = "var"
-
-data TokenPredeclIdentifier
- = Boolean
- | Byte
- | Complex64
- | Complex128
- | Error
- | Float32
- | Float64
- | PlainInt
- | Int8
- | Int16
- | Int32
- | Int64
- | Rune
- | Str
- | Uint
- | Uint8
- | Uint16
- | Uint32
- | Uint64
- | UintPointer
- | BoolTrue
- | BoolFalse
- | Iota
- | Nil
- | Append
- | Cap
- | Close
- | Complex
- | Copy
- | Delete
- | Imag
- | Len
- | Make
- | New
- | Panic
- | Print
- | Println
- | Real
- | Recover
- deriving (Enum)
-
-instance Show TokenPredeclIdentifier where
- show Boolean = "bool"
- show Byte = "byte"
- show Complex64 = "complex64"
- show Complex128 = "complex128"
- show Error = "error"
- show Float32 = "float32"
- show Float64 = "float64"
- show PlainInt = "int"
- show Int8 = "int8"
- show Int16 = "int16"
- show Int32 = "int32"
- show Int64 = "int64"
- show Rune = "rune"
- show Str = "string"
- show Uint = "uint"
- show Uint8 = "uint8"
- show Uint16 = "uint16"
- show Uint32 = "uint32"
- show Uint64 = "uint64"
- show UintPointer = "uintptr"
- show BoolTrue = "true"
- show BoolFalse = "false"
- show Iota = "iota"
- show Nil = "nil"
- show Append = "append"
- show Cap = "cap"
- show Close = "close"
- show Complex = "complex"
- show Copy = "copy"
- show Delete = "delete"
- show Imag = "imag"
- show Len = "len"
- show Make = "make"
- show New = "new"
- show Panic = "panic"
- show Print = "print"
- show Println = "println"
- show Real = "real"
- show Recover = "recover"
-
-data TokenIdentifier =
- Identifier T.Text
-
-instance Show TokenIdentifier where
- show (Identifier s) = show s
-
-data TokenOperator
- = Plus
- | Minus
- | Mult
- | Div
- | Mod
- | BitAnd
- | BitOr
- | XOR
- | LShift
- | RShift
- | PlusEq
- | MinusEq
- | MultEq
- | DivEq
- | ModEq
- | BitAndEq
- | BitOrEq
- | XorEq
- | LShiftEq
- | MShiftEq
- | And
- | Or
- | Recv
- | PlusPlus
- | MinusMinus
- | Equal
- | LessThan
- | GreaterThan
- | Assign
- | Bang
- | Diff
- | LessThanOrEq
- | GreaterThanOrEq
- | TypeAssign
- | TripleDot
- | LParen
- | RParen
- | LSqParen
- | RSqParen
- | LBlockParen
- | RBlockParen
- | Comma
- | SemiColon
- | Colon
- | Dot
- deriving (Enum)
-
-instance Show TokenOperator where
- show Plus = "+"
- show Minus = "-"
- show Mult = "*"
- show Div = "/"
- show Mod = "%"
- show BitAnd = "&"
- show BitOr = "|"
- show XOR = "^"
- show LShift = "<<"
- show RShift = ">>"
- show PlusEq = "+="
- show MinusEq = "-="
- show MultEq = "*="
- show DivEq = "/="
- show ModEq = "%="
- show BitAndEq = "&="
- show BitOrEq = "|="
- show XorEq = "^="
- show LShiftEq = "<<="
- show MShiftEq = ">>="
- show And = "&&"
- show Or = "||"
- show Recv = "<-"
- show PlusPlus = "++"
- show MinusMinus = "--"
- show Equal = "=="
- show LessThan = "<"
- show GreaterThan = ">"
- show Assign = "="
- show Bang = "!"
- show Diff = "!="
- show LessThanOrEq = "<="
- show GreaterThanOrEq = ">="
- show TypeAssign = ":="
- show TripleDot = "..."
- show LParen = "("
- show RParen = ")"
- show LSqParen = "["
- show RSqParen = "]"
- show LBlockParen = "{"
- show RBlockParen = "}"
- show Comma = ","
- show SemiColon = ";"
- show Colon = ":"
- show Dot = "."
-
-data TokenWhitespace
- = Whitespace
- | NewLine
- | Tab
-
-instance Show TokenWhitespace where
- show Whitespace = "&nbsp;"
- show NewLine = "<br>"
- show Tab = "&emsp;"
-
-data TokenLiteral
- = Number T.Text
- | FloatNumber T.Text
- | OctNumber T.Text
- | HexNumber T.Text
- | RuneLiteral T.Text
- | StringLiteral T.Text
-
-instance Show TokenLiteral where
- show (Number num) = show num
- show (FloatNumber num) = show num
- show (OctNumber num) = "0" <> show num
- show (HexNumber num) = "0x" <> show num
- show (RuneLiteral rune) = show rune
- show (StringLiteral string) = show string
-
-data TokenComment
- = SingleLine T.Text
- | MultiLine T.Text
-
-instance Show TokenComment where
- show (SingleLine t) = "//" <> show t
- show (MultiLine t) = "/*" <> show t <> "*/"
-
-data TokenType where
- PredeclIdent :: TokenPredeclIdentifier -> TokenType
- Ident :: TokenIdentifier -> TokenType
- Keyword :: TokenKeyword -> TokenType
- Operator :: TokenOperator -> TokenType
- Literal :: TokenLiteral -> TokenType
- Space :: TokenWhitespace -> TokenType
- Comment :: TokenComment -> TokenType
- deriving (Show)
diff --git a/homework/81333/golang-highlighter/src/Data/Utils.hs b/homework/81333/golang-highlighter/src/Data/Utils.hs
deleted file mode 100644
index 393d23d..0000000
--- a/homework/81333/golang-highlighter/src/Data/Utils.hs
+++ /dev/null
@@ -1,124 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-
-module Data.Utils where
-
-import Data.Char (isAlpha, isAlphaNum)
-import qualified Data.Map.Strict as MapS
-import Data.Maps (keywords, operators, predeclIdentifiers)
-import qualified Data.Text as T
-import Data.Token
-import Data.TokenTypes
-import Debug.Trace
-
-safeHead :: T.Text -> Maybe Char
-safeHead s =
- if s == ""
- then Nothing
- else Just $ T.head s
-
-safeTail :: T.Text -> Maybe T.Text
-safeTail s =
- if s == ""
- then Nothing
- else Just $ T.tail s
-
-token :: MapS.Map T.Text TokenType -> T.Text -> Line -> Column -> Token
-token m ident line column =
- Token
- {tokenType = (MapS.!) m ident, lexeme = ident, location = (line, column)}
-
-tokenNumber :: T.Text -> Line -> Column -> Token
-tokenNumber num line column =
- Token
- { tokenType = Literal (Number num)
- , lexeme = num
- , location = (line, column + T.length num)
- }
-
-tokenStringLiteral :: T.Text -> Line -> Column -> Token
-tokenStringLiteral str line column =
- Token
- { tokenType = Literal (StringLiteral str)
- , lexeme = str
- , location = (line, column + T.length str)
- }
-
-tokenSpace :: T.Text -> Line -> Column -> Token
-tokenSpace str line column
- | str == " " =
- Token
- { tokenType = Space Whitespace
- , lexeme = "&nbsp;"
- , location = (line, column + 1)
- }
- | str == "\n" =
- Token {tokenType = Space NewLine, lexeme = "<br>", location = (line + 1, 0)}
- | str == "\t" =
- Token
- { tokenType = Space Tab
- , lexeme = T.replicate 8 "&nbsp;"
- , location = (line, column + 8)
- }
-
-tokenSingleComment :: T.Text -> Line -> Column -> Token
-tokenSingleComment str line column =
- Token
- { tokenType = Comment (SingleLine str)
- , lexeme = str
- , location = (line, column + T.length str)
- }
-
-tokenMultiComment :: T.Text -> Line -> Column -> Token
-tokenMultiComment str line column =
- Token
- { tokenType = Comment (MultiLine str)
- , lexeme = str
- , location = (line, column + T.length str)
- }
-
-hasNewLine :: T.Text -> Bool
-hasNewLine "" = False
-hasNewLine s =
- if T.head s == '\n'
- then True
- else False
-
-stripPrefix :: T.Text -> T.Text
-stripPrefix = T.dropWhile (\x -> x /= ' ' && x /= '\n' && (not $ isOperator x))
-
-getPrefix :: T.Text -> T.Text
-getPrefix = T.takeWhile (\x -> x /= ' ' && x /= '\n' && (not $ isOperator x))
-
-isOperator :: Char -> Bool
-isOperator c = any (== c) (map (T.head . T.pack . show) [Plus ..])
-
-isOnePlaceOperator :: Char -> Bool
-isOnePlaceOperator c =
- c `elem`
- map (T.head . T.pack . show) (filter (\x -> (length $ show x) == 1) [Plus ..])
-
-isWhitespace :: Char -> Bool
-isWhitespace c = [c] == " "
-
-isNewLine :: Char -> Bool
-isNewLine c = [c] == "\n"
-
-isTab :: Char -> Bool
-isTab c = [c] == "\t"
-
-isTwoPlaceOperator :: T.Text -> Bool
-isTwoPlaceOperator s =
- s `elem` map (T.pack . show) (filter (\x -> (length $ show x) == 2) [Plus ..])
-
-isThreePlaceOperator :: T.Text -> Bool
-isThreePlaceOperator s =
- s `elem` map (T.pack . show) (filter (\x -> (length $ show x) == 3) [Plus ..])
-
-getDecNumber :: T.Text -> T.Text
-getDecNumber code = T.takeWhile isAlphaNum code
-
-getStringLiteral :: T.Text -> T.Text
-getStringLiteral code = "\"" <> T.takeWhile (/= '"') code <> "\""
-
-getSingleLineComment :: T.Text -> T.Text
-getSingleLineComment = T.takeWhile (/= '\n')
diff --git a/homework/81333/golang-highlighter/src/Lib.hs b/homework/81333/golang-highlighter/src/Lib.hs
deleted file mode 100644
index f999329..0000000
--- a/homework/81333/golang-highlighter/src/Lib.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Lib
- ( golangToHtml
- ) where
-
-import qualified Data.Text as T
-
-import Data.Highlighter (tokensToHtml)
-import Data.Lexer (tokenize)
-
-golangToHtml :: T.Text -> T.Text
-golangToHtml code = tokensToHtml $ tokenize code 0 0
diff --git a/homework/81333/golang-highlighter/stack.yaml b/homework/81333/golang-highlighter/stack.yaml
deleted file mode 100644
index 34ad9e9..0000000
--- a/homework/81333/golang-highlighter/stack.yaml
+++ /dev/null
@@ -1,65 +0,0 @@
-# This file was automatically generated by 'stack init'
-#
-# Some commonly used options have been documented as comments in this file.
-# For advanced use and comprehensive documentation of the format, please see:
-# https://docs.haskellstack.org/en/stable/yaml_configuration/
-
-# Resolver to choose a 'specific' stackage snapshot or a compiler version.
-# A snapshot resolver dictates the compiler version and the set of packages
-# to be used for project dependencies. For example:
-#
-# resolver: lts-3.5
-# resolver: nightly-2015-09-21
-# resolver: ghc-7.10.2
-# resolver: ghcjs-0.1.0_ghc-7.10.2
-#
-# The location of a snapshot can be provided as a file or url. Stack assumes
-# a snapshot provided as a file might change, whereas a url resource does not.
-#
-# resolver: ./custom-snapshot.yaml
-# resolver: https://example.com/snapshots/2018-01-01.yaml
-resolver: lts-12.13
-
-# User packages to be built.
-# Various formats can be used as shown in the example below.
-#
-# packages:
-# - some-directory
-# - https://example.com/foo/bar/baz-0.0.2.tar.gz
-# - location:
-# git: https://github.com/commercialhaskell/stack.git
-# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
-# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a
-# subdirs:
-# - auto-update
-# - wai
-packages:
-- .
-# Dependency packages to be pulled from upstream that are not in the resolver
-# using the same syntax as the packages field.
-# (e.g., acme-missiles-0.3)
-# extra-deps: []
-
-# Override default flag values for local packages and extra-deps
-# flags: {}
-
-# Extra package databases containing global packages
-# extra-package-dbs: []
-
-# Control whether we use the GHC we find on the path
-# system-ghc: true
-#
-# Require a specific version of stack, using version ranges
-# require-stack-version: -any # Default
-# require-stack-version: ">=1.7"
-#
-# Override the architecture used by stack, especially useful on Windows
-# arch: i386
-# arch: x86_64
-#
-# Extra directories used by stack for building
-# extra-include-dirs: [/path/to/dir]
-# extra-lib-dirs: [/path/to/dir]
-#
-# Allow a newer minor version of GHC than the snapshot specifies
-# compiler-check: newer-minor \ No newline at end of file
diff --git a/homework/81333/golang-highlighter/test/Spec.hs b/homework/81333/golang-highlighter/test/Spec.hs
deleted file mode 100644
index cd4753f..0000000
--- a/homework/81333/golang-highlighter/test/Spec.hs
+++ /dev/null
@@ -1,2 +0,0 @@
-main :: IO ()
-main = putStrLn "Test suite not yet implemented"
diff --git a/homework/81350/brainfuck_interpreter/Makefile b/homework/81350/brainfuck_interpreter/Makefile
deleted file mode 100644
index 5619881..0000000
--- a/homework/81350/brainfuck_interpreter/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-all: brainfuck
-
-brainfuck: interpreter.cpp input.file
- gcc interpreter.cpp -o brainfuck
-
-clean:
- rm brainfuck
diff --git a/homework/81350/brainfuck_interpreter/README b/homework/81350/brainfuck_interpreter/README
deleted file mode 100644
index f795c86..0000000
--- a/homework/81350/brainfuck_interpreter/README
+++ /dev/null
@@ -1,9 +0,0 @@
-The program in brainfuck is stored in "input.file". The program can be changed
-to any valid program in brainfuck.
-To use the interpreter:
-
-1. You need to build it:
-$ make
-
-2. Run the interpreter:
-$ ./brainfuck
diff --git a/homework/81350/brainfuck_interpreter/input.file b/homework/81350/brainfuck_interpreter/input.file
deleted file mode 100644
index 8fa0f72..0000000
--- a/homework/81350/brainfuck_interpreter/input.file
+++ /dev/null
@@ -1 +0,0 @@
-++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
diff --git a/homework/81350/brainfuck_interpreter/interpreter.cpp b/homework/81350/brainfuck_interpreter/interpreter.cpp
deleted file mode 100644
index 76fdd44..0000000
--- a/homework/81350/brainfuck_interpreter/interpreter.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-#include <stdio.h>
-#include <vector>
-char cells[1024] = {0};
-char* ptr = cells;
-FILE* program;
-
-
-void read_while_loop(){
- int position = ftell(program);
- //printf("%d\n", position);
- char c;
-
- while((c = fgetc(program)) != ']'){
- if(c == '['){
- read_while_loop();
- }
-
- switch (c) {
- case '+':
- (*ptr)++;
- break;
- case '-':
- (*ptr)--;
- break;
- case '>':
- ptr++;
- break;
- case '<':
- ptr--;
- break;
- case '.':
- putchar(*ptr);
- break;
- case ',':
- *ptr = getchar();
- break;
- }
- }
-
- if((int)*ptr != 0){
- fseek(program, position, SEEK_SET);
- read_while_loop();
- }
-}
-
-int main(){
- program = fopen("input.file", "r");
- char c;
-
- while((c = fgetc(program)) != EOF ){
-
- switch (c) {
- case '+':
- (*ptr)++;
- break;
- case '-':
- (*ptr)--;
- break;
- case '>':
- ptr++;
- break;
- case '<':
- ptr--;
- break;
- case '.':
- putchar(*ptr);
- break;
- case ',':
- *ptr = getchar();
- break;
- case '[':
- read_while_loop();
- break;
- }
- }
- // printf("%c\n", cells[0]);
-}
diff --git a/homework/81350/parser/Makefile b/homework/81350/parser/Makefile
deleted file mode 100644
index ceb9963..0000000
--- a/homework/81350/parser/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-all: parser
-
-parser: parser.tab.c parser.tab.h stack.c stack.h lex.yy.c
- gcc lex.yy.c parser.tab.c stack.c -lfl -o parser
-
-parser.tab.c parser.tab.h: parser.y
- bison -v -d parser.y
-
-lex.yy.c: lexer.lex parser.tab.h stack.h
- flex lexer.lex
-
-clean:
- rm -f lex.yy.c parser.tab.h parser.tab.c parser
diff --git a/homework/81350/parser/colapser/Makefile b/homework/81350/parser/colapser/Makefile
deleted file mode 100644
index ceb9963..0000000
--- a/homework/81350/parser/colapser/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-all: parser
-
-parser: parser.tab.c parser.tab.h stack.c stack.h lex.yy.c
- gcc lex.yy.c parser.tab.c stack.c -lfl -o parser
-
-parser.tab.c parser.tab.h: parser.y
- bison -v -d parser.y
-
-lex.yy.c: lexer.lex parser.tab.h stack.h
- flex lexer.lex
-
-clean:
- rm -f lex.yy.c parser.tab.h parser.tab.c parser
diff --git a/homework/81350/parser/colapser/README b/homework/81350/parser/colapser/README
deleted file mode 100644
index cb143ea..0000000
--- a/homework/81350/parser/colapser/README
+++ /dev/null
@@ -1,13 +0,0 @@
-Използвала съм изгледа на човека с факултетен номер 81319, затова изглежда по същия начин.
-
-За да се изпробва как действа:
-1. Трябва да се билдне:
-$ make
-
-2. Да се пусне:
-$ ./parser > <name of file>
-
-Напреимер:
-$ ./parser > output.html
-
-3. Да се отвори html файла в браузъра.
diff --git a/homework/81350/parser/colapser/input.file b/homework/81350/parser/colapser/input.file
deleted file mode 100644
index 223392d..0000000
--- a/homework/81350/parser/colapser/input.file
+++ /dev/null
@@ -1,13 +0,0 @@
-def func():
- num = 7
-
- factorial = 1
-
- if num < 0:
- print("Sorry, factorial does not exist for negative numbers")
- elif num == 0:
- print("The factorial of 0 is 1")
- else:
- for i in range(1,num + 1):
- factorial = factorial*i
- print("The factorial of",num,"is",factorial)
diff --git a/homework/81350/parser/colapser/lexer.lex b/homework/81350/parser/colapser/lexer.lex
deleted file mode 100644
index 7174494..0000000
--- a/homework/81350/parser/colapser/lexer.lex
+++ /dev/null
@@ -1,236 +0,0 @@
-
-%{
-#include "stack.h"
-#include <stdio.h>
-#include "parser.tab.h"
-
-int g_current_line_indent = 0;
-int g_is_fake_outdent_symbol = 0;
-int current_line = 0;
-int is_read_indent = 0;
-int is_preveous_unindent = 0;
-
-static const unsigned int TAB_WIDTH = 2;
-
-#define YY_USER_INIT { \
- push(0); \
- BEGIN(initial); \
- }
-
-int yycolumn = 1;
-void set_yycolumn(int val) {
- yycolumn = val;
- yylloc.first_column = yycolumn;
- yylloc.last_column = yycolumn + yyleng - 1;
-}
-
-#define YY_USER_ACTION { \
- yylloc.first_line = yylloc.last_line = yylineno; \
- set_yycolumn(yycolumn); \
- yycolumn += yyleng; \
-}
-
-char* fixed_unindent(char* text){
- char* add_new_line = "";
- if(is_preveous_unindent){
- add_new_line ="<br>";
- is_preveous_unindent = 0;
- }
- return concatenate(add_new_line, text);
-}
-
-%}
-
- /* This is a sub-parser (state) for indentation-sensitive scoping */
-%x initial
-%x indent
-%s normal
-
- /* %option 8bit reentrant bison-bridge */
-%option warn
-%option nodefault
-%option yylineno
-%option noyywrap
-
-
-digit [0-9]
-number [1-9]{digit}*
-fnumber {digit}+"."{digit}*
-letter [a-zA-Z_]
-stringdq \"([^\"]|(\\\"))*\"
-stringsq \'([^\']|(\\\'))*\'
-
- /*%option debug*/
-%%
- int indent_caller = normal;
-
-
-<*>\n { set_yycolumn(0); yylineno--; REJECT; }
-
-
-<initial>. { set_yycolumn(yycolumn-1); indent_caller = normal; yyless(0); BEGIN(indent); }
-<initial>\n { indent_caller = normal; yyless(0); BEGIN(indent); }
-
- /* The following are the rules that keep track of indentation. */
-<indent>" " { g_current_line_indent++; }
-<indent>\t { g_current_line_indent = (g_current_line_indent + TAB_WIDTH) & ~(TAB_WIDTH-1); }
-<indent>\n { g_current_line_indent = 0; /* ignoring blank line */ }
-<indent><<EOF>> {
- if(peek() != 0) {
- pop();
-
- if(g_current_line_indent != peek()) {
- unput('\n');
- for(size_t i = 0 ; i < peek() ; ++i) {
- unput(' ');
- }
- } else {
- BEGIN(indent_caller);
- }
-
- return UNINDENT;
- } else {
- yyterminate();
- }
- }
-
-<indent>. {
- // if(!g_is_fake_outdent_symbol) {
- unput(*yytext);
- // }
- set_yycolumn(yycolumn-1);
- g_is_fake_outdent_symbol = 0;
-
-
- if(g_current_line_indent > peek()) {
- push(g_current_line_indent);
- BEGIN(indent_caller);
- return INDENT;
- } else if(g_current_line_indent < peek()) {
- pop();
-
- if(g_current_line_indent != peek()) {
- for(size_t i = 0 ; i < g_current_line_indent ; ++i) {
- unput(' ');
- }
- unput('\n');
-
- unput('$');
-
- g_is_fake_outdent_symbol = 1;
- for(size_t i = 0 ; i < peek() ; ++i) {
- unput(' ');
- }
- unput('\n');
- } else {
-
- BEGIN(indent_caller);
- }
- is_preveous_unindent = 1;
- return UNINDENT;
- } else {
- BEGIN(indent_caller);
- }
- }
-<normal>" " { yylval.lexeme = " ";}
-<normal>\n { g_current_line_indent = 0; indent_caller = YY_START; BEGIN(indent); yylval.lexeme = "<br>"; return NEWLINE; }
-
-<normal>{number}|{fnumber} { yylval.lexeme = fixed_unindent(yytext); return NUMBER; }
-<normal>{digit} { yylval.lexeme = fixed_unindent(yytext); return NUMBER;}
-<normal>{stringsq} { yylval.lexeme = fixed_unindent(yytext); return STRING;}
-<normal>{stringdq} { yylval.lexeme = fixed_unindent(yytext); return STRING;}
-
-<normal>"+" { yylval.lexeme = fixed_unindent(yytext); return PLUS; }
-<normal>"-" { yylval.lexeme = fixed_unindent(yytext); return MINUS; }
-<normal>"*" { yylval.lexeme = fixed_unindent(yytext); return STAR; }
-<normal>"/" { yylval.lexeme = fixed_unindent(yytext); return SLASH; }
-<normal>"//" { yylval.lexeme = fixed_unindent(yytext); return DOUBLESLASH;}
-<normal>"%" { yylval.lexeme = fixed_unindent(yytext); return PERCENT; }
-<normal>"**" { yylval.lexeme = fixed_unindent(yytext); return DOUBLESTAR; }
-<normal>">" { yylval.lexeme = fixed_unindent(yytext); return BIGGER; }
-<normal>"<" { yylval.lexeme = fixed_unindent(yytext); return LESS; }
-<normal>">=" { yylval.lexeme = fixed_unindent(yytext); return BIGGEREQL; }
-<normal>"<=" { yylval.lexeme = fixed_unindent(yytext); return LESSEQL; }
-<normal>"==" { yylval.lexeme = fixed_unindent(yytext); return EQL; }
-<normal>"!=" { yylval.lexeme = fixed_unindent(yytext); return NOTEQL; }
-
-
-<normal>"&" { yylval.lexeme = fixed_unindent(yytext); return BOOLAND; }
-<normal>"|" { yylval.lexeme = fixed_unindent(yytext); return BOOLOR; }
-<normal>"~" { yylval.lexeme = fixed_unindent(yytext); return TILDA; }
-<normal>"^" { yylval.lexeme = fixed_unindent(yytext); return HAT; }
-<normal>">>" { yylval.lexeme = fixed_unindent(yytext); return SHIFTRIGHT; }
-<normal>"<<" { yylval.lexeme = fixed_unindent(yytext); return SHIFTLESS; }
-
-
-<normal>"=" { yylval.lexeme = fixed_unindent(yytext); return ASSIGN; }
-<normal>"+=" { yylval.lexeme = fixed_unindent(yytext); return PLUSASSIGN; }
-<normal>"-=" { yylval.lexeme = fixed_unindent(yytext); return MINUSASSIGN;}
-<normal>"*=" { yylval.lexeme = fixed_unindent(yytext); return STARASSIGN; }
-<normal>"/=" { yylval.lexeme = fixed_unindent(yytext); return SLASHASSIGN;}
-<normal>"%=" { yylval.lexeme = fixed_unindent(yytext); return PERCENTASSIGN;}
-<normal>"**=" { yylval.lexeme = fixed_unindent(yytext); return DOUBLESTARASSIGN;}
-<normal>"//=" { yylval.lexeme = fixed_unindent(yytext); return DOUBLESLASHASSIGN;}
-<normal>"^=" { yylval.lexeme = fixed_unindent(yytext); return HATASSIGN;}
-<normal>"&=" { yylval.lexeme = fixed_unindent(yytext); return BOOLANDASSIGN;}
-<normal>"|=" { yylval.lexeme = fixed_unindent(yytext); return BOOLORASSIGN;}
-<normal>">>=" { yylval.lexeme = fixed_unindent(yytext); return SHIFTRIGHTASSIGN;}
-<normal>"<<=" { yylval.lexeme = fixed_unindent(yytext); return SHIFTLEFTASSIGN;}
-<normal>"@=" { yylval.lexeme = fixed_unindent(yytext); return ATASSIGN; }
-
-<normal>"@" { yylval.lexeme = fixed_unindent(yytext); return AT;}
-<normal>"(" { yylval.lexeme = fixed_unindent(yytext); return LPAREN; }
-<normal>")" { yylval.lexeme = fixed_unindent(yytext); return RPAREN; }
-<normal>"[" { yylval.lexeme = fixed_unindent(yytext); return LSQPAREN;}
-<normal>"]" { yylval.lexeme = fixed_unindent(yytext); return RSQPAREN;}
-<normal>"{" { yylval.lexeme = fixed_unindent(yytext); return LCURPAREN;}
-<normal>"}" { yylval.lexeme = fixed_unindent(yytext); return RCURPAREN;}
-<normal>";" { yylval.lexeme = fixed_unindent(yytext); return SEMICOLON; }
-<normal>":" { yylval.lexeme = fixed_unindent(yytext); return COLON; }
-<normal>"," { yylval.lexeme = fixed_unindent(yytext); return COMMA; }
-<normal>"." { yylval.lexeme = fixed_unindent(yytext); return DOT; }
-<normal>"..." { yylval.lexeme = fixed_unindent(yytext); return THREEDOTS;}
-
-<normal>"$" { return DOLAR; }
-
-<normal>"async" { yylval.lexeme = fixed_unindent(yytext); return ASYNC;}
-<normal>"def" { yylval.lexeme = fixed_unindent(yytext); return DEF; }
-<normal>"and" { yylval.lexeme = fixed_unindent(yytext); return AND;}
-<normal>"or" { yylval.lexeme = fixed_unindent(yytext); return OR;}
-<normal>"not" { yylval.lexeme = fixed_unindent(yytext); return NOT;}
-<normal>"in" { yylval.lexeme = fixed_unindent(yytext); return IN;}
-<normal>"not in" { yylval.lexeme = fixed_unindent(yytext); return NOTIN;}
-<normal>"is" { yylval.lexeme = fixed_unindent(yytext); return IS;}
-<normal>"is not" { yylval.lexeme = fixed_unindent(yytext); return ISNOT;}
-<normal>"await" { yylval.lexeme = fixed_unindent(yytext); return AWAIT;}
-<normal>"None" { yylval.lexeme = fixed_unindent(yytext); return NONE;}
-<normal>"True" { yylval.lexeme = fixed_unindent(yytext); return TRUE;}
-<normal>"False" { yylval.lexeme = fixed_unindent(yytext); return FALSE;}
-<normal>"class" { yylval.lexeme = fixed_unindent(yytext); return CLASS;}
-<normal>"for" { yylval.lexeme = fixed_unindent(yytext); return FOR;}
-<normal>"if" { yylval.lexeme = fixed_unindent(yytext); return IF;}
-<normal>"elif" { yylval.lexeme = fixed_unindent(yytext); return ELIF;}
-<normal>"else" { yylval.lexeme = fixed_unindent(yytext); return ELSE;}
-<normal>"except" { yylval.lexeme = fixed_unindent(yytext); return EXCEPT;}
-<normal>"from" { yylval.lexeme = fixed_unindent(yytext); return FROM;}
-<normal>"finally" { yylval.lexeme = fixed_unindent(yytext); return FINALLY;}
-<normal>"lambda" { yylval.lexeme = fixed_unindent(yytext); return LAMBDA;}
-<normal>"yield" { yylval.lexeme = fixed_unindent(yytext); return YIELD;}
-<normal>"as" { yylval.lexeme = fixed_unindent(yytext); return AS;}
-<normal>"assert" { yylval.lexeme = fixed_unindent(yytext); return ASSERT;}
-<normal>"break" { yylval.lexeme = fixed_unindent(yytext); return BREAK;}
-<normal>"continue" { yylval.lexeme = fixed_unindent(yytext); return CONTINUE;}
-<normal>"del" { yylval.lexeme = fixed_unindent(yytext); return DEL;}
-<normal>"global" { yylval.lexeme = fixed_unindent(yytext); return GLOBAL;}
-<normal>"import" { yylval.lexeme = fixed_unindent(yytext); return IMPORT;}
-<normal>"nonlocal" { yylval.lexeme = fixed_unindent(yytext); return NONLOCAL;}
-<normal>"pass" { yylval.lexeme = fixed_unindent(yytext); return PASS;}
-<normal>"raise" { yylval.lexeme = fixed_unindent(yytext); return RAISE;}
-<normal>"return" { yylval.lexeme = fixed_unindent(yytext); return RETURN;}
-<normal>"try" { yylval.lexeme = fixed_unindent(yytext); return TRY;}
-<normal>"while" { yylval.lexeme = fixed_unindent(yytext); return WHILE;}
-<normal>"with" { yylval.lexeme = fixed_unindent(yytext); return WITH;}
-
-<normal>{letter}({letter}|{digit})* {
- yylval.lexeme = fixed_unindent(yytext); return NAME; }
-%%
diff --git a/homework/81350/parser/colapser/parser.y b/homework/81350/parser/colapser/parser.y
deleted file mode 100644
index 030ae64..0000000
--- a/homework/81350/parser/colapser/parser.y
+++ /dev/null
@@ -1,1107 +0,0 @@
-
-%{
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include "stack.h"
-int yylex();
-int yyerror(const char* error);
-FILE *yyin;
-#undef YYDEBUG
-#define YYDEBUG 1
-/* #define YY_DECL int yylex(scanner) void* scanner; */
-
-
-
- char* concatenate3(char* first, char* second, char* third){
- char* result1 = concatenate(first, second);
- char* result2 = concatenate(result1, third);
- }
-
- void printStyles() {
- puts(
- " <style>"
- " .identifier {"
- " color: black;"
- " }"
- " .keyword {"
- " color: purple;"
- " }"
- " .number {"
- " color: blue;"
- " }"
- " .string {"
- " color: green;"
- " }"
- " .operator {"
- " color: #db184c;"
- " font-style: bold;"
- " .constant {"
- " color: purple;"
- " }"
- " .collapsible {"
- " color: white;"
- " cursor: pointer;"
- " padding: 2px;"
- " width: 2%;"
- " border: none;"
- " text-align: center;"
- " outline: none;"
- " font-size: 15px;"
- " }"
- " </style>"
- );
- }
- void printCollapsableScript() {
- puts(
- "<script>"
- "var coll = document.getElementsByClassName(\"collapsible\");\n"
- "var i;\n"
- "\n"
- "for (i = 0; i < coll.length; i++) {\n"
- "coll[i].addEventListener(\"click\", function() {\n"
- "this.classList.toggle(\"active\");\n"
- "var content = this.nextElementSibling;\n"
- "if (content.style.display === \"inline\") {\n"
- "content.style.display = \"none\";\n"
- "this.innerHTML=\"+\""
- "} else {\n"
- "content.style.display = \"inline\";\n"
- "this.innerHTML=\"-\""
- "}\n"
- "});\n"
- "}\n"
- "for (i = 0; i < coll.length; i++) {\n"
- "coll[i].click()\n"
- "}\n"
- "</script>"
- );
- }
- char* stylize(char* text, char* style) {
- char* result = concatenate("<span class=\"", style);
- result = concatenate(result, "\">");
- result = concatenate(result, text);
- result = concatenate(result, " </span>");
- return result;
- }
-
- char *str_replace(char *orig, char *rep, char *with) {
- char *result;
- char *ins;
- char *tmp;
- int len_rep;
- int len_with;
- int len_front;
- int count;
-
- if (!orig || !rep)
- return NULL;
- len_rep = strlen(rep);
- if (len_rep == 0)
- return NULL;
- if (!with)
- with = "";
- len_with = strlen(with);
-
- // count the number of replacements needed
- ins = orig;
- for (count = 0; tmp = strstr(ins, rep); ++count) {
- ins = tmp + len_rep;
- }
-
- tmp = result = malloc(strlen(orig) + (len_with - len_rep) * count + 1);
-
- if (!result)
- return NULL;
-
- while (count--) {
- ins = strstr(orig, rep);
- len_front = ins - orig;
- tmp = strncpy(tmp, orig, len_front) + len_front;
- tmp = strcpy(tmp, with) + len_with;
- orig += len_front + len_rep; // move to next "end of rep"
- }
- strcpy(tmp, orig);
- return result;
- }
-
- char* collapsableBlock(char* text) {
- int len = strlen(text);
- if(len>4 && text[len-1] == '>' && text[len-2] == 'r' && text[len-3] == 'b' && text[len-4] == '<'){
- text[len-4] = '\0';
- }
- char* result = concatenate("<button class=\"collapsible\">+</button>", "<div class=\"content\">");
- char* new_text = str_replace(text, "<br>", "<br>&nbsp&nbsp");
- result = concatenate(result, new_text);
- result = concatenate(result, "</div>");
- return result;
- }
-
-%}
-
-%start input_stmt
-/* %define api.pure full */
-%define api.value.type {union name {char* lexeme;}}
-%locations
-
-%type<lexeme> NUMBER PLUS MINUS STAR SLASH DOUBLESLASH PERCENT DOUBLESTAR BIGGER
-%type<lexeme> LESS BIGGEREQL LESSEQL EQL NOTEQL
-%type<lexeme> BOOLAND BOOLOR TILDA HAT SHIFTRIGHT SHIFTLESS
-%type<lexeme> ASSIGN PLUSASSIGN MINUSASSIGN STARASSIGN SLASHASSIGN PERCENTASSIGN
-%type<lexeme> DOUBLESTARASSIGN DOUBLESLASHASSIGN HATASSIGN BOOLANDASSIGN
-%type<lexeme> BOOLORASSIGN SHIFTRIGHTASSIGN SHIFTLEFTASSIGN ATASSIGN
-%type<lexeme> LPAREN RPAREN LSQPAREN RSQPAREN LCURPAREN RCURPAREN SEMICOLON
-%type<lexeme> COLON COMMA DOT AT THREEDOTS NAME
-%type<lexeme> DEF ASYNC AND OR NOT IN NOTIN IS ISNOT AWAIT NONE TRUE FALSE FOR
-%type<lexeme> IF ELIF ELSE EXCEPT CLASS FROM FINALLY LAMBDA YIELD AS ASSERT
-%type<lexeme> BREAK CONTINUE DEL GLOBAL IMPORT NONLOCAL PASS RAISE RETURN TRY WHILE WITH
-%type<lexeme> INDENT UNINDENT NEWLINE STRING
-%type<lexeme> input_stmt decorator decorator_more decorated obj_definition async_funcdef funcdef parameters typedargslist td_one td_one_arg td_more_arg td_one_optional td_two td_two_optional td_three tfpdef varargslist var_one var_one_arg var_more_arg var_one_optional var_two var_two_optional var_three vfpdef stmt simple_stmt simple_more_stmt small_stmt expr_stmt expr_stmt_two assign_more assign_expr aug_expr annassign testlist_star_expr testlist_se testlist_star_expr_more augassign del_stmt pass_stmt flow_stmt break_stmt continue_stmt return_stmt yield_stmt raise_stmt import_stmt import_name import_from import_from_name dots dots_more import_from_import import_as_name dotted_as_name import_as_names import_as_name_more dotted_as_names dotted_as_name_more dotted_name dotted_name_more global_stmt global_stmt_more nonlocal_stmt nonlocal_stmt_more assert_stmt compound_stmt async_stmt if_stmt elif_stmt else_stmt elif_stmt_more while_stmt for_stmt try_stmt try_stmt_two finally_stmt except_fin_stmt except_stmt_more except_stmt except_clause with_stmt with_item with_item_more suite stmt_more test test_nocond lambdadef lambdadef_nocond or_test or_test_more and_test and_test_more not_test comparison comp_more comp_op star_expr expr expr_more xor_expr xor_expr_more and_expr and_expr_more shift_expr shift_expr_more shift_op arith_expr arith_expr_more arith_op term term_more term_op factor unar_op power atom_expr atom testlist_comp testlist_comp_second testlist_more_arg trailer trailer_more subscriptlist subscipt_more subscript sliceop exprlist exprlist_more exprlist_op testlist testlist_more dictorsetmaker test_star_expr dsm_one test_star_expr_more test_star_expr_2 dsm_two test_star_expr_2_more classdef arglist arglist_more argument comp_iter sync_comp_for comp_for comp_if yield_expr yield_arg
-
-
-
-%token NUMBER
-%token PLUS
-%token MINUS
-%token STAR
-%token SLASH
-%token DOUBLESLASH
-%token PERCENT
-%token DOUBLESTAR
-%token BIGGER
-%token LESS
-%token BIGGEREQL
-%token LESSEQL
-%token EQL
-%token NOTEQL
-
-%token BOOLAND
-%token BOOLOR
-%token TILDA
-%token HAT
-%token SHIFTRIGHT
-%token SHIFTLESS
-
-%token ASSIGN
-%token PLUSASSIGN
-%token MINUSASSIGN
-%token STARASSIGN
-%token SLASHASSIGN
-%token PERCENTASSIGN
-%token DOUBLESTARASSIGN
-%token DOUBLESLASHASSIGN
-%token HATASSIGN
-%token BOOLANDASSIGN
-%token BOOLORASSIGN
-%token SHIFTRIGHTASSIGN
-%token SHIFTLEFTASSIGN
-%token ATASSIGN
-
-%token LPAREN
-%token RPAREN
-%token LSQPAREN
-%token RSQPAREN
-%token LCURPAREN
-%token RCURPAREN
-%token SEMICOLON
-%token COLON
-%token COMMA
-%token DOT
-%token AT
-%token THREEDOTS
-
-%token NAME
-
-%token DEF
-%token ASYNC
-%token AND
-%token OR
-%token NOT
-%token IN
-%token NOTIN
-%token IS
-%token ISNOT
-%token AWAIT
-%token NONE
-%token TRUE
-%token FALSE
-%token FOR
-%token IF
-%token ELIF
-%token ELSE
-%token EXCEPT
-%token CLASS
-%token FROM
-%token FINALLY
-%token LAMBDA
-%token YIELD
-%token AS
-%token ASSERT
-%token BREAK
-%token CONTINUE
-%token DEL
-%token GLOBAL
-%token IMPORT
-%token NONLOCAL
-%token PASS
-%token RAISE
-%token RETURN
-%token TRY
-%token WHILE
-%token WITH
-
-%token INDENT
-%token UNINDENT
-%token NEWLINE
-%token EOFILE
-%token STRING
-%token DOLAR
-
-/*
-Define both - precedence and associativity */
-%left PLUS MINUS
-%left STAR SLASH
-
-%%
-
-input_stmt: NEWLINE { printf("\n");}
- | simple_stmt { printf("%s", $$);}
- | compound_stmt NEWLINE { printf("%s\n", $$);}
- | compound_stmt { printf("%s", $$);}
-
-
-decorator: AT dotted_name NEWLINE {
- $$ = concatenate(stylize($1, "operator"), $2);
- $$ = concatenate($$, "\n");
- }
- | AT dotted_name LPAREN RPAREN NEWLINE {
- $$ = concatenate(stylize($1, "operator"), $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- $$ = concatenate($$, "\n");
- }
- | AT dotted_name LPAREN arglist RPAREN NEWLINE {
- $$ = concatenate(stylize($1, "operator"), $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- $$ = concatenate($$, $5);
- $$ = concatenate($$, "\n");
- }
-decorator_more: decorator { $$ = $1; }
- | decorator_more decorator { $$ = concatenate($1, $2);}
-decorated: decorator_more obj_definition { $$ = concatenate($1, $2);}
-obj_definition: classdef { $$ = $1; }
- | funcdef { $$ = $1; }
- | async_funcdef { $$ = $1; }
-
-/* gotovo do tuk */
-
-async_funcdef: ASYNC funcdef { $$ = concatenate(stylize($1, "keyword"), $2);}
-funcdef: DEF NAME parameters COLON suite {
- $$ = concatenate(stylize($1, "keyword"), stylize($2, "identifier"));
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- $$ = concatenate($$, $5);
- }
-parameters: LPAREN RPAREN { $$ = concatenate($1, $2);}
- | LPAREN typedargslist RPAREN {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-
-typedargslist: td_one { $$ = $1; }
- | td_two { $$ = $1; }
- | td_three { $$ = $1; }
-td_one: td_one_arg td_more_arg td_one_optional {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
- | td_one_arg td_one_optional { $$ = concatenate($1, $2);}
-td_one_arg: tfpdef ASSIGN test {
- $$ = concatenate($1, stylize($2, "operator"));
- $$ = concatenate($$, $3);
- }
- | tfpdef { $$ = $1; }
-td_more_arg: COMMA td_one_arg { $$ = concatenate($1, $2);}
- | td_more_arg COMMA td_one_arg {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-td_one_optional: COMMA td_two { $$ = concatenate($1, $2);}
- | COMMA td_three { $$ = concatenate($1, $2);}
- | COMMA { $$ = $1; }
- | { $$ = ""; }
-td_two: STAR tfpdef td_more_arg td_two_optional {
- $$ = concatenate(stylize($1, "operator"), $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- }
- | STAR td_more_arg td_two_optional {
- $$ = concatenate(stylize($1, "operator"), $2);
- $$ = concatenate($$, $3);
- }
-td_two_optional: COMMA td_three { $$ = concatenate($1, $2);}
- | COMMA { $$ = $1; }
-td_three: DOUBLESTAR tfpdef COMMA {
- $$ = concatenate(stylize($1, "operator"), $2);
- $$ = concatenate($$, $3);
- }
- | DOUBLESTAR tfpdef { $$ = concatenate(stylize($1, "operator"), $2);}
-tfpdef: NAME { $$ = $1; }
- | NAME COLON test {
- $$ = concatenate(stylize($1, "identifier"), $2);
- $$ = concatenate($$, $3);
- }
-
-varargslist: var_one { $$ = $1; }
- | var_two { $$ = $1; }
- | var_three { $$ = $1; }
-var_one: var_one_arg var_more_arg var_one_optional {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
- | var_one_arg var_one_optional { $$ = concatenate($1, $2);}
-var_one_arg: vfpdef ASSIGN test {
- $$ = concatenate($1, stylize($2, "operator"));
- $$ = concatenate($$, $3);
- }
- | vfpdef { $$ = $1; }
-var_more_arg: COMMA var_one_arg { $$ = concatenate($1, $2);}
- | var_more_arg COMMA var_one_arg {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-var_one_optional: COMMA var_two { $$ = concatenate($1, $2);}
- | COMMA var_three { $$ = concatenate($1, $2);}
- | COMMA { $$ = $1; }
-var_two: STAR vfpdef var_more_arg var_two_optional {
- $$ = concatenate(stylize($1, "operator"), $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- }
- | STAR var_more_arg var_two_optional {
- $$ = concatenate(stylize($1, "operator"), $2);
- $$ = concatenate($$, $3);
- }
-var_two_optional: COMMA var_three { $$ = concatenate($1, $2);}
- | COMMA { $$ = $1; }
-var_three: DOUBLESTAR vfpdef COMMA {
- $$ = concatenate(stylize($1, "operator"), $2);
- $$ = concatenate($$, $3);
- }
- | DOUBLESTAR vfpdef { $$ = concatenate(stylize($1, "operator"), $2);}
-vfpdef: NAME { $$ = stylize($1, "identifier"); }
-
-/* do tuk e gotovo */
-
-stmt: simple_stmt { $$ = $1; }
- | compound_stmt { $$ = $1; }
-simple_stmt: small_stmt simple_more_stmt SEMICOLON NEWLINE {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, "<br>");
- }
- | small_stmt simple_more_stmt NEWLINE {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, "<br>");
- }
- | small_stmt NEWLINE { $$ = concatenate($1, "<br>");}
- | small_stmt SEMICOLON NEWLINE {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, "<br>");
- }
-simple_more_stmt: SEMICOLON small_stmt { $$ = concatenate($1, $2);}
- | simple_more_stmt SEMICOLON small_stmt {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-small_stmt: expr_stmt { $$ = $1; }
- | del_stmt { $$ = $1; }
- | pass_stmt { $$ = $1; }
- | flow_stmt { $$ = $1; }
- | import_stmt { $$ = $1; }
- | global_stmt { $$ = $1; }
- | nonlocal_stmt { $$ = $1; }
- | assert_stmt { $$ = $1; }
-expr_stmt: testlist_star_expr expr_stmt_two { $$ = concatenate($1, $2);}
- | testlist_star_expr { $$ = $1; }
-expr_stmt_two: annassign { $$ = $1; }
- | augassign aug_expr { $$ = concatenate($1, $2);}
- | assign_more { $$ = $1; }
-assign_more: ASSIGN assign_expr { $$ = concatenate(stylize($1, "operator"), $2);}
- | assign_more ASSIGN assign_expr {
- $$ = concatenate($1, stylize($2, "operator"));
- $$ = concatenate($$, $3);
- }
-assign_expr: yield_expr { $$ = $1; }
- | testlist_star_expr { $$ = $1; }
-aug_expr: yield_expr { $$ = $1; }
- | testlist { $$ = $1; }
-annassign: COLON test { $$ = concatenate($1, $2);}
- | COLON test ASSIGN test {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, stylize($3, "operator"));
- $$ = concatenate($$, $4);
- }
-testlist_star_expr: testlist_se testlist_star_expr_more COMMA {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
- | testlist_se testlist_star_expr_more { $$ = concatenate($1, $2);}
- | testlist_se COMMA { $$ = concatenate($1, $2);}
- | testlist_se { $$ = $1; }
-testlist_se: test { $$ = $1; }
- | star_expr { $$ = $1; }
-testlist_star_expr_more: COMMA testlist_se { $$ = concatenate($1, $2);}
- | testlist_star_expr_more COMMA testlist_se {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-augassign: PLUSASSIGN { $$ = stylize($1, "operator");}
- | MINUSASSIGN { $$ = stylize($1, "operator");}
- | STARASSIGN { $$ = stylize($1, "operator");}
- | ATASSIGN { $$ = stylize($1, "operator");}
- | SLASHASSIGN { $$ = stylize($1, "operator");}
- | PERCENTASSIGN { $$ = stylize($1, "operator");}
- | BOOLANDASSIGN { $$ = stylize($1, "operator");}
- | BOOLORASSIGN { $$ = stylize($1, "operator");}
- | HATASSIGN { $$ = stylize($1, "operator");}
- | SHIFTLEFTASSIGN { $$ = stylize($1, "operator");}
- | SHIFTRIGHTASSIGN { $$ = stylize($1, "operator");}
- | DOUBLESTARASSIGN { $$ = stylize($1, "operator");}
- | DOUBLESLASHASSIGN { $$ = stylize($1, "operator");}
-
-del_stmt: DEL exprlist { $$ = concatenate(stylize($1, "keyword"), $2);}
-pass_stmt: PASS { $$ = stylize($1, "keyword");}
-flow_stmt: break_stmt { $$ = $1; }
- | continue_stmt { $$ = $1; }
- | return_stmt { $$ = $1; }
- | raise_stmt { $$ = $1; }
- | yield_stmt { $$ = $1; }
-break_stmt: BREAK { $$ = stylize($1, "keyword");}
-continue_stmt: CONTINUE { $$ = stylize($1, "keyword");}
-return_stmt: RETURN { $$ = stylize($1, "keyword");}
- | RETURN testlist { $$ = concatenate(stylize($1, "keyword"), $2);}
-yield_stmt: yield_expr { $$ = $1; }
-raise_stmt: RAISE { $$ = stylize($1, "keyword");}
- | RAISE test { $$ = concatenate(stylize($1, "keyword"), $2);}
- | RAISE test FROM test {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, stylize($3, "keyword"));
- $$ = concatenate($$, $4);
- }
-import_stmt: import_name { $$ = $1; }
- | import_from { $$ = $1; }
-import_name: IMPORT dotted_as_names { $$ = concatenate(stylize($1, "keyword"), $2);}
-import_from: FROM import_from_name IMPORT import_from_import {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, stylize($3, "keyword"));
- $$ = concatenate($$, $4);
- }
-import_from_name: dotted_name { $$ = $1; }
- | dots_more dotted_name { $$ = concatenate($1, $2);}
- | dots_more { $$ = $1; }
-dots: DOT { $$ = $1; }
- | THREEDOTS { $$ = $1; }
-dots_more: dots { $$ = $1; }
- | dots_more dots { $$ = concatenate($1, $2);}
-import_from_import: STAR { $$ = stylize($1, "operator");}
- | LPAREN import_as_names RPAREN {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
- | import_as_names { $$ = $1; }
-import_as_name: NAME { $$ = stylize($1, "identifier");}
- | NAME AS NAME {
- $$ = concatenate(stylize($1, "identifier"), stylize($2, "operator"));
- $$ = concatenate($$, stylize($3, "identifier"));
- }
-dotted_as_name: dotted_name { $$ = $1; }
- | dotted_name AS NAME {
- $$ = concatenate($1, stylize($2, "operator"));
- $$ = concatenate($$, stylize($3, "identifier"));
- }
-import_as_names: import_as_name COMMA { $$ = concatenate($1, $2);}
- | import_as_name { $$ = $1; }
- | import_as_name import_as_name_more COMMA {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
- | import_as_name import_as_name_more { $$ = concatenate($1, $2);}
-import_as_name_more: COMMA import_as_name { $$ = concatenate($1, $2);}
- | import_as_name_more COMMA import_as_name {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-dotted_as_names: dotted_as_name { $$ = $1; }
- | dotted_as_name dotted_as_name_more { $$ = concatenate($1, $2);}
-dotted_as_name_more: COMMA dotted_as_name { $$ = concatenate($1, $2);}
- | dotted_as_name_more COMMA dotted_as_name {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-dotted_name: NAME { $$ = stylize($1, "identifier");}
- | NAME dotted_name_more { $$ = concatenate(stylize($1, "identifier"), $2);}
-dotted_name_more: DOT NAME { $$ = concatenate($1, stylize($2, "identifier"));}
- | dotted_name_more DOT NAME {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, stylize($3, "identifier"));
- }
-global_stmt: GLOBAL NAME { $$ = concatenate(stylize($1, "keyword"), stylize($2, "identifier"));}
- | GLOBAL NAME global_stmt_more {
- $$ = concatenate(stylize($1, "keyword"), stylize($2, "identifier"));
- $$ = concatenate($$, $3);
- }
-global_stmt_more: COMMA NAME { $$ = concatenate($1, stylize($2, "identifier"));}
- | global_stmt_more COMMA NAME {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, stylize($3, "identifier"));
- }
-nonlocal_stmt: NONLOCAL NAME { $$ = concatenate(stylize($1, "keyword"), stylize($2, "identifier"));}
- | NONLOCAL NAME nonlocal_stmt_more {
- $$ = concatenate(stylize($1, "keyword"), stylize($2, "identifier"));
- $$ = concatenate($$, $3);
- }
-nonlocal_stmt_more: COMMA NAME { $$ = concatenate($1, stylize($2, "identifier"));}
- | nonlocal_stmt_more COMMA NAME {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, stylize($3, "identifier"));;
- }
-assert_stmt: ASSERT test { $$ = concatenate(stylize($1, "keyword"), $2);}
- | ASSERT COMMA test {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- }
-
-compound_stmt: if_stmt { $$ = $1; }
- | while_stmt { $$ = $1; }
- | for_stmt { $$ = $1; }
- | try_stmt { $$ = $1; }
- | with_stmt { $$ = $1; }
- | funcdef { $$ = $1; }
- | classdef { $$ = $1; }
- | decorated { $$ = $1; }
- | async_stmt { $$ = $1; }
-async_stmt: ASYNC funcdef { $$ = concatenate(stylize($1, "keyword"), $2);}
- | ASYNC with_stmt { $$ = concatenate(stylize($1, "keyword"), $2);}
- | ASYNC for_stmt { $$ = concatenate(stylize($1, "keyword"), $2);}
-
-if_stmt: IF test COLON suite elif_stmt_more else_stmt {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- $$ = concatenate($$, $5);
- $$ = concatenate($$, $6);
- }
- | IF test COLON suite elif_stmt_more {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- $$ = concatenate($$, $5);
- }
- | IF test COLON suite else_stmt {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- $$ = concatenate($$, $5);
- }
- | IF test COLON suite {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- }
-elif_stmt: ELIF test COLON suite {
- $$ = $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- }
-else_stmt: ELSE COLON suite {
- $$ = $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- }
-elif_stmt_more: elif_stmt { $$ = $1; }
- | elif_stmt_more elif_stmt { $$ = concatenate($1, $2);}
-
-while_stmt: WHILE test COLON suite {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- }
- | WHILE test COLON suite else_stmt {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- $$ = concatenate($$, $5);
- }
-
-for_stmt: FOR exprlist IN testlist COLON suite {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, stylize($3, "operator"));
- $$ = concatenate($$, $4);
- $$ = concatenate($$, $5);
- $$ = concatenate($$, $6);
- }
- | FOR exprlist IN testlist COLON suite else_stmt {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, stylize($3, "operator"));
- $$ = concatenate($$, $4);
- $$ = concatenate($$, $5);
- $$ = concatenate($$, $6);
- $$ = concatenate($$, $7);
- }
-
-try_stmt: TRY COLON suite try_stmt_two {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- }
-try_stmt_two: except_fin_stmt { $$ = $1; }
- | finally_stmt { $$ = $1; }
-finally_stmt: FINALLY COLON suite {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- }
-except_fin_stmt: except_stmt_more { $$ = $1; }
- | except_stmt_more else_stmt { $$ = concatenate($1, $2);}
- | except_stmt_more finally_stmt { $$ = concatenate($1, $2);}
- | except_stmt_more else_stmt finally_stmt {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-except_stmt_more: except_stmt { $$ = $1; }
- | except_stmt_more except_stmt { $$ = concatenate($1, $2);}
-except_stmt: except_clause COLON suite {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-except_clause: EXCEPT { $$ = stylize($1, "keyword"); }
- | EXCEPT test { $$ = concatenate(stylize($1, "keyword"), $2);}
- | EXCEPT test AS NAME {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, stylize($3, "operator"));
- $$ = concatenate($$, stylize($4, "identifier"));
- }
-with_stmt: WITH with_item with_item_more COLON suite {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- $$ = concatenate($$, $5);
- }
- | WITH with_item COLON suite {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- }
-with_item: test { $$ = $1; }
- | test AS expr {
- $$ = concatenate($1, stylize($2, "operator"));
- $$ = concatenate($$, $3);
- }
-with_item_more: COMMA with_item { $$ = concatenate($1, $2);}
- | with_item_more COMMA with_item {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-suite: simple_stmt { $$ = $1; }
- | NEWLINE INDENT stmt_more UNINDENT {
- $$ = concatenate("<br>", $2);
- $$ = concatenate($2, $3);
- $$ = concatenate($$, "");
- /* $$ = concatenate($$, $4); */
- $$ = collapsableBlock($$);
- }
-stmt_more: stmt { $$ = $1; }
- | stmt_more stmt { $$ = concatenate($1, $2);}
-
-
-test: or_test { $$ = $1; }
- | or_test IF or_test ELSE test {
- $$ = concatenate($1, stylize($2, "keyword"));
- $$ = concatenate($$, $3);
- $$ = concatenate($$, stylize($4, "keyword"));
- $$ = concatenate($$, $5);
- }
- | lambdadef { $$ = $1; }
-test_nocond: or_test { $$ = $1; }
- | lambdadef_nocond { $$ = $1; }
-lambdadef: LAMBDA COLON test {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- }
- | LAMBDA varargslist COLON test {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- }
-lambdadef_nocond: LAMBDA COLON test_nocond {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- }
- | LAMBDA varargslist COLON test {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- }
-or_test: and_test or_test_more { $$ = concatenate($1, $2);}
-or_test_more: OR and_test or_test_more {
- $$ = concatenate(stylize($1, "operator"), $2);
- $$ = concatenate($$, $3);
- }
- | { $$ = ""; }
-and_test: not_test and_test_more { $$ = concatenate($1, $2);}
-and_test_more: AND not_test and_test_more {
- $$ = concatenate(stylize($1, "operator"), $2);
- $$ = concatenate($$, $3);
- }
- | { $$ = ""; }
-not_test: NOT not_test { $$ = concatenate(stylize($1, "operator"), $2);}
- | comparison { $$ = $1; }
-comparison: expr { $$ = $1; }
- | expr comp_more { $$ = concatenate($1, $2);}
-comp_more: comp_op expr { $$ = concatenate($1, $2);}
- | comp_more comp_op expr {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-comp_op: LESS { $$ = stylize($1, "operator");}
- | BIGGER { $$ = stylize($1, "operator");}
- | EQL { $$ = stylize($1, "operator");}
- | LESSEQL { $$ = stylize($1, "operator");}
- | BIGGEREQL { $$ = stylize($1, "operator");}
- | NOTEQL { $$ = stylize($1, "operator");}
- | IN { $$ = stylize($1, "operator");}
- | NOTIN { $$ = stylize($1, "operator");}
- | IS { $$ = stylize($1, "operator");}
- | ISNOT { $$ = stylize($1, "operator");}
-star_expr: STAR expr { $$ = concatenate(stylize($1, "operator"), $2);}
-expr: xor_expr { $$ = $1; }
- | xor_expr expr_more { $$ = concatenate($1, $2);}
-expr_more: BOOLOR xor_expr { $$ = concatenate(stylize($1, "operator"), $2);}
- | expr_more BOOLOR xor_expr {
- $$ = concatenate($1, stylize($2, "operator"));
- $$ = concatenate($$, $3);
- }
-xor_expr: and_expr { $$ = $1; }
- | and_expr xor_expr_more { $$ = concatenate($1, $2);}
-xor_expr_more: HAT and_expr { $$ = concatenate(stylize($1, "operator"), $2);}
- | xor_expr_more HAT and_expr {
- $$ = concatenate($1, stylize($2, "operator"));
- $$ = concatenate($$, $3);
- }
-and_expr: shift_expr { $$ = $1; }
- | shift_expr and_expr_more { $$ = concatenate($1, $2);}
-and_expr_more: BOOLAND shift_expr { $$ = concatenate(stylize($1, "operator"), $2);}
- | and_expr_more BOOLAND shift_expr {
- $$ = concatenate($1, stylize($2, "operator"));
- $$ = concatenate($$, $3);
- }
-shift_expr: arith_expr { $$ = $1; }
- | arith_expr shift_expr_more { $$ = concatenate($1, $2);}
-shift_expr_more: shift_op arith_expr { $$ = concatenate($1, $2);}
- | shift_expr_more shift_op arith_expr {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-shift_op: SHIFTLESS { $$ = stylize($1, "operator");}
- | SHIFTRIGHT { $$ = stylize($1, "operator");}
-arith_expr: term { $$ = $1; }
- | term arith_expr_more { $$ = concatenate($1, $2);}
-arith_expr_more: arith_op term { $$ = concatenate($1, $2);}
- | arith_expr_more arith_op term {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-arith_op: PLUS { $$ = stylize($1, "operator");}
- | MINUS { $$ = stylize($1, "operator");}
-term: factor { $$ = $1; }
- | factor term_more { $$ = concatenate($1, $2);}
-term_more: term_op factor { $$ = concatenate($1, $2);}
- | term_more term_op factor {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-term_op: STAR { $$ = stylize($1, "operator");}
- | AT { $$ = stylize($1, "operator");}
- | SLASH { $$ = stylize($1, "operator");}
- | PERCENT { $$ = stylize($1, "operator");}
- | DOUBLESLASH { $$ = stylize($1, "operator");}
-factor: unar_op factor { $$ = concatenate($1, $2); }
- | power { $$ = $1; }
-unar_op: PLUS { $$ = stylize($1, "operator");}
- | MINUS { $$ = stylize($1, "operator");}
- | TILDA { $$ = stylize($1, "operator");}
-power: atom_expr { $$ = $1; }
- | atom_expr DOUBLESTAR factor { $$ = concatenate3($1, stylize($2, "operator"), $3);}
-atom_expr: AWAIT atom { $$ = concatenate(stylize($1, "operator"), $2);}
- | atom { $$ = $1; }
- | AWAIT atom trailer_more {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- }
- | atom trailer_more { $$ = concatenate($1, $2);}
-atom: LPAREN RPAREN { $$ = concatenate($1, $2);}
- | LPAREN yield_expr RPAREN { $$ = concatenate3($1, $2, $3);}
- | LPAREN testlist_comp RPAREN { $$ = concatenate3($1, $2, $3);}
- | LSQPAREN RSQPAREN { $$ = concatenate($1, $2);}
- | LSQPAREN testlist_comp RSQPAREN { $$ = concatenate3($1, $2, $3); }
- | LCURPAREN RCURPAREN { $$ = concatenate($1, $2);}
- | LCURPAREN dictorsetmaker RCURPAREN { $$ = concatenate3($1, $2, $3); }
- | NAME { $$ = stylize($1, "identifier");}
- | NUMBER { $$ = stylize($1, "number");}
- | STRING { $$ = stylize($1, "string");}
- | THREEDOTS { $$ = stylize($1, "operator");}
- | NONE { $$ = stylize($1, "constant");}
- | TRUE { $$ = stylize($1, "constant");}
- | FALSE { $$ = stylize($1, "constant");}
- | DOLAR { $$ = "";}
-testlist_comp: test testlist_comp_second { $$ = concatenate($1, $2);}
- | star_expr testlist_comp_second { $$ = concatenate($1, $2);}
-testlist_comp_second: comp_for { $$ = $1; }
- | testlist_more_arg { $$ = $1; }
-testlist_more_arg: COMMA test COMMA {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
- | COMMA test { $$ = concatenate($1, $2);}
- | testlist_more_arg COMMA test COMMA {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- }
- | testlist_more_arg COMMA test {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
- | testlist_more_arg COMMA star_expr COMMA {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- }
- | testlist_more_arg COMMA star_expr {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-trailer: LPAREN RPAREN { $$ = concatenate($1, $2);}
- | LPAREN arglist RPAREN {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
- | LSQPAREN subscriptlist RSQPAREN {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
- | DOT NAME { $$ = concatenate($1, stylize($2, "identifier"));}
-trailer_more: trailer { $$ = $1; }
- | trailer_more trailer { $$ = concatenate($1, $2);}
-subscriptlist: subscript COMMA { $$ = concatenate($1, $2);}
- | subscript { $$ = $1; }
- | subscript subscipt_more COMMA {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
- | subscript subscipt_more { $$ = concatenate($1, $2);}
-subscipt_more: COMMA subscript { $$ = concatenate($1, $2);}
- | subscipt_more COMMA subscript {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-subscript: test { $$ = $1; }
- | COLON { $$ = $1; }
- | COLON test { $$ = concatenate($1, $2);}
- | COLON sliceop { $$ = concatenate($1, $2);}
- | COLON test sliceop {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
- | test COLON { $$ = concatenate($1, $2);}
- | test COLON test { $$ = concatenate($1, $2);}
- | test COLON sliceop {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
- | test COLON test sliceop {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- }
-sliceop: COLON test { $$ = concatenate($1, $2);}
- | COLON { $$ = $1; }
-exprlist: exprlist_op COMMA { $$ = concatenate($1, $2);}
- | exprlist_op { $$ = $1; }
- | exprlist_op exprlist_more COMMA {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
- | exprlist_op exprlist_more { $$ = concatenate($1, $2);}
-exprlist_more: COMMA exprlist_op { $$ = concatenate($1, $2);}
- | exprlist_more COMMA exprlist_op {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-exprlist_op: expr { $$ = $1; }
- | star_expr { $$ = $1; }
-testlist: test { $$ = $1; }
- | test COMMA { $$ = concatenate($1, $2);}
- | test testlist_more { $$ = concatenate($1, $2);}
- | test testlist_more COMMA {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-testlist_more: COMMA test { $$ = concatenate($1, $2);}
- | testlist_more COMMA test {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-dictorsetmaker: test_star_expr dsm_one { $$ = concatenate($1, $2);}
- | test_star_expr COMMA { $$ = concatenate($1, $2);} /* in the case test_star_expr is zero times */
- | test_star_expr { $$ = $1; } /* in the case test_star_expr is zero times */
- | test_star_expr_2 dsm_two { $$ = concatenate($1, $2);}
- | test_star_expr_2 COMMA { $$ = concatenate($1, $2);}/* in the case test_star_expr_2 is zero times */
- | test_star_expr_2 { $$ = $1; } /* in the case test_star_expr_2 is zero times */
-test_star_expr: test COLON test {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
- | DOUBLESTAR expr { $$ = concatenate(stylize($1, "operator"), $2);}
-dsm_one: comp_for { $$ = $1; }
- | comp_for COMMA { $$ = concatenate($1, $2);}
- | test_star_expr_more COMMA { $$ = concatenate($1, $2);}
- | test_star_expr_more { $$ = $1; }
-test_star_expr_more: COMMA test_star_expr { $$ = concatenate($1, $2);}
- | test_star_expr_more COMMA test_star_expr {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-test_star_expr_2: test { $$ = $1; }
- | star_expr { $$ = $1; }
-dsm_two: comp_for { $$ = $1; }
- | comp_for COMMA { $$ = concatenate($1, $2);}
- | test_star_expr_2_more COMMA { $$ = concatenate($1, $2);}
- | test_star_expr_2_more { $$ = $1; }
-test_star_expr_2_more: COMMA test_star_expr_2 { $$ = concatenate($1, $2);}
- | test_star_expr_2_more COMMA test_star_expr_2 {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-
-classdef: CLASS NAME COLON suite {
- $$ = concatenate(stylize($1, "keyword"), stylize($2, "identifier"));
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- }
- | CLASS NAME LPAREN RPAREN COLON suite {
- $$ = concatenate(stylize($1, "keyword"), stylize($2, "identifier"));
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- $$ = concatenate($$, $5);
- $$ = concatenate($$, $6);
- }
- | CLASS NAME LPAREN arglist RPAREN COLON suite {
- $$ = concatenate(stylize($1, "keyword"), stylize($2, "identifier"));
- $$ = concatenate($$, $3);
- $$ = concatenate($$, $4);
- $$ = concatenate($$, $5);
- $$ = concatenate($$, $6);
- $$ = concatenate($$, $7);
- }
-arglist: argument COMMA { $$ = concatenate($1, $2);}
- | argument { $$ = $1; }
- | argument arglist_more COMMA {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
- | argument arglist_more { $$ = concatenate($1, $2);}
-arglist_more: COMMA argument { $$ = concatenate($1, $2);}
- | arglist_more COMMA argument {
- $$ = concatenate($1, $2);
- $$ = concatenate($$, $3);
- }
-argument: test comp_for { $$ = concatenate($1, $2);}
- | test { $$ = $1; }
- | test ASSIGN test {
- $$ = concatenate($1, stylize($2, "operator"));
- $$ = concatenate($$, $3);
- }
- | DOUBLESTAR test { $$ = concatenate(stylize($1, "operator"), $2);}
- | STAR test { $$ = concatenate(stylize($1, "operator"), $2);}
-comp_iter: comp_for { $$ = $1; }
- | comp_if { $$ = $1; }
-sync_comp_for: FOR exprlist IN or_test {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, stylize($3, "operator"));
- $$ = concatenate($$, $4);
- }
- | FOR exprlist IN or_test comp_iter {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, stylize($3, "operator"));
- $$ = concatenate($$, $4);
- $$ = concatenate($$, $5);
- }
-comp_for: sync_comp_for { $$ = $1; }
- | ASYNC comp_for { $$ = concatenate(stylize($1, "keyword"), $2);}
-comp_if: IF test_nocond { $$ = concatenate(stylize($1, "keyword"), $2);}
- | IF test_nocond comp_iter {
- $$ = concatenate(stylize($1, "keyword"), $2);
- $$ = concatenate($$, $3);
- }
-
-/* encoding_decl: NAME */
-
-yield_expr: YIELD { $$ = stylize($1, "keyword");}
- | YIELD yield_arg { $$ = concatenate(stylize($1, "keyword"), $2);}
-yield_arg: FROM test { $$ = concatenate(stylize($1, "keyword"), $2);}
- | testlist { $$ = $1; }
-
-%%
-int yyerror(const char* error)
-{
- extern int current_line;
- fprintf(stderr, "input:%d: error: %s\n", current_line, error);
- return 0;
-}
-
-void printHtmlHeader(){
- puts(
- "<head>"
- " <title>python-parse.html</title>"
- );
- printStyles();
- puts(
- "</head>"
- );
-}
-void printBody() {
- puts(
- "<body bgcolor=\"#e2cdb7\">"
- " <pre class=\"code\">"
- );
- yyparse();
- puts("</pre></body>");
-}
-void printHTML() {
- puts(
- "<!doctype>"
- "<html>"
- );
- printHtmlHeader();
- printBody();
- printCollapsableScript();
- puts("</html>");
-}
-
-
-int main(int argc, const char* argv[])
-{
- #if YYDEBUG
- yydebug = 1;
- #endif
- //printHTML();
- FILE *myfile = fopen("input.file", "r");
-if (!myfile) {
- printf("I can't open input.file!\n");
- return -1;
-}
-yyin = myfile;
- printHTML();
- return 0;
-}
diff --git a/homework/81350/parser/colapser/stack.c b/homework/81350/parser/colapser/stack.c
deleted file mode 100644
index c6edd42..0000000
--- a/homework/81350/parser/colapser/stack.c
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "stack.h"
-
-int stack[MAXSIZE];
-int top = -1;
-
-int isempty() {
-
- if(top == -1)
- return 1;
- else
- return 0;
-}
-
-int isfull() {
-
- if(top == MAXSIZE)
- return 1;
- else
- return 0;
-}
-
-int peek() {
- return stack[top];
-}
-
-int pop() {
- int data;
-
- if(!isempty()) {
- data = stack[top];
- top = top - 1;
- return data;
- } else {
- printf("Could not retrieve data, Stack is empty.\n");
- }
-}
-
-int push(int data) {
-
- if(!isfull()) {
- top = top + 1;
- stack[top] = data;
- } else {
- printf("Could not insert data, Stack is full.\n");
- }
-}
-
-char* concatenate(char* first, char* second) {
- int firstlen = strlen(first);
- int secondlen = strlen(second);
- char* result;
- result = malloc(firstlen + secondlen + 1);
- strcpy(result, first);
- strcat(result, second);
- return result;
-}
diff --git a/homework/81350/parser/colapser/stack.h b/homework/81350/parser/colapser/stack.h
deleted file mode 100644
index 83c2741..0000000
--- a/homework/81350/parser/colapser/stack.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#pragma once
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#define MAXSIZE 1000
-extern int stack[MAXSIZE];
-extern int top;
-
-int isempty();
-int isfull();
-int peek();
-int pop();
-int push(int);
-
-char* concatenate(char*, char*);
diff --git a/homework/81350/parser/input.file b/homework/81350/parser/input.file
deleted file mode 100644
index d39ec80..0000000
--- a/homework/81350/parser/input.file
+++ /dev/null
@@ -1,3 +0,0 @@
-func():
- a=2
- a=2+3
diff --git a/homework/81350/parser/lexer.lex b/homework/81350/parser/lexer.lex
deleted file mode 100644
index 03ea391..0000000
--- a/homework/81350/parser/lexer.lex
+++ /dev/null
@@ -1,182 +0,0 @@
-%{
-/* need this for the call to atof() below */
-#include <math.h>
-#include "parser.tab.h"
-#include "stack.h"
-#define YY_NO_UNISTD_H
-static const unsigned int TAB_WIDTH = 2;
-
-#define YY_USER_INIT { push(0); BEGIN(initial); }
-int current_line = 0;
-int current_line_indent = 0;
-int indent_level = 0;
-int is_fake_sym = 0;
-%}
-
-digit [0-9]
-number [1-9]{digit}*
-fnumber {digit}+"."{digit}*
-letter [a-zA-Z]
-string ["]{3}(["]{0,2}([^\\"]|\\(.|\n)))*["]{3}
-
-%x initial
-%x indent
-%s normal
-
-%%
- int indent_caller = normal;
-<*>"\n" { REJECT; }
-
-<initial>. { unput(*yytext); indent_caller = normal; BEGIN(indent); }
-<initial>\n { indent_caller = normal; BEGIN(indent); }
-
-<indent>" " { current_line_indent++;}
-<indent>"\t" { current_line_indent = (current_line_indent+2) & ~1;} /* one tab is 2 spaces*/
-<indent>"\n" { current_line_indent = 0; return NEWLINE;}
-<indent><<EOF>> {
- if(peek() != 0){
- pop();
- if(current_line_indent != peek()){
- unput('\n');
- for(int i=0; i< peek(); i++){
- unput(' ');
- }
- } else {
- BEGIN(indent_caller);
- }
- return UNINDENT;
- } else {
- yyterminate();
- }
- }
-<indent>. {
- if(!is_fake_sym){
- unput(*yytext);
- }
- is_fake_sym = 0;
- if (current_line_indent > peek()) {
- push(current_line_indent);
- BEGIN(indent_caller);
- return INDENT;
- } else if (current_line_indent < peek()) {
- pop();
- if(current_line_indent != peek()){
- for(int i=0; i< current_line_indent; i++){
- unput(' ');
- }
- unput('\n');
-
- unput('.');
- is_fake_sym = 1;
- for(int i=0; i < peek(); i++){
- unput(' ');
- is_fake_sym = 1;
- }
- unput('\n');
- is_fake_sym = 1;
- } else {
- BEGIN(indent_caller);
- }
- return UNINDENT;
- } else {
- BEGIN(indent_caller);
- }
- }
-<normal>"\n" { current_line_indent = 0; indent_caller = YY_START; BEGIN(indent); return NEWLINE;}
-
-<normal>{number}|{fnumber} { yylval.Number = atof(yytext); return NUMBER; }
-<normal>{digit} { yylval.Number = atof(yytext); return NUMBER;}
-<normal>{string} { strcpy(yylval.Lexeme, strdup(yytext)); return STRING;}
-
-<normal>"+" { return PLUS; }
-<normal>"-" { return MINUS; }
-<normal>"*" { return STAR; }
-<normal>"/" { return SLASH; }
-<normal>"//" { return DOUBLESLASH;}
-<normal>"%" { return PERCENT; }
-<normal>"**" { return DOUBLESTAR; }
-<normal>">" { return BIGGER; }
-<normal>"<" { return LESS; }
-<normal>">=" { return BIGGEREQL; }
-<normal>"<=" { return LESSEQL; }
-<normal>"==" { return EQL; }
-<normal>"!=" { return NOTEQL; }
-
-
-<normal>"&" { return BOOLAND; }
-<normal>"|" { return BOOLOR; }
-<normal>"~" { return TILDA; }
-<normal>"^" { return HAT; }
-<normal>">>" { return SHIFTRIGHT; }
-<normal>"<<" { return SHIFTLESS; }
-
-
-<normal>"=" { return ASSIGN; }
-<normal>"+=" { return PLUSASSIGN; }
-<normal>"-=" { return MINUSASSIGN;}
-<normal>"*=" { return STARASSIGN; }
-<normal>"/=" { return SLASHASSIGN;}
-<normal>"%=" { return PERCENTASSIGN;}
-<normal>"**=" { return DOUBLESTARASSIGN;}
-<normal>"//=" { return DOUBLESLASHASSIGN;}
-<normal>"^=" { return HATASSIGN;}
-<normal>"&=" { return BOOLANDASSIGN;}
-<normal>"|=" { return BOOLORASSIGN;}
-<normal>">>=" { return SHIFTRIGHTASSIGN;}
-<normal>"<<=" { return SHIFTLEFTASSIGN;}
-<normal>"@=" { return ATASSIGN; }
-
-<normal>"@" { return AT;}
-<normal>"(" { return LPAREN; }
-<normal>")" { return RPAREN; }
-<normal>"[" { return LSQPAREN;}
-<normal>"]" { return RSQPAREN;}
-<normal>"{" { return LCURPAREN;}
-<normal>"}" { return RCURPAREN;}
-<normal>";" { return SEMICOLON; }
-<normal>":" { return COLON; }
-<normal>"," { return COMMA; }
-<normal>"." { return DOT; }
-<normal>"..." { return THREEDOTS;}
-
-<normal>"async" { return ASYNC;}
-<normal>"def" { return DEF; }
-<normal>"and" { return AND;}
-<normal>"or" { return OR;}
-<normal>"not" { return NOT;}
-<normal>"in" { return IN;}
-<normal>"not in" { return NOTIN;}
-<normal>"is" { return IS;}
-<normal>"is not" { return ISNOT;}
-<normal>"await" { return AWAIT;}
-<normal>"None" { return NONE;}
-<normal>"True" { return TRUE;}
-<normal>"False" { return FALSE;}
-<normal>"class" { return CLASS;}
-<normal>"for" { return FOR;}
-<normal>"if" { return IF;}
-<normal>"elif" { return ELIF;}
-<normal>"else" { return ELSE;}
-<normal>"except" { return EXCEPT;}
-<normal>"from" { return FROM;}
-<normal>"finally" { return FINALLY;}
-<normal>"lambda" { return LAMBDA;}
-<normal>"yield" { return YIELD;}
-<normal>"as" { return AS;}
-<normal>"assert" { return ASSERT;}
-<normal>"break" { return BREAK;}
-<normal>"continue" { return CONTINUE;}
-<normal>"del" { return DEL;}
-<normal>"global" { return GLOBAL;}
-<normal>"import" { return IMPORT;}
-<normal>"nonlocal" { return NONLOCAL;}
-<normal>"pass" { return PASS;}
-<normal>"raise" { return RAISE;}
-<normal>"return" { return RETURN;}
-<normal>"try" { return TRY;}
-<normal>"while" { return WHILE;}
-<normal>"with" { return WITH;}
-
-<normal>{letter}({letter}|{digit})* {
- strcpy(yylval.Lexeme, strdup(yytext));
-return NAME; }
diff --git a/homework/81350/parser/parser.y b/homework/81350/parser/parser.y
deleted file mode 100644
index 97d7393..0000000
--- a/homework/81350/parser/parser.y
+++ /dev/null
@@ -1,441 +0,0 @@
-
-%code requires {
-#include <stdio.h>
-#include <string.h>
-int yylex();
-int yyerror(const char* error);
-FILE *yyin;
-#undef YYDEBUG
-#define YYDEBUG 1
-/* #define YY_DECL int yylex(scanner) void* scanner; */
-}
-
-%start input_stmt
-/* %define api.pure full */
-%define api.value.type {union name { double Number; char Lexeme[256];} }
-
-%token NUMBER
-%token PLUS
-%token MINUS
-%token STAR
-%token SLASH
-%token DOUBLESLASH
-%token PERCENT
-%token DOUBLESTAR
-%token BIGGER
-%token LESS
-%token BIGGEREQL
-%token LESSEQL
-%token EQL
-%token NOTEQL
-
-%token BOOLAND
-%token BOOLOR
-%token TILDA
-%token HAT
-%token SHIFTRIGHT
-%token SHIFTLESS
-
-%token ASSIGN
-%token PLUSASSIGN
-%token MINUSASSIGN
-%token STARASSIGN
-%token SLASHASSIGN
-%token PERCENTASSIGN
-%token DOUBLESTARASSIGN
-%token DOUBLESLASHASSIGN
-%token HATASSIGN
-%token BOOLANDASSIGN
-%token BOOLORASSIGN
-%token SHIFTRIGHTASSIGN
-%token SHIFTLEFTASSIGN
-%token ATASSIGN
-
-%token LPAREN
-%token RPAREN
-%token LSQPAREN
-%token RSQPAREN
-%token LCURPAREN
-%token RCURPAREN
-%token SEMICOLON
-%token COLON
-%token COMMA
-%token DOT
-%token AT
-%token THREEDOTS
-
-%token NAME
-
-%token DEF
-%token ASYNC
-%token AND
-%token OR
-%token NOT
-%token IN
-%token NOTIN
-%token IS
-%token ISNOT
-%token AWAIT
-%token NONE
-%token TRUE
-%token FALSE
-%token FOR
-%token IF
-%token ELIF
-%token ELSE
-%token EXCEPT
-%token CLASS
-%token FROM
-%token FINALLY
-%token LAMBDA
-%token YIELD
-%token AS
-%token ASSERT
-%token BREAK
-%token CONTINUE
-%token DEL
-%token GLOBAL
-%token IMPORT
-%token NONLOCAL
-%token PASS
-%token RAISE
-%token RETURN
-%token TRY
-%token WHILE
-%token WITH
-
-%token INDENT
-%token UNINDENT
-%token NEWLINE
-%token EOFILE
-%token STRING
-
-/*
-Define both - precedence and associativity */
-%left PLUS MINUS
-%left STAR SLASH
-
-%%
-/*
-input:
- | expr { printf("%f\n", $1.Number); }
- ;
-expr: NUMBER { $$.Number = $1.Number; }
- | '(' expr ')' { $$.Number = $2.Number; }
- | expr PLUS expr { $$.Number = $1.Number + $3.Number; }
- | expr MINUS expr { $$.Number = $1.Number - $3.Number; }
- | expr STAR expr { $$.Number = $1.Number * $3.Number; }
- | expr SLASH expr { $$.Number = $1.Number / $3.Number; }
-*/
-
-input_stmt: NEWLINE | simple_stmt | compound_stmt NEWLINE | compound_stmt
-
-
-decorator: AT dotted_name NEWLINE
- | AT dotted_name LPAREN RPAREN NEWLINE
- | AT dotted_name LPAREN arglist RPAREN NEWLINE
-decorator_more: decorator | decorator_more decorator
-decorated: decorator_more obj_definition
-obj_definition: classdef | funcdef | async_funcdef
-
-
-async_funcdef: ASYNC funcdef
-funcdef: DEF NAME parameters COLON suite /* | DEF NAME parameters '->' test COLON suite */
-parameters: LPAREN RPAREN | LPAREN typedargslist RPAREN
-
-typedargslist: td_one | td_two | td_three
-td_one: td_one_arg td_more_arg td_one_optional | td_one_arg td_one_optional
-td_one_arg: tfpdef ASSIGN test | tfpdef
-td_more_arg: COMMA td_one_arg | td_more_arg COMMA td_one_arg
-/* td_add_arg: COMMA td_one_arg td_more_arg */
-td_one_optional: COMMA td_two | COMMA td_three | COMMA |
-td_two: STAR tfpdef td_more_arg td_two_optional | STAR td_more_arg td_two_optional
-td_two_optional: COMMA td_three | COMMA
-td_three: DOUBLESTAR tfpdef COMMA | DOUBLESTAR tfpdef
-tfpdef: NAME | NAME COLON test
-
-varargslist: var_one | var_two | var_three
-var_one: var_one_arg var_more_arg var_one_optional | var_one_arg var_one_optional
-var_one_arg: vfpdef ASSIGN test | vfpdef
-var_more_arg: COMMA var_one_arg | var_more_arg COMMA var_one_arg
-var_one_optional: COMMA var_two | COMMA var_three | COMMA
-var_two: STAR vfpdef var_more_arg var_two_optional | STAR var_more_arg var_two_optional
-var_two_optional: COMMA var_three | COMMA
-var_three: DOUBLESTAR vfpdef COMMA | DOUBLESTAR vfpdef
-vfpdef: NAME
-
-stmt: simple_stmt
- | compound_stmt
-simple_stmt: small_stmt simple_more_stmt SEMICOLON NEWLINE
- | small_stmt simple_more_stmt NEWLINE
- | small_stmt NEWLINE
- | small_stmt SEMICOLON NEWLINE
-simple_more_stmt: SEMICOLON small_stmt
- | simple_more_stmt SEMICOLON small_stmt
-small_stmt: expr_stmt
- | del_stmt
- | pass_stmt
- | flow_stmt
- | import_stmt
- | global_stmt
- | nonlocal_stmt
- | assert_stmt
-expr_stmt: testlist_star_expr expr_stmt_two
- | testlist_star_expr
-expr_stmt_two: annassign
- | augassign aug_expr
- | assign_more
-assign_more: ASSIGN assign_expr
- | assign_more ASSIGN assign_expr
-assign_expr: yield_expr
- | testlist_star_expr
-aug_expr: yield_expr
- | testlist
-annassign: COLON test | COLON test ASSIGN test
-testlist_star_expr: testlist_se testlist_star_expr_more COMMA
- | testlist_se testlist_star_expr_more
- | testlist_se COMMA
- | testlist_se
-testlist_se: test
- | star_expr
-testlist_star_expr_more: COMMA testlist_se | testlist_star_expr_more COMMA testlist_se
-augassign: PLUSASSIGN
- | MINUSASSIGN
- | STARASSIGN
- | ATASSIGN
- | SLASHASSIGN
- | PERCENTASSIGN
- | BOOLANDASSIGN
- | BOOLORASSIGN
- | HATASSIGN
- | SHIFTLEFTASSIGN
- | SHIFTRIGHTASSIGN
- | DOUBLESTARASSIGN
- | DOUBLESLASHASSIGN
-
-del_stmt: DEL exprlist
-pass_stmt: PASS
-flow_stmt: break_stmt
- | continue_stmt
- | return_stmt
- | raise_stmt
- | yield_stmt
-break_stmt: BREAK
-continue_stmt: CONTINUE
-return_stmt: RETURN | RETURN testlist
-yield_stmt: yield_expr
-raise_stmt: RAISE | RAISE test | RAISE test FROM test
-import_stmt: import_name | import_from
-import_name: IMPORT dotted_as_names
-import_from: FROM import_from_name IMPORT import_from_import
-import_from_name: dotted_name | dots_more dotted_name | dots_more
-dots: DOT | THREEDOTS
-dots_more: dots | dots_more dots
-import_from_import: STAR
- | LPAREN import_as_names RPAREN
- | import_as_names
-import_as_name: NAME | NAME AS NAME
-dotted_as_name: dotted_name | dotted_name AS NAME
-import_as_names: import_as_name COMMA
- | import_as_name
- | import_as_name import_as_name_more COMMA
- | import_as_name import_as_name_more
-import_as_name_more: COMMA import_as_name
- | import_as_name_more COMMA import_as_name
-dotted_as_names: dotted_as_name
- | dotted_as_name dotted_as_name_more
-dotted_as_name_more: COMMA dotted_as_name
- | dotted_as_name_more COMMA dotted_as_name
-dotted_name: NAME | NAME dotted_name_more
-dotted_name_more: DOT NAME | dotted_name_more DOT NAME
-global_stmt: GLOBAL NAME | GLOBAL NAME global_stmt_more
-global_stmt_more: COMMA NAME | global_stmt_more COMMA NAME
-nonlocal_stmt: NONLOCAL NAME | NONLOCAL NAME nonlocal_stmt_more
-nonlocal_stmt_more: COMMA NAME | nonlocal_stmt_more COMMA NAME
-assert_stmt: ASSERT test | ASSERT COMMA test
-
-compound_stmt: if_stmt
- | while_stmt
- | for_stmt
- | try_stmt
- | with_stmt
- | funcdef
- | classdef
- | decorated
- | async_stmt
-async_stmt: ASYNC funcdef | ASYNC with_stmt | ASYNC for_stmt
-if_stmt: IF test COLON suite elif_stmt_more else_stmt
- | IF test COLON suite elif_stmt_more
- | IF test COLON suite else_stmt
- | IF test COLON suite
-elif_stmt: ELIF test COLON suite
-else_stmt: ELSE COLON suite
-elif_stmt_more: elif_stmt | elif_stmt_more elif_stmt
-while_stmt: WHILE test COLON suite
- | WHILE test COLON suite else_stmt
-for_stmt: FOR exprlist IN testlist COLON suite
- | FOR exprlist IN testlist COLON suite else_stmt
-try_stmt: TRY COLON suite try_stmt_two
-try_stmt_two: except_fin_stmt | finally_stmt
-finally_stmt: FINALLY COLON suite
-except_fin_stmt: except_stmt_more
- | except_stmt_more else_stmt
- | except_stmt_more finally_stmt
- | except_stmt_more else_stmt finally_stmt
-except_stmt_more: except_stmt | except_stmt_more except_stmt
-except_stmt: except_clause COLON suite
-except_clause: EXCEPT
- | EXCEPT test
- | EXCEPT test AS NAME
-with_stmt: WITH with_item with_item_more COLON suite
- | WITH with_item COLON suite
-with_item: test | test AS expr
-with_item_more: COMMA with_item | with_item_more COMMA with_item
-suite: simple_stmt | NEWLINE INDENT stmt_more UNINDENT
-stmt_more: stmt | stmt_more stmt
-
-
-test: or_test
- | or_test IF or_test ELSE test
- | lambdadef
-test_nocond: or_test | lambdadef_nocond
-lambdadef: LAMBDA COLON test
- | LAMBDA varargslist COLON test
-lambdadef_nocond: LAMBDA COLON test_nocond
- | LAMBDA varargslist COLON test
-or_test: and_test or_test_more
-or_test_more: | OR and_test or_test_more
-and_test: not_test and_test_more
-and_test_more: | AND not_test and_test_more
-not_test: NOT not_test | comparison
-comparison: expr | expr comp_more
-comp_more: comp_op expr | comp_more comp_op expr
-comp_op: LESS | BIGGER | EQL | LESSEQL | BIGGEREQL | NOTEQL | IN | NOTIN | IS | ISNOT
-star_expr: STAR expr
-expr: xor_expr | xor_expr expr_more
-expr_more: BOOLOR xor_expr | expr BOOLOR xor_expr
-xor_expr: and_expr | and_expr xor_expr_more
-xor_expr_more: HAT and_expr | xor_expr HAT and_expr
-and_expr: shift_expr | shift_expr and_expr_more
-and_expr_more: BOOLAND shift_expr | and_expr BOOLAND shift_expr
-shift_expr: arith_expr | arith_expr shift_expr_more
-shift_expr_more: shift_op arith_expr | shift_expr shift_op arith_expr
-shift_op: SHIFTLESS | SHIFTRIGHT
-arith_expr: term | term arith_expr_more
-arith_expr_more: arith_op term | arith_expr arith_op term
-arith_op: PLUS | MINUS
-term: factor | factor term_more
-term_more: term_op factor | term term_op factor
-term_op: STAR | AT | SLASH | PERCENT | DOUBLESLASH
-factor: unar_op factor | power
-unar_op: PLUS | MINUS | TILDA
-power: atom_expr | atom_expr DOUBLESTAR factor
-atom_expr: AWAIT atom | atom | AWAIT atom trailer_more | atom trailer_more
-atom: LPAREN RPAREN
- | LPAREN yield_expr RPAREN
- | LPAREN testlist_comp RPAREN
- | LSQPAREN RSQPAREN
- | LSQPAREN testlist_comp RSQPAREN
- | LCURPAREN RCURPAREN
- | LCURPAREN dictorsetmaker RCURPAREN
- | NAME
- | NUMBER
- | STRING
- | THREEDOTS
- | NONE
- | TRUE
- | FALSE
-testlist_comp: test testlist_comp_second | star_expr testlist_comp_second
-testlist_comp_second: comp_for | testlist_more_arg
-testlist_more_arg: COMMA test COMMA
- | COMMA test
- | testlist_more_arg COMMA test COMMA
- | testlist_more_arg COMMA test
- | testlist_more_arg COMMA star_expr COMMA
- | testlist_more_arg COMMA star_expr
-trailer: LPAREN RPAREN
- | LPAREN arglist RPAREN
- | LSQPAREN subscriptlist RSQPAREN
- | DOT NAME
-trailer_more: trailer | trailer_more trailer
-subscriptlist: subscript COMMA
- | subscript
- | subscript subscipt_more COMMA |
- | subscript subscipt_more
-subscipt_more: COMMA subscript | subscipt_more COMMA subscript
-subscript: test
- | COLON
- | COLON test
- | COLON sliceop
- | COLON test sliceop
- | test COLON
- | test COLON test
- | test COLON sliceop
- | test COLON test sliceop
-sliceop: COLON test | COLON
-exprlist: exprlist_op COMMA | exprlist_op | exprlist_op exprlist_more COMMA | exprlist_op exprlist_more
-exprlist_more: COMMA exprlist_op | exprlist_more COMMA exprlist_op
-exprlist_op: expr | star_expr
-testlist: test | test COMMA | test testlist_more | test testlist_more COMMA
-testlist_more: COMMA test | testlist_more COMMA test
-dictorsetmaker: test_star_expr dsm_one
- | test_star_expr COMMA /* in the case test_star_expr is zero times */
- | test_star_expr /* in the case test_star_expr is zero times */
- | test_star_expr_2 dsm_two
- | test_star_expr_2 COMMA /* in the case test_star_expr_2 is zero times */
- | test_star_expr_2 /* in the case test_star_expr_2 is zero times */
-test_star_expr: test COLON test | DOUBLESTAR expr
-dsm_one: comp_for | comp_for COMMA | test_star_expr_more COMMA | test_star_expr_more
-test_star_expr_more: COMMA test_star_expr | test_star_expr_more COMMA test_star_expr
-test_star_expr_2: test | star_expr
-dsm_two: comp_for | comp_for COMMA | test_star_expr_2_more COMMA | test_star_expr_2_more
-test_star_expr_2_more: COMMA test_star_expr_2 | test_star_expr_2_more COMMA test_star_expr_2
-
-classdef: CLASS NAME COLON suite
- | CLASS NAME LPAREN RPAREN COLON suite
- | CLASS NAME LPAREN arglist RPAREN COLON suite
-arglist: argument COMMA
- | argument
- | argument arglist_more COMMA
- | argument arglist_more
-arglist_more: COMMA argument
- | arglist_more COMMA argument
-argument: test comp_for
- | test
- | test ASSIGN test
- | DOUBLESTAR test
- | STAR test
-comp_iter: comp_for
- | comp_if
-sync_comp_for: FOR exprlist IN or_test
- | FOR exprlist IN or_test comp_iter
-comp_for: sync_comp_for
- | ASYNC comp_for
-comp_if: IF test_nocond | IF test_nocond comp_iter
-
-/* encoding_decl: NAME */
-
-yield_expr: YIELD | YIELD yield_arg
-yield_arg: FROM test | testlist
-
-%%
-int yyerror(const char* error)
-{
- extern int current_line;
- fprintf(stderr, "input:%d: error: %s\n", current_line, error);
- return 0;
-}
- int main()
-{
-#if YYDEBUG
- yydebug = 1;
-#endif
-FILE *myfile = fopen("input.file", "r");
-if (!myfile) {
- printf("I can't open input.file!\n");
- return -1;
-}
-yyin = myfile;
-yyparse();
- return 0;
-}
diff --git a/homework/81350/parser/stack.c b/homework/81350/parser/stack.c
deleted file mode 100644
index a051f7a..0000000
--- a/homework/81350/parser/stack.c
+++ /dev/null
@@ -1,46 +0,0 @@
-#include "stack.h"
-
-int stack[MAXSIZE];
-int top = -1;
-
-int isempty() {
-
- if(top == -1)
- return 1;
- else
- return 0;
-}
-
-int isfull() {
-
- if(top == MAXSIZE)
- return 1;
- else
- return 0;
-}
-
-int peek() {
- return stack[top];
-}
-
-int pop() {
- int data;
-
- if(!isempty()) {
- data = stack[top];
- top = top - 1;
- return data;
- } else {
- printf("Could not retrieve data, Stack is empty.\n");
- }
-}
-
-int push(int data) {
-
- if(!isfull()) {
- top = top + 1;
- stack[top] = data;
- } else {
- printf("Could not insert data, Stack is full.\n");
- }
-}
diff --git a/homework/81350/parser/stack.h b/homework/81350/parser/stack.h
deleted file mode 100644
index 2fccd60..0000000
--- a/homework/81350/parser/stack.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#pragma once
-#include <stdio.h>
-
-#define MAXSIZE 1000
-extern int stack[MAXSIZE];
-extern int top;
-
-int isempty();
-int isfull();
-int peek();
-int pop();
-int push(int);
diff --git a/homework/81350/py2html/README b/homework/81350/py2html/README
deleted file mode 100644
index da727c2..0000000
--- a/homework/81350/py2html/README
+++ /dev/null
@@ -1,12 +0,0 @@
-To build the program run the bash script build_lexer.sh:
-$ ./build_lexer.sh
-
-To run the highlighter on a given program:
-$ ./py2html <program name>
-When you run the highlighter, it will produce an html
-file in the current directory named "index.html".
-
-There is a test program named program.py:
-$ ./py2html program.py
-
-
diff --git a/homework/81350/py2html/Token.cpp b/homework/81350/py2html/Token.cpp
deleted file mode 100644
index ea17db5..0000000
--- a/homework/81350/py2html/Token.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "Token.h"
-#include<unordered_map>
-
-std::unordered_map<std::string, TokenType> keywords = {
- {"False", TokenType::False},
- {"True", TokenType::True},
- {"None", TokenType::None},
- {"and", TokenType::And},
- {"as", TokenType::As},
- {"assert", TokenType::Assert},
- {"break", TokenType::Break},
- {"class", TokenType::Class},
- {"continue", TokenType::Continue},
- {"def", TokenType::Def},
- {"del", TokenType::Del},
- {"elif", TokenType::Elif},
- {"else", TokenType::Else},
- {"except", TokenType::Except},
- {"finally", TokenType::Finally},
- {"for", TokenType::For},
- {"from", TokenType::From},
- {"global", TokenType::Global},
- {"if", TokenType::If},
- {"import", TokenType::Import},
- {"in", TokenType::In},
- {"is", TokenType::Is},
- {"lambda", TokenType::Lambda},
- {"nonlocal", TokenType::Nonlocal},
- {"not", TokenType::Not},
- {"or", TokenType::Or},
- {"pass", TokenType::Pass},
- {"print", TokenType::Print},
- {"raise", TokenType::Raise},
- {"return", TokenType::Return},
- {"try", TokenType::Try},
- {"while", TokenType::While},
- {"with", TokenType::With},
- {"yield", TokenType::Yield}
-};
diff --git a/homework/81350/py2html/Token.h b/homework/81350/py2html/Token.h
deleted file mode 100644
index 97dda8d..0000000
--- a/homework/81350/py2html/Token.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#pragma once
-#include<string>
-#include<unordered_map>
-
-typedef std::string IPLString ;
-
- enum TokenType{
- False,
- None,
- True,
- And,
- As,
- Assert,
- Break,
- Class,
- Continue,
- Def,
- Del,
- Elif,
- Else,
- Except,
- Finally,
- For,
- From,
- Global,
- If,
- Import,
- In,
- Is,
- Lambda,
- Nonlocal,
- Not,
- Or,
- Pass,
- Print,
- Raise,
- Return,
- Try,
- While,
- With,
- Yield
- };
-
-struct Token
-{
- TokenType Type;
- unsigned Line;
- IPLString Lexeme;
- double Number = 0.0;
-};
-
-extern std::unordered_map<std::string, TokenType> keywords;
diff --git a/homework/81350/py2html/build_lexer.sh b/homework/81350/py2html/build_lexer.sh
deleted file mode 100755
index 95492e0..0000000
--- a/homework/81350/py2html/build_lexer.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-g++ -Wall -O2 -std=c++11 -c py2html.cpp -o py2html.o
-g++ -Wall -O2 -std=c++11 -c Token.cpp -o Token.o
-g++ -o py2html py2html.o Token.o -s
diff --git a/homework/81350/py2html/program.py b/homework/81350/py2html/program.py
deleted file mode 100644
index 8343c02..0000000
--- a/homework/81350/py2html/program.py
+++ /dev/null
@@ -1,10 +0,0 @@
-num1 = 1.5
-num2 = 6.3
-
-sum = float(num1) + float(num2)
-
-print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
-
-table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678}
-for name, phone in table.items():
- print(f'{name:10} ==> {phone:10d}')
diff --git a/homework/81350/py2html/py2html.cpp b/homework/81350/py2html/py2html.cpp
deleted file mode 100644
index 65d28da..0000000
--- a/homework/81350/py2html/py2html.cpp
+++ /dev/null
@@ -1,258 +0,0 @@
-#include <iostream>
-#include <string>
-#include <cctype>
-#include <unistd.h>
-#include <sys/types.h>
-#include <unordered_map>
-#include <set>
-#include "Token.h"
-
-std::string operatorChars = "+-*/%=<>&|^~";
-std::string parenthesisChars = "[]{}(),";
-std::set<std::string> operators = {
- "+",
- "-",
- "*",
- "/",
- "//",
- "%",
- "**",
- ">",
- "<",
- ">=",
- "<=",
- "==",
- "!=",
- "&",
- "|",
- "~",
- "^",
- ">>",
- "<<",
- "=",
- "+=",
- "-=",
- "*=",
- "/=",
- "%=",
- "**=",
- "//=",
- "^=",
- "&=",
- "|=",
- ">>=",
- "<<="
-};
-
-using namespace std;
-FILE* in;
-FILE* out;
-
-bool isNumber(char c){
- return c >= '0' && c <= '9';
-}
-
-bool notValidNumber(char c){
- return !(isNumber(c) || c == '.');
-}
-
-bool isQuote(char c){
- return c == '\'' || c == '"';
-}
-
-bool isLastQuote(char firstQuote, char previousChar, char currentChar){
- return firstQuote == currentChar && previousChar != '\\';
-}
-
-bool isOperator(char c){
- return operatorChars.find(c) != std::string::npos;
-}
-
-bool isParenthesis(char c){
- return parenthesisChars.find(c) != std::string::npos;
-}
-
-bool isValidIdentifierChar(char c){
- return !(isOperator(c) || isParenthesis(c) || isQuote(c) || c == '\n' || isblank(c) || c == ',');
-}
-
-bool isValidOperator(std::string word){
- std::set<std::string>::iterator iter;
- iter = operators.find(word);
- return iter != operators.end();
-}
-
-std::string readFormat(){
- std::string word = "{";
- char c;
-
- while((c = fgetc(in)) != EOF && c != '}'){
- word += c;
- }
- word += '}';
- return word;
-}
-
-std::string readNumber(){
- fseek(in, -1, SEEK_CUR);
- std::string word;
- char c;
- int dotCount = 0;
-
- while((c = fgetc(in)) != EOF && !notValidNumber(c)){
- //printf("%c", c);
- if(notValidNumber(c)){
- return "";
- } else if(c == '.'){
- dotCount++;
- if(dotCount >= 2){
- return "";
- }
- }
- word += c;
- }
- if(notValidNumber(c)){
- fseek(in, -1, SEEK_CUR);
- }
- return word;
-}
-
-std::string readString(char firstQuote){
- std::string word = "";
- word += firstQuote;
- char c;
- char previousChar = ' ';
-
- while((c = fgetc(in)) != EOF && !isLastQuote(firstQuote, previousChar, c)){
- if( c == '{'){
- fprintf(out, "<span class=\"string\">%s</span>", word.c_str());
- word = readFormat();
- fprintf(out, "<span class=\"formatString\">%s</span>", word.c_str());
- word = "";
- } else {
- word += c;
- }
- previousChar = c;
- }
- word += firstQuote;
- fprintf(out, "<span class=\"string\">%s</span>", word.c_str());
- return word;
-}
-
-std::string readOperator(){
- fseek(in, -1, SEEK_CUR);
- std::string word;
- char c;
- while((c = fgetc(in)) != EOF && isOperator(c)){
- word += c;
- }
- if(!isOperator(c)){
- fseek(in, -1, SEEK_CUR);
- }
- return word;
-}
-
-std::string readWord(){
- fseek(in, -1, SEEK_CUR);
- std::string word;
- char c;
- while((c = fgetc(in)) != EOF && isValidIdentifierChar(c)){
- word += c;
- }
-
- if(!isValidIdentifierChar(c)){
- fseek(in, -1, SEEK_CUR);
- }
- return word;
-}
-
-void lexer(){
- char c;
- bool validSyntaxis = 1;
- std::string word;
- std::unordered_map<std::string, TokenType>::const_iterator iter;
-
- while((c = fgetc(in)) != EOF){
- if(isQuote(c)){
- word = readString(c);
- //fprintf(out, "<span class=\"string\">%s</span>", word.c_str());
- continue;
- }
- if(isNumber(c)){
- word = readNumber();
- fprintf(out, "<span class=\"number\">%s</span>", word.c_str());
- continue;
- }
- if(isOperator(c)){
- word = readOperator();
- if(isValidOperator(word)){
- validSyntaxis = 0;
- }
- fprintf(out, "<span class=\"operator\">%s</span>", word.c_str());
- // trqbwa da se proweti dali e korektno
- // t.e. da e w nqkyw set ili hash
- continue;
- }
- if(isParenthesis(c)){
- fprintf(out, "%c", c);
- continue;
- }
- if(isblank(c) || c == '\n'){
- fprintf(out, "%c", c);
- continue;
- }
-
- word = readWord();
- iter = keywords.find(word);
- if(iter == keywords.end()){
- fprintf(out, "%s", word.c_str());
- } else {
- fprintf(out, "<span class=\"keyword\">%s</span>", word.c_str());
- }
-
- }
-}
-
-int main(int argc, const char* argv[])
-{
- ++argv, --argc; /* skip over program name */
- if ( argc > 0 )
- in = fopen( argv[0], "r" );
- else
- in = stdin;
-
- out = fopen("index.html", "w");
-
- fputs(
- "<!doctype>"
- "<html>"
- "<head>"
- " <title>program.py</title>"
- " <style>"
- " .keyword {"
- " color: purple;"
- " }"
- " .number {"
- " color: orange;"
- " }"
- " .string {"
- " color: green;"
- " }"
- " .operator {"
- " font-style: bold;"
- " }"
- " .formatString {"
- " color: red;"
- " }"
- " </style>"
- "</head>"
- "<body>"
- " <pre class=\"code\">",
- out);
-
- lexer();
- fputs("</pre></body></html>", out);
- fclose(in);
- fclose(out);
- return 0;
-}
diff --git a/homework/81352/README.md b/homework/81352/README.md
deleted file mode 100644
index 8ceb8e6..0000000
--- a/homework/81352/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-# Dimitar Milev's homeworks
-### [Homework 1](./ts2html-hw1)
-### [Homework 2](./ts2html-hw2)
-### [Homework 3](./gcd-hw3)
diff --git a/homework/81352/gcd-hw3/README.md b/homework/81352/gcd-hw3/README.md
deleted file mode 100644
index 565c03b..0000000
--- a/homework/81352/gcd-hw3/README.md
+++ /dev/null
@@ -1,10 +0,0 @@
-# Homework 3
-# SPGCD
-
-Супер прост implementation of the Euclid's algorithm for computing the greatest common divisor(GCD) of two numbers
-in spasm.
-
-
-### Prerequisites
-
-1. [spasm](../../../spasm)
diff --git a/homework/81352/gcd-hw3/spgcd.txt b/homework/81352/gcd-hw3/spgcd.txt
deleted file mode 100644
index 386c52d..0000000
--- a/homework/81352/gcd-hw3/spgcd.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-push 3
-read r1
-read r2
-label loop
-eq r3 r1 r2
-jmpt r3 end
-less r3 r1 r2
-jmpt r3 subs
-sub r1 r1 r2
-jmp loop
-label subs
-sub r2 r2 r1
-jmp loop
-label end
-print r1
-halt \ No newline at end of file
diff --git a/homework/81352/ts2html-hw1/README.md b/homework/81352/ts2html-hw1/README.md
deleted file mode 100644
index 5b22712..0000000
--- a/homework/81352/ts2html-hw1/README.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# Homework 1
-
-Typescript syntax highlighter.
-
-### Prerequisites
-
-1. [g++ compiler](http://man7.org/linux/man-pages/man1/g++.1.html)
-2. [flex](https://www.gnu.org/software/flex/)
-
-### Usage
-```
-./flex.sh [ts file] > highlighted.html
-``` \ No newline at end of file
diff --git a/homework/81352/ts2html-hw1/example.ts b/homework/81352/ts2html-hw1/example.ts
deleted file mode 100644
index 5cbb6e0..0000000
--- a/homework/81352/ts2html-hw1/example.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-@Decorator
-class A {
- public a?: string;
- public b?: A;
-}
-// comment
-const x = "hello" + " " + "world" + 1; \ No newline at end of file
diff --git a/homework/81352/ts2html-hw1/flex.sh b/homework/81352/ts2html-hw1/flex.sh
deleted file mode 100755
index 81f15b3..0000000
--- a/homework/81352/ts2html-hw1/flex.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-flex ts2html.flex
-g++ -std=c++11 lex.yy.c highlighter.cpp token.cpp -o lexer
-./lexer $1
-rm lexer
diff --git a/homework/81352/ts2html-hw1/highlighter.cpp b/homework/81352/ts2html-hw1/highlighter.cpp
deleted file mode 100644
index 6c44066..0000000
--- a/homework/81352/ts2html-hw1/highlighter.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <sstream>
-#include <iostream>
-#include <unordered_set>
-#include "highlighter.h"
-
-Highlighter::Highlighter(std::vector<Token> tokens): tokens(tokens){}
-
-std::string Highlighter::highlight() {
- std::ostringstream result;
- result << "<!doctype><html><head>";
- result << "<style>.keyword {color:red;} \
- .operator {color:#0e7c31; font-weight: bold} \
- .number {color:#d119b2;} .string {color:blue;} \
- .comment {color:grey; font-style: italic;} \
- .line_number {opacity: 0.5;} \
- .decorator {color:#1a1f63; font-style: italic;} \
- .user_defined_type {color:#105109} \
- </style></head><body><pre>";
- if (!this->tokens.empty()) {
- result << "<span class=\"line_number\">1. </span>";
- }
- int line_number = 2;
- for (Token token: this->tokens) {
- if (token.getTokenType() == TokenType::NEWLINE) {
- result << "\n<span class=\"line_number\">" << line_number++ << ". </span>";
- } else {
- result << "<span class=\"" << token.getTypeName() << "\">" << token.getTextValue() << "</span>";
- }
- }
- result << "</pre></body></html>";
- return result.str();
-}
diff --git a/homework/81352/ts2html-hw1/highlighter.h b/homework/81352/ts2html-hw1/highlighter.h
deleted file mode 100644
index 3a0e476..0000000
--- a/homework/81352/ts2html-hw1/highlighter.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef HIGHLIGHTER
-#define HIGHLIGHTER
-
-#include <vector>
-#include <string>
-#include "token.h"
-
-class Highlighter {
- private:
- std::vector<Token> tokens;
- void preProcessTokens();
- public:
- Highlighter(std::vector<Token>);
- std::string highlight();
-
-};
-#endif \ No newline at end of file
diff --git a/homework/81352/ts2html-hw1/lex.yy.c b/homework/81352/ts2html-hw1/lex.yy.c
deleted file mode 100644
index 8d2fe22..0000000
--- a/homework/81352/ts2html-hw1/lex.yy.c
+++ /dev/null
@@ -1,2257 +0,0 @@
-
-#line 3 "lex.yy.c"
-
-#define YY_INT_ALIGNED short int
-
-/* A lexical scanner generated by flex */
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 0
-#if YY_FLEX_SUBMINOR_VERSION > 0
-#define FLEX_BETA
-#endif
-
-/* First, we deal with platform-specific or compiler-specific issues. */
-
-/* begin standard C headers. */
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/* end standard C headers. */
-
-/* flex integer type definitions */
-
-#ifndef FLEXINT_H
-#define FLEXINT_H
-
-/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-
-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-
-/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
- * if you want the limit (max/min) macros for int types.
- */
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS 1
-#endif
-
-#include <inttypes.h>
-typedef int8_t flex_int8_t;
-typedef uint8_t flex_uint8_t;
-typedef int16_t flex_int16_t;
-typedef uint16_t flex_uint16_t;
-typedef int32_t flex_int32_t;
-typedef uint32_t flex_uint32_t;
-#else
-typedef signed char flex_int8_t;
-typedef short int flex_int16_t;
-typedef int flex_int32_t;
-typedef unsigned char flex_uint8_t;
-typedef unsigned short int flex_uint16_t;
-typedef unsigned int flex_uint32_t;
-
-/* Limits of integral types. */
-#ifndef INT8_MIN
-#define INT8_MIN (-128)
-#endif
-#ifndef INT16_MIN
-#define INT16_MIN (-32767-1)
-#endif
-#ifndef INT32_MIN
-#define INT32_MIN (-2147483647-1)
-#endif
-#ifndef INT8_MAX
-#define INT8_MAX (127)
-#endif
-#ifndef INT16_MAX
-#define INT16_MAX (32767)
-#endif
-#ifndef INT32_MAX
-#define INT32_MAX (2147483647)
-#endif
-#ifndef UINT8_MAX
-#define UINT8_MAX (255U)
-#endif
-#ifndef UINT16_MAX
-#define UINT16_MAX (65535U)
-#endif
-#ifndef UINT32_MAX
-#define UINT32_MAX (4294967295U)
-#endif
-
-#endif /* ! C99 */
-
-#endif /* ! FLEXINT_H */
-
-#ifdef __cplusplus
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-/* C99 requires __STDC__ to be defined as 1. */
-#if defined (__STDC__)
-
-#define YY_USE_CONST
-
-#endif /* defined (__STDC__) */
-#endif /* ! __cplusplus */
-
-#ifdef YY_USE_CONST
-#define yyconst const
-#else
-#define yyconst
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* An opaque pointer. */
-#ifndef YY_TYPEDEF_YY_SCANNER_T
-#define YY_TYPEDEF_YY_SCANNER_T
-typedef void* yyscan_t;
-#endif
-
-/* For convenience, these vars (plus the bison vars far below)
- are macros in the reentrant scanner. */
-#define yyin yyg->yyin_r
-#define yyout yyg->yyout_r
-#define yyextra yyg->yyextra_r
-#define yyleng yyg->yyleng_r
-#define yytext yyg->yytext_r
-#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
-#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
-#define yy_flex_debug yyg->yy_flex_debug_r
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN yyg->yy_start = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state. The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START ((yyg->yy_start - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart(yyin ,yyscanner )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#ifndef YY_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k.
- * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
- * Ditto for the __ia64__ case accordingly.
- */
-#define YY_BUF_SIZE 32768
-#else
-#define YY_BUF_SIZE 16384
-#endif /* __ia64__ */
-#endif
-
-/* The state buf must be large enough to hold one state per character in the main buffer.
- */
-#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
-
-#ifndef YY_TYPEDEF_YY_BUFFER_STATE
-#define YY_TYPEDEF_YY_BUFFER_STATE
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-#endif
-
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef size_t yy_size_t;
-#endif
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
- #define YY_LESS_LINENO(n)
- #define YY_LINENO_REWIND_TO(ptr)
-
-/* Return all but the first "n" matched characters back to the input stream. */
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- *yy_cp = yyg->yy_hold_char; \
- YY_RESTORE_YY_MORE_OFFSET \
- yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up yytext again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
-
-#ifndef YY_STRUCT_YY_BUFFER_STATE
-#define YY_STRUCT_YY_BUFFER_STATE
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- yy_size_t yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- int yy_n_chars;
-
- /* Whether we "own" the buffer - i.e., we know we created it,
- * and can realloc() it to grow it, and should free() it to
- * delete it.
- */
- int yy_is_our_buffer;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether we're considered to be at the beginning of a line.
- * If so, '^' rules will be active on the next match, otherwise
- * not.
- */
- int yy_at_bol;
-
- int yy_bs_lineno; /**< The line count. */
- int yy_bs_column; /**< The column count. */
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via yyrestart()), so that the user can continue scanning by
- * just pointing yyin at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
-
- };
-#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- *
- * Returns the top of the stack, or NULL.
- */
-#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
- ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
- : NULL)
-
-/* Same as previous macro, but useful when we know that the buffer stack is not
- * NULL or when we need an lvalue. For internal use only.
- */
-#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
-
-void yyrestart (FILE *input_file ,yyscan_t yyscanner );
-void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
-void yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-void yypop_buffer_state (yyscan_t yyscanner );
-
-static void yyensure_buffer_stack (yyscan_t yyscanner );
-static void yy_load_buffer_state (yyscan_t yyscanner );
-static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
-
-#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
-
-YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
-YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
-
-void *yyalloc (yy_size_t ,yyscan_t yyscanner );
-void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
-void yyfree (void * ,yyscan_t yyscanner );
-
-#define yy_new_buffer yy_create_buffer
-
-#define yy_set_interactive(is_interactive) \
- { \
- if ( ! YY_CURRENT_BUFFER ){ \
- yyensure_buffer_stack (yyscanner); \
- YY_CURRENT_BUFFER_LVALUE = \
- yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
- }
-
-#define yy_set_bol(at_bol) \
- { \
- if ( ! YY_CURRENT_BUFFER ){\
- yyensure_buffer_stack (yyscanner); \
- YY_CURRENT_BUFFER_LVALUE = \
- yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
- }
-
-#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
-
-/* Begin user sect3 */
-
-typedef unsigned char YY_CHAR;
-
-typedef int yy_state_type;
-
-#define yytext_ptr yytext_r
-
-static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
-static int yy_get_next_buffer (yyscan_t yyscanner );
-#if defined(__GNUC__) && __GNUC__ >= 3
-__attribute__((__noreturn__))
-#endif
-static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up yytext.
- */
-#define YY_DO_BEFORE_ACTION \
- yyg->yytext_ptr = yy_bp; \
- yyleng = (size_t) (yy_cp - yy_bp); \
- yyg->yy_hold_char = *yy_cp; \
- *yy_cp = '\0'; \
- yyg->yy_c_buf_p = yy_cp;
-
-#define YY_NUM_RULES 17
-#define YY_END_OF_BUFFER 18
-/* This struct is not used in this scanner,
- but its presence is necessary. */
-struct yy_trans_info
- {
- flex_int32_t yy_verify;
- flex_int32_t yy_nxt;
- };
-static yyconst flex_int16_t yy_accept[255] =
- { 0,
- 0, 0, 18, 16, 15, 14, 8, 16, 7, 8,
- 8, 16, 12, 13, 8, 8, 8, 8, 8, 5,
- 9, 8, 8, 8, 16, 8, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 10, 8, 11, 15, 8,
- 0, 4, 0, 7, 8, 0, 0, 0, 1, 6,
- 5, 8, 8, 8, 3, 7, 2, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 2, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-
- 7, 7, 7, 7, 7, 4, 4, 0, 0, 1,
- 6, 8, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 1, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 2,
- 7, 7, 7, 2, 7, 7, 7, 7, 7, 7,
-
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 0
- } ;
-
-static yyconst YY_CHAR yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 4, 5, 1, 6, 7, 8, 9, 10,
- 11, 12, 13, 1, 14, 15, 16, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 18, 19, 20,
- 21, 22, 23, 24, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 1, 26, 1, 27, 6, 1, 28, 29, 30, 31,
-
- 32, 33, 34, 35, 36, 25, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
- 51, 25, 52, 53, 54, 55, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-static yyconst YY_CHAR yy_meta[56] =
- { 0,
- 1, 1, 2, 1, 1, 3, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 3, 1, 1, 1,
- 1, 1, 1, 1, 4, 1, 1, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 1, 1, 1, 1
- } ;
-
-static yyconst flex_uint16_t yy_base[261] =
- { 0,
- 0, 0, 365, 366, 362, 366, 342, 51, 0, 341,
- 49, 49, 366, 366, 340, 46, 47, 366, 48, 48,
- 366, 51, 52, 57, 0, 339, 36, 39, 54, 52,
- 47, 58, 327, 67, 326, 316, 56, 323, 68, 323,
- 72, 66, 70, 54, 318, 366, 87, 366, 351, 331,
- 104, 366, 108, 0, 366, 105, 107, 339, 0, 333,
- 105, 328, 327, 103, 0, 296, 0, 305, 313, 81,
- 316, 303, 99, 297, 294, 20, 302, 299, 294, 296,
- 296, 289, 292, 90, 287, 301, 282, 100, 300, 105,
- 300, 99, 282, 115, 285, 290, 286, 108, 100, 282,
-
- 279, 286, 285, 274, 287, 143, 140, 306, 138, 0,
- 300, 295, 277, 286, 281, 282, 266, 110, 263, 271,
- 280, 275, 274, 266, 263, 271, 257, 273, 261, 269,
- 119, 252, 265, 249, 257, 265, 256, 244, 245, 252,
- 242, 241, 241, 250, 253, 238, 254, 237, 240, 248,
- 247, 247, 239, 241, 237, 262, 241, 235, 236, 225,
- 223, 232, 233, 238, 218, 218, 219, 222, 229, 222,
- 213, 226, 213, 228, 211, 216, 221, 224, 223, 218,
- 213, 212, 203, 210, 205, 200, 213, 201, 192, 199,
- 207, 207, 209, 192, 195, 200, 189, 194, 199, 184,
-
- 198, 190, 191, 187, 179, 184, 190, 190, 177, 186,
- 173, 188, 187, 172, 175, 184, 179, 177, 173, 177,
- 169, 161, 160, 174, 173, 158, 158, 151, 160, 168,
- 169, 170, 165, 164, 149, 162, 163, 160, 147, 150,
- 149, 156, 155, 149, 122, 121, 124, 132, 132, 121,
- 116, 125, 109, 366, 169, 171, 175, 87, 179, 183
- } ;
-
-static yyconst flex_int16_t yy_def[261] =
- { 0,
- 254, 1, 254, 254, 254, 254, 254, 255, 256, 254,
- 254, 257, 254, 254, 254, 254, 254, 254, 254, 254,
- 254, 254, 254, 254, 258, 254, 256, 256, 256, 256,
- 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- 256, 256, 256, 256, 256, 254, 254, 254, 254, 254,
- 255, 254, 255, 256, 254, 257, 257, 259, 260, 254,
- 254, 254, 254, 254, 258, 256, 256, 256, 256, 256,
- 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
-
- 256, 256, 256, 256, 256, 255, 257, 259, 259, 260,
- 254, 254, 256, 256, 256, 256, 256, 256, 256, 256,
- 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- 256, 256, 256, 256, 256, 259, 256, 256, 256, 256,
- 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
-
- 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- 256, 256, 256, 0, 254, 254, 254, 254, 254, 254
- } ;
-
-static yyconst flex_uint16_t yy_nxt[422] =
- { 0,
- 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
- 14, 15, 16, 17, 18, 19, 20, 18, 21, 22,
- 23, 24, 18, 25, 9, 4, 26, 27, 28, 29,
- 30, 31, 32, 33, 9, 34, 9, 35, 36, 37,
- 38, 39, 9, 40, 41, 42, 9, 43, 44, 9,
- 45, 46, 47, 48, 18, 52, 55, 52, 55, 58,
- 55, 125, 60, 59, 61, 126, 55, 55, 55, 55,
- 62, 55, 63, 55, 57, 66, 53, 55, 64, 68,
- 67, 70, 69, 73, 74, 77, 75, 87, 103, 104,
- 65, 71, 67, 78, 72, 89, 76, 101, 79, 67,
-
- 98, 80, 88, 93, 81, 83, 84, 55, 52, 99,
- 102, 90, 106, 52, 91, 107, 100, 94, 95, 60,
- 96, 61, 97, 55, 112, 115, 116, 119, 120, 53,
- 57, 121, 57, 53, 132, 133, 122, 135, 136, 55,
- 138, 141, 143, 148, 142, 139, 150, 52, 52, 109,
- 67, 149, 67, 156, 161, 162, 172, 67, 144, 173,
- 67, 253, 67, 67, 252, 57, 251, 250, 53, 51,
- 51, 51, 51, 54, 54, 56, 56, 56, 56, 108,
- 249, 108, 108, 110, 248, 110, 110, 247, 246, 67,
- 67, 67, 245, 67, 244, 67, 67, 243, 242, 241,
-
- 240, 67, 67, 67, 67, 239, 238, 237, 67, 67,
- 67, 67, 67, 67, 67, 236, 67, 235, 234, 233,
- 67, 67, 232, 231, 67, 230, 229, 228, 227, 67,
- 67, 226, 225, 224, 223, 222, 221, 67, 67, 220,
- 67, 219, 218, 67, 217, 216, 215, 214, 213, 212,
- 211, 210, 209, 208, 207, 206, 205, 204, 203, 202,
- 67, 201, 200, 199, 198, 197, 196, 195, 194, 67,
- 67, 67, 193, 109, 192, 67, 191, 67, 190, 67,
- 189, 67, 188, 187, 186, 185, 184, 183, 182, 181,
- 180, 179, 178, 177, 67, 176, 175, 174, 171, 67,
-
- 170, 169, 168, 167, 67, 67, 166, 165, 164, 163,
- 160, 159, 67, 158, 157, 55, 111, 109, 155, 154,
- 153, 152, 67, 151, 147, 146, 145, 67, 140, 137,
- 67, 134, 67, 131, 67, 130, 129, 67, 128, 127,
- 124, 123, 118, 117, 114, 113, 67, 55, 55, 111,
- 109, 55, 49, 105, 92, 67, 86, 85, 82, 55,
- 55, 55, 50, 49, 254, 3, 254, 254, 254, 254,
- 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
- 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
- 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
-
- 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
- 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
- 254
- } ;
-
-static yyconst flex_int16_t yy_chk[422] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 8, 11, 12, 16, 19,
- 17, 76, 20, 19, 20, 76, 16, 17, 19, 11,
- 22, 22, 23, 23, 12, 27, 8, 24, 24, 28,
- 27, 29, 28, 30, 31, 32, 31, 37, 44, 44,
- 258, 29, 30, 32, 29, 39, 31, 43, 32, 34,
-
- 42, 32, 37, 41, 32, 34, 34, 47, 51, 42,
- 43, 39, 53, 56, 39, 57, 42, 41, 41, 61,
- 41, 61, 41, 64, 64, 70, 70, 73, 73, 51,
- 56, 73, 57, 53, 84, 84, 73, 88, 88, 47,
- 90, 92, 94, 98, 92, 90, 99, 106, 107, 109,
- 99, 98, 253, 109, 118, 118, 131, 252, 94, 131,
- 251, 250, 249, 248, 247, 107, 246, 245, 106, 255,
- 255, 255, 255, 256, 256, 257, 257, 257, 257, 259,
- 244, 259, 259, 260, 243, 260, 260, 242, 241, 240,
- 239, 238, 237, 236, 235, 234, 233, 232, 231, 230,
-
- 229, 228, 227, 226, 225, 224, 223, 222, 221, 220,
- 219, 218, 217, 216, 215, 214, 213, 212, 211, 210,
- 209, 208, 207, 206, 205, 204, 203, 202, 201, 200,
- 199, 198, 197, 196, 195, 194, 193, 192, 191, 190,
- 189, 188, 187, 186, 185, 184, 183, 182, 181, 180,
- 179, 178, 177, 176, 175, 174, 173, 172, 171, 170,
- 169, 168, 167, 166, 165, 164, 163, 162, 161, 160,
- 159, 158, 157, 156, 155, 154, 153, 152, 151, 150,
- 149, 148, 147, 146, 145, 144, 143, 142, 141, 140,
- 139, 138, 137, 136, 135, 134, 133, 132, 130, 129,
-
- 128, 127, 126, 125, 124, 123, 122, 121, 120, 119,
- 117, 116, 115, 114, 113, 112, 111, 108, 105, 104,
- 103, 102, 101, 100, 97, 96, 95, 93, 91, 89,
- 87, 86, 85, 83, 82, 81, 80, 79, 78, 77,
- 75, 74, 72, 71, 69, 68, 66, 63, 62, 60,
- 58, 50, 49, 45, 40, 38, 36, 35, 33, 26,
- 15, 10, 7, 5, 3, 254, 254, 254, 254, 254,
- 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
- 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
- 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
-
- 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
- 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
- 254
- } ;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-#line 1 "ts2html.flex"
-#line 2 "ts2html.flex"
-#include <vector>
-#include <iostream>
-#include "token.h"
-#include "highlighter.h"
-#line 624 "lex.yy.c"
-
-#define INITIAL 0
-
-#ifndef YY_NO_UNISTD_H
-/* Special case for "unistd.h", since it is non-ANSI. We include it way
- * down here because we want the user's section 1 to have been scanned first.
- * The user has a chance to override it with an option.
- */
-#include <unistd.h>
-#endif
-
-#define YY_EXTRA_TYPE std::vector<Token> *
-
-/* Holds the entire state of the reentrant scanner. */
-struct yyguts_t
- {
-
- /* User-defined. Not touched by flex. */
- YY_EXTRA_TYPE yyextra_r;
-
- /* The rest are the same as the globals declared in the non-reentrant scanner. */
- FILE *yyin_r, *yyout_r;
- size_t yy_buffer_stack_top; /**< index of top of stack. */
- size_t yy_buffer_stack_max; /**< capacity of stack. */
- YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
- char yy_hold_char;
- int yy_n_chars;
- yy_size_t yyleng_r;
- char *yy_c_buf_p;
- int yy_init;
- int yy_start;
- int yy_did_buffer_switch_on_eof;
- int yy_start_stack_ptr;
- int yy_start_stack_depth;
- int *yy_start_stack;
- yy_state_type yy_last_accepting_state;
- char* yy_last_accepting_cpos;
-
- int yylineno_r;
- int yy_flex_debug_r;
-
- char *yytext_r;
- int yy_more_flag;
- int yy_more_len;
-
- }; /* end struct yyguts_t */
-
-static int yy_init_globals (yyscan_t yyscanner );
-
-int yylex_init (yyscan_t* scanner);
-
-int yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
-
-/* Accessor methods to globals.
- These are made visible to non-reentrant scanners for convenience. */
-
-int yylex_destroy (yyscan_t yyscanner );
-
-int yyget_debug (yyscan_t yyscanner );
-
-void yyset_debug (int debug_flag ,yyscan_t yyscanner );
-
-YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner );
-
-void yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
-
-FILE *yyget_in (yyscan_t yyscanner );
-
-void yyset_in (FILE * _in_str ,yyscan_t yyscanner );
-
-FILE *yyget_out (yyscan_t yyscanner );
-
-void yyset_out (FILE * _out_str ,yyscan_t yyscanner );
-
-yy_size_t yyget_leng (yyscan_t yyscanner );
-
-char *yyget_text (yyscan_t yyscanner );
-
-int yyget_lineno (yyscan_t yyscanner );
-
-void yyset_lineno (int _line_number ,yyscan_t yyscanner );
-
-int yyget_column (yyscan_t yyscanner );
-
-void yyset_column (int _column_no ,yyscan_t yyscanner );
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int yywrap (yyscan_t yyscanner );
-#else
-extern int yywrap (yyscan_t yyscanner );
-#endif
-#endif
-
-#ifndef YY_NO_UNPUT
-
- static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner);
-
-#endif
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
-#endif
-
-#ifndef YY_NO_INPUT
-
-#ifdef __cplusplus
-static int yyinput (yyscan_t yyscanner );
-#else
-static int input (yyscan_t yyscanner );
-#endif
-
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k */
-#define YY_READ_BUF_SIZE 16384
-#else
-#define YY_READ_BUF_SIZE 8192
-#endif /* __ia64__ */
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
- { \
- int c = '*'; \
- size_t n; \
- for ( n = 0; n < max_size && \
- (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
- buf[n] = (char) c; \
- if ( c == '\n' ) \
- buf[n++] = (char) c; \
- if ( c == EOF && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- result = n; \
- } \
- else \
- { \
- errno=0; \
- while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
- { \
- if( errno != EINTR) \
- { \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- break; \
- } \
- errno=0; \
- clearerr(yyin); \
- } \
- }\
-\
-
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
-#endif
-
-/* end tables serialization structures and prototypes */
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL_IS_OURS 1
-
-extern int yylex (yyscan_t yyscanner);
-
-#define YY_DECL int yylex (yyscan_t yyscanner)
-#endif /* !YY_DECL */
-
-/* Code executed at the beginning of each rule, after yytext and yyleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK /*LINTED*/break;
-#endif
-
-#define YY_RULE_SETUP \
- YY_USER_ACTION
-
-/** The main scanner function which does all the work.
- */
-YY_DECL
-{
- yy_state_type yy_current_state;
- char *yy_cp, *yy_bp;
- int yy_act;
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-
- if ( !yyg->yy_init )
- {
- yyg->yy_init = 1;
-
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! yyg->yy_start )
- yyg->yy_start = 1; /* first start state */
-
- if ( ! yyin )
- yyin = stdin;
-
- if ( ! yyout )
- yyout = stdout;
-
- if ( ! YY_CURRENT_BUFFER ) {
- yyensure_buffer_stack (yyscanner);
- YY_CURRENT_BUFFER_LVALUE =
- yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
- }
-
- yy_load_buffer_state(yyscanner );
- }
-
- {
-#line 24 "ts2html.flex"
-
-
-#line 886 "lex.yy.c"
-
- while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
- {
- yy_cp = yyg->yy_c_buf_p;
-
- /* Support of yytext. */
- *yy_cp = yyg->yy_hold_char;
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = yyg->yy_start;
-yy_match:
- do
- {
- YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
- if ( yy_accept[yy_current_state] )
- {
- yyg->yy_last_accepting_state = yy_current_state;
- yyg->yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 255 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- ++yy_cp;
- }
- while ( yy_base[yy_current_state] != 366 );
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
- if ( yy_act == 0 )
- { /* have to back up */
- yy_cp = yyg->yy_last_accepting_cpos;
- yy_current_state = yyg->yy_last_accepting_state;
- yy_act = yy_accept[yy_current_state];
- }
-
- YY_DO_BEFORE_ACTION;
-
-do_action: /* This label is used only to access EOF actions. */
-
- switch ( yy_act )
- { /* beginning of action switch */
- case 0: /* must back up */
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = yyg->yy_hold_char;
- yy_cp = yyg->yy_last_accepting_cpos;
- yy_current_state = yyg->yy_last_accepting_state;
- goto yy_find_action;
-
-case 1:
-YY_RULE_SETUP
-#line 26 "ts2html.flex"
-{
- yyextra->push_back(Token(yytext, TokenType::COMMENT));
-}
- YY_BREAK
-case 2:
-YY_RULE_SETUP
-#line 30 "ts2html.flex"
-{
- yyextra->push_back(Token(yytext, TokenType::KEYWORD));
-}
- YY_BREAK
-case 3:
-YY_RULE_SETUP
-#line 34 "ts2html.flex"
-{
- yyextra->push_back(Token(yytext, TokenType::DECORATOR));
-}
- YY_BREAK
-case 4:
-/* rule 4 can match eol */
-YY_RULE_SETUP
-#line 38 "ts2html.flex"
-{
- yyextra->push_back(Token(yytext, TokenType::STRING));
-}
- YY_BREAK
-case 5:
-YY_RULE_SETUP
-#line 42 "ts2html.flex"
-{
- yyextra->push_back(Token(yytext, TokenType::NUMBER));
-}
- YY_BREAK
-case 6:
-YY_RULE_SETUP
-#line 46 "ts2html.flex"
-{
- yyextra->push_back(Token(yytext, TokenType::NUMBER));
-}
- YY_BREAK
-case 7:
-YY_RULE_SETUP
-#line 50 "ts2html.flex"
-{
- yyextra->push_back(Token(yytext, TokenType::IDENTIFIER));
-}
- YY_BREAK
-case 8:
-YY_RULE_SETUP
-#line 54 "ts2html.flex"
-{
- yyextra->push_back(Token(yytext, TokenType::OPERATOR));
-}
- YY_BREAK
-case 9:
-YY_RULE_SETUP
-#line 58 "ts2html.flex"
-{
- yyextra->push_back(Token(yytext, TokenType::SEMICOLON));
-}
- YY_BREAK
-case 10:
-YY_RULE_SETUP
-#line 62 "ts2html.flex"
-{
- yyextra->push_back(Token(yytext, TokenType::LEFT_BLOCK_BRACKET));
-}
- YY_BREAK
-case 11:
-YY_RULE_SETUP
-#line 66 "ts2html.flex"
-{
- yyextra->push_back(Token(yytext, TokenType::RIGHT_BLOCK_BRACKET));
-}
- YY_BREAK
-case 12:
-YY_RULE_SETUP
-#line 70 "ts2html.flex"
-{
- yyextra->push_back(Token(yytext, TokenType::LEFT_BRACKET));
-}
- YY_BREAK
-case 13:
-YY_RULE_SETUP
-#line 74 "ts2html.flex"
-{
- yyextra->push_back(Token(yytext, TokenType::RIGHT_BRACKET));
-}
- YY_BREAK
-case 14:
-/* rule 14 can match eol */
-YY_RULE_SETUP
-#line 78 "ts2html.flex"
-{
- yyextra->push_back(Token(yytext, TokenType::NEWLINE));
-}
- YY_BREAK
-case 15:
-YY_RULE_SETUP
-#line 82 "ts2html.flex"
-{
- yyextra->push_back(Token(yytext, TokenType::WHITESPACE));
-}
- YY_BREAK
-case 16:
-YY_RULE_SETUP
-#line 86 "ts2html.flex"
-{
- yyextra->push_back(Token(yytext, TokenType::UNRECOGNIZED));
-}
- YY_BREAK
-case 17:
-YY_RULE_SETUP
-#line 90 "ts2html.flex"
-ECHO;
- YY_BREAK
-#line 1062 "lex.yy.c"
-case YY_STATE_EOF(INITIAL):
- yyterminate();
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = yyg->yy_hold_char;
- YY_RESTORE_YY_MORE_OFFSET
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed yyin at a new source and called
- * yylex(). If so, then we have to assure
- * consistency between YY_CURRENT_BUFFER and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( yyscanner );
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
-
- yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++yyg->yy_c_buf_p;
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = yyg->yy_c_buf_p;
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer( yyscanner ) )
- {
- case EOB_ACT_END_OF_FILE:
- {
- yyg->yy_did_buffer_switch_on_eof = 0;
-
- if ( yywrap(yyscanner ) )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * yytext, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! yyg->yy_did_buffer_switch_on_eof )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- yyg->yy_c_buf_p =
- yyg->yytext_ptr + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( yyscanner );
-
- yy_cp = yyg->yy_c_buf_p;
- yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- yyg->yy_c_buf_p =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
-
- yy_current_state = yy_get_previous_state( yyscanner );
-
- yy_cp = yyg->yy_c_buf_p;
- yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
- } /* end of user's declarations */
-} /* end of yylex */
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-static int yy_get_next_buffer (yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
- char *source = yyg->yytext_ptr;
- yy_size_t number_to_move, i;
- int ret_val;
-
- if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
- {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (yy_size_t) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
-
- else
- {
- yy_size_t num_to_read =
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
-
- int yy_c_buf_p_offset =
- (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer )
- {
- yy_size_t new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 )
- b->yy_buf_size += b->yy_buf_size / 8;
- else
- b->yy_buf_size *= 2;
-
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
- }
- else
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
- number_to_move - 1;
-
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- yyg->yy_n_chars, num_to_read );
-
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
- }
-
- if ( yyg->yy_n_chars == 0 )
- {
- if ( number_to_move == YY_MORE_ADJ )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- yyrestart(yyin ,yyscanner);
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- if ((int) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
- /* Extend the array by 50%, plus the number we really need. */
- int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
- if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
- }
-
- yyg->yy_n_chars += number_to_move;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
-
- yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
-
- return ret_val;
-}
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
- static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
-{
- yy_state_type yy_current_state;
- char *yy_cp;
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-
- yy_current_state = yyg->yy_start;
-
- for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
- {
- YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
- if ( yy_accept[yy_current_state] )
- {
- yyg->yy_last_accepting_state = yy_current_state;
- yyg->yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 255 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- }
-
- return yy_current_state;
-}
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
- static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
-{
- int yy_is_jam;
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
- char *yy_cp = yyg->yy_c_buf_p;
-
- YY_CHAR yy_c = 1;
- if ( yy_accept[yy_current_state] )
- {
- yyg->yy_last_accepting_state = yy_current_state;
- yyg->yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 255 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 254);
-
- (void)yyg;
- return yy_is_jam ? 0 : yy_current_state;
-}
-
-#ifndef YY_NO_UNPUT
-
- static void yyunput (int c, char * yy_bp , yyscan_t yyscanner)
-{
- char *yy_cp;
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-
- yy_cp = yyg->yy_c_buf_p;
-
- /* undo effects of setting up yytext */
- *yy_cp = yyg->yy_hold_char;
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- /* +2 for EOB chars. */
- yy_size_t number_to_move = yyg->yy_n_chars + 2;
- char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
- char *source =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
-
- while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += (int) (dest - source);
- yy_bp += (int) (dest - source);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
- yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- *--yy_cp = (char) c;
-
- yyg->yytext_ptr = yy_bp;
- yyg->yy_hold_char = *yy_cp;
- yyg->yy_c_buf_p = yy_cp;
-}
-
-#endif
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
- static int yyinput (yyscan_t yyscanner)
-#else
- static int input (yyscan_t yyscanner)
-#endif
-
-{
- int c;
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-
- *yyg->yy_c_buf_p = yyg->yy_hold_char;
-
- if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
- /* This was really a NUL. */
- *yyg->yy_c_buf_p = '\0';
-
- else
- { /* need more input */
- yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
- ++yyg->yy_c_buf_p;
-
- switch ( yy_get_next_buffer( yyscanner ) )
- {
- case EOB_ACT_LAST_MATCH:
- /* This happens because yy_g_n_b()
- * sees that we've accumulated a
- * token and flags that we need to
- * try matching the token before
- * proceeding. But for input(),
- * there's no matching to consider.
- * So convert the EOB_ACT_LAST_MATCH
- * to EOB_ACT_END_OF_FILE.
- */
-
- /* Reset buffer status. */
- yyrestart(yyin ,yyscanner);
-
- /*FALLTHROUGH*/
-
- case EOB_ACT_END_OF_FILE:
- {
- if ( yywrap(yyscanner ) )
- return EOF;
-
- if ( ! yyg->yy_did_buffer_switch_on_eof )
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput(yyscanner);
-#else
- return input(yyscanner);
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
- break;
- }
- }
- }
-
- c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
- *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
- yyg->yy_hold_char = *++yyg->yy_c_buf_p;
-
- return c;
-}
-#endif /* ifndef YY_NO_INPUT */
-
-/** Immediately switch to a different input stream.
- * @param input_file A readable stream.
- * @param yyscanner The scanner object.
- * @note This function does not reset the start condition to @c INITIAL .
- */
- void yyrestart (FILE * input_file , yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-
- if ( ! YY_CURRENT_BUFFER ){
- yyensure_buffer_stack (yyscanner);
- YY_CURRENT_BUFFER_LVALUE =
- yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
- }
-
- yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
- yy_load_buffer_state(yyscanner );
-}
-
-/** Switch to a different input buffer.
- * @param new_buffer The new input buffer.
- * @param yyscanner The scanner object.
- */
- void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-
- /* TODO. We should be able to replace this entire function body
- * with
- * yypop_buffer_state();
- * yypush_buffer_state(new_buffer);
- */
- yyensure_buffer_stack (yyscanner);
- if ( YY_CURRENT_BUFFER == new_buffer )
- return;
-
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *yyg->yy_c_buf_p = yyg->yy_hold_char;
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
- }
-
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
- yy_load_buffer_state(yyscanner );
-
- /* We don't actually know whether we did this switch during
- * EOF (yywrap()) processing, but the only time this flag
- * is looked at is after yywrap() is called, so it's safe
- * to go ahead and always set it.
- */
- yyg->yy_did_buffer_switch_on_eof = 1;
-}
-
-static void yy_load_buffer_state (yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
- yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
- yyg->yy_hold_char = *yyg->yy_c_buf_p;
-}
-
-/** Allocate and initialize an input buffer state.
- * @param file A readable stream.
- * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
- * @param yyscanner The scanner object.
- * @return the allocated buffer state.
- */
- YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
-{
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_buf_size = (yy_size_t)size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ,yyscanner );
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_is_our_buffer = 1;
-
- yy_init_buffer(b,file ,yyscanner);
-
- return b;
-}
-
-/** Destroy the buffer.
- * @param b a buffer created with yy_create_buffer()
- * @param yyscanner The scanner object.
- */
- void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-
- if ( ! b )
- return;
-
- if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
- YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
-
- if ( b->yy_is_our_buffer )
- yyfree((void *) b->yy_ch_buf ,yyscanner );
-
- yyfree((void *) b ,yyscanner );
-}
-
-/* Initializes or reinitializes a buffer.
- * This function is sometimes called more than once on the same buffer,
- * such as during a yyrestart() or at EOF.
- */
- static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
-
-{
- int oerrno = errno;
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-
- yy_flush_buffer(b ,yyscanner);
-
- b->yy_input_file = file;
- b->yy_fill_buffer = 1;
-
- /* If b is the current buffer, then yy_init_buffer was _probably_
- * called from yyrestart() or through yy_get_next_buffer.
- * In that case, we don't want to reset the lineno or column.
- */
- if (b != YY_CURRENT_BUFFER){
- b->yy_bs_lineno = 1;
- b->yy_bs_column = 0;
- }
-
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-
- errno = oerrno;
-}
-
-/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
- * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
- * @param yyscanner The scanner object.
- */
- void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- if ( ! b )
- return;
-
- b->yy_n_chars = 0;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[0];
-
- b->yy_at_bol = 1;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- if ( b == YY_CURRENT_BUFFER )
- yy_load_buffer_state(yyscanner );
-}
-
-/** Pushes the new state onto the stack. The new state becomes
- * the current state. This function will allocate the stack
- * if necessary.
- * @param new_buffer The new state.
- * @param yyscanner The scanner object.
- */
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- if (new_buffer == NULL)
- return;
-
- yyensure_buffer_stack(yyscanner);
-
- /* This block is copied from yy_switch_to_buffer. */
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *yyg->yy_c_buf_p = yyg->yy_hold_char;
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
- }
-
- /* Only push if top exists. Otherwise, replace top. */
- if (YY_CURRENT_BUFFER)
- yyg->yy_buffer_stack_top++;
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
-
- /* copied from yy_switch_to_buffer. */
- yy_load_buffer_state(yyscanner );
- yyg->yy_did_buffer_switch_on_eof = 1;
-}
-
-/** Removes and deletes the top of the stack, if present.
- * The next element becomes the new top.
- * @param yyscanner The scanner object.
- */
-void yypop_buffer_state (yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- if (!YY_CURRENT_BUFFER)
- return;
-
- yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
- YY_CURRENT_BUFFER_LVALUE = NULL;
- if (yyg->yy_buffer_stack_top > 0)
- --yyg->yy_buffer_stack_top;
-
- if (YY_CURRENT_BUFFER) {
- yy_load_buffer_state(yyscanner );
- yyg->yy_did_buffer_switch_on_eof = 1;
- }
-}
-
-/* Allocates the stack if it does not exist.
- * Guarantees space for at least one push.
- */
-static void yyensure_buffer_stack (yyscan_t yyscanner)
-{
- yy_size_t num_to_alloc;
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-
- if (!yyg->yy_buffer_stack) {
-
- /* First allocation is just for 2 elements, since we don't know if this
- * scanner will even need a stack. We use 2 instead of 1 to avoid an
- * immediate realloc on the next call.
- */
- num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
- yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
- (num_to_alloc * sizeof(struct yy_buffer_state*)
- , yyscanner);
- if ( ! yyg->yy_buffer_stack )
- YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
-
- memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-
- yyg->yy_buffer_stack_max = num_to_alloc;
- yyg->yy_buffer_stack_top = 0;
- return;
- }
-
- if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
-
- /* Increase the buffer to prepare for a possible push. */
- yy_size_t grow_size = 8 /* arbitrary grow size */;
-
- num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
- yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
- (yyg->yy_buffer_stack,
- num_to_alloc * sizeof(struct yy_buffer_state*)
- , yyscanner);
- if ( ! yyg->yy_buffer_stack )
- YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
-
- /* zero only the new slots.*/
- memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
- yyg->yy_buffer_stack_max = num_to_alloc;
- }
-}
-
-/** Setup the input buffer state to scan directly from a user-specified character buffer.
- * @param base the character buffer
- * @param size the size in bytes of the character buffer
- * @param yyscanner The scanner object.
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
-{
- YY_BUFFER_STATE b;
-
- if ( size < 2 ||
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
- base[size-1] != YY_END_OF_BUFFER_CHAR )
- /* They forgot to leave room for the EOB's. */
- return 0;
-
- b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
-
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
- b->yy_buf_pos = b->yy_ch_buf = base;
- b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
- b->yy_n_chars = b->yy_buf_size;
- b->yy_is_interactive = 0;
- b->yy_at_bol = 1;
- b->yy_fill_buffer = 0;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- yy_switch_to_buffer(b ,yyscanner );
-
- return b;
-}
-
-/** Setup the input buffer state to scan a string. The next call to yylex() will
- * scan from a @e copy of @a str.
- * @param yystr a NUL-terminated string to scan
- * @param yyscanner The scanner object.
- * @return the newly allocated buffer state object.
- * @note If you want to scan bytes that may contain NUL values, then use
- * yy_scan_bytes() instead.
- */
-YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
-{
-
- return yy_scan_bytes(yystr,strlen(yystr) ,yyscanner);
-}
-
-/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
- * scan from a @e copy of @a bytes.
- * @param yybytes the byte buffer to scan
- * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
- * @param yyscanner The scanner object.
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner)
-{
- YY_BUFFER_STATE b;
- char *buf;
- yy_size_t n;
- yy_size_t i;
-
- /* Get memory for full buffer, including space for trailing EOB's. */
- n = _yybytes_len + 2;
- buf = (char *) yyalloc(n ,yyscanner );
- if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
-
- for ( i = 0; i < _yybytes_len; ++i )
- buf[i] = yybytes[i];
-
- buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
-
- b = yy_scan_buffer(buf,n ,yyscanner);
- if ( ! b )
- YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
-
- /* It's okay to grow etc. this buffer, and we should throw it
- * away when we're done.
- */
- b->yy_is_our_buffer = 1;
-
- return b;
-}
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- (void)yyg;
- (void) fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
-}
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- yytext[yyleng] = yyg->yy_hold_char; \
- yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
- yyg->yy_hold_char = *yyg->yy_c_buf_p; \
- *yyg->yy_c_buf_p = '\0'; \
- yyleng = yyless_macro_arg; \
- } \
- while ( 0 )
-
-/* Accessor methods (get/set functions) to struct members. */
-
-/** Get the user-defined data for this scanner.
- * @param yyscanner The scanner object.
- */
-YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- return yyextra;
-}
-
-/** Get the current line number.
- * @param yyscanner The scanner object.
- */
-int yyget_lineno (yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-
- if (! YY_CURRENT_BUFFER)
- return 0;
-
- return yylineno;
-}
-
-/** Get the current column number.
- * @param yyscanner The scanner object.
- */
-int yyget_column (yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-
- if (! YY_CURRENT_BUFFER)
- return 0;
-
- return yycolumn;
-}
-
-/** Get the input stream.
- * @param yyscanner The scanner object.
- */
-FILE *yyget_in (yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- return yyin;
-}
-
-/** Get the output stream.
- * @param yyscanner The scanner object.
- */
-FILE *yyget_out (yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- return yyout;
-}
-
-/** Get the length of the current token.
- * @param yyscanner The scanner object.
- */
-yy_size_t yyget_leng (yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- return yyleng;
-}
-
-/** Get the current token.
- * @param yyscanner The scanner object.
- */
-
-char *yyget_text (yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- return yytext;
-}
-
-/** Set the user-defined data. This data is never touched by the scanner.
- * @param user_defined The data to be associated with this scanner.
- * @param yyscanner The scanner object.
- */
-void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- yyextra = user_defined ;
-}
-
-/** Set the current line number.
- * @param _line_number line number
- * @param yyscanner The scanner object.
- */
-void yyset_lineno (int _line_number , yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-
- /* lineno is only valid if an input buffer exists. */
- if (! YY_CURRENT_BUFFER )
- YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
-
- yylineno = _line_number;
-}
-
-/** Set the current column.
- * @param _column_no column number
- * @param yyscanner The scanner object.
- */
-void yyset_column (int _column_no , yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-
- /* column is only valid if an input buffer exists. */
- if (! YY_CURRENT_BUFFER )
- YY_FATAL_ERROR( "yyset_column called with no buffer" );
-
- yycolumn = _column_no;
-}
-
-/** Set the input stream. This does not discard the current
- * input buffer.
- * @param _in_str A readable stream.
- * @param yyscanner The scanner object.
- * @see yy_switch_to_buffer
- */
-void yyset_in (FILE * _in_str , yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- yyin = _in_str ;
-}
-
-void yyset_out (FILE * _out_str , yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- yyout = _out_str ;
-}
-
-int yyget_debug (yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- return yy_flex_debug;
-}
-
-void yyset_debug (int _bdebug , yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- yy_flex_debug = _bdebug ;
-}
-
-/* Accessor methods for yylval and yylloc */
-
-/* User-visible API */
-
-/* yylex_init is special because it creates the scanner itself, so it is
- * the ONLY reentrant function that doesn't take the scanner as the last argument.
- * That's why we explicitly handle the declaration, instead of using our macros.
- */
-
-int yylex_init(yyscan_t* ptr_yy_globals)
-
-{
- if (ptr_yy_globals == NULL){
- errno = EINVAL;
- return 1;
- }
-
- *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
-
- if (*ptr_yy_globals == NULL){
- errno = ENOMEM;
- return 1;
- }
-
- /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
- memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
-
- return yy_init_globals ( *ptr_yy_globals );
-}
-
-/* yylex_init_extra has the same functionality as yylex_init, but follows the
- * convention of taking the scanner as the last argument. Note however, that
- * this is a *pointer* to a scanner, as it will be allocated by this call (and
- * is the reason, too, why this function also must handle its own declaration).
- * The user defined value in the first argument will be available to yyalloc in
- * the yyextra field.
- */
-
-int yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
-
-{
- struct yyguts_t dummy_yyguts;
-
- yyset_extra (yy_user_defined, &dummy_yyguts);
-
- if (ptr_yy_globals == NULL){
- errno = EINVAL;
- return 1;
- }
-
- *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
-
- if (*ptr_yy_globals == NULL){
- errno = ENOMEM;
- return 1;
- }
-
- /* By setting to 0xAA, we expose bugs in
- yy_init_globals. Leave at 0x00 for releases. */
- memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
-
- yyset_extra (yy_user_defined, *ptr_yy_globals);
-
- return yy_init_globals ( *ptr_yy_globals );
-}
-
-static int yy_init_globals (yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- /* Initialization is the same as for the non-reentrant scanner.
- * This function is called from yylex_destroy(), so don't allocate here.
- */
-
- yyg->yy_buffer_stack = 0;
- yyg->yy_buffer_stack_top = 0;
- yyg->yy_buffer_stack_max = 0;
- yyg->yy_c_buf_p = (char *) 0;
- yyg->yy_init = 0;
- yyg->yy_start = 0;
-
- yyg->yy_start_stack_ptr = 0;
- yyg->yy_start_stack_depth = 0;
- yyg->yy_start_stack = NULL;
-
-/* Defined in main.c */
-#ifdef YY_STDINIT
- yyin = stdin;
- yyout = stdout;
-#else
- yyin = (FILE *) 0;
- yyout = (FILE *) 0;
-#endif
-
- /* For future reference: Set errno on error, since we are called by
- * yylex_init()
- */
- return 0;
-}
-
-/* yylex_destroy is for both reentrant and non-reentrant scanners. */
-int yylex_destroy (yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-
- /* Pop the buffer stack, destroying each element. */
- while(YY_CURRENT_BUFFER){
- yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- yypop_buffer_state(yyscanner);
- }
-
- /* Destroy the stack itself. */
- yyfree(yyg->yy_buffer_stack ,yyscanner);
- yyg->yy_buffer_stack = NULL;
-
- /* Destroy the start condition stack. */
- yyfree(yyg->yy_start_stack ,yyscanner );
- yyg->yy_start_stack = NULL;
-
- /* Reset the globals. This is important in a non-reentrant scanner so the next time
- * yylex() is called, initialization will occur. */
- yy_init_globals( yyscanner);
-
- /* Destroy the main struct (reentrant only). */
- yyfree ( yyscanner , yyscanner );
- yyscanner = NULL;
- return 0;
-}
-
-/*
- * Internal utility routines.
- */
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- (void)yyg;
-
- int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
-}
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
-{
- int n;
- for ( n = 0; s[n]; ++n )
- ;
-
- return n;
-}
-#endif
-
-void *yyalloc (yy_size_t size , yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- (void)yyg;
- return (void *) malloc( size );
-}
-
-void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- (void)yyg;
-
- /* The cast to (char *) in the following accommodates both
- * implementations that use char* generic pointers, and those
- * that use void* generic pointers. It works with the latter
- * because both ANSI C and C++ allow castless assignment from
- * any pointer type to void*, and deal with argument conversions
- * as though doing an assignment.
- */
- return (void *) realloc( (char *) ptr, size );
-}
-
-void yyfree (void * ptr , yyscan_t yyscanner)
-{
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- (void)yyg;
- free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
-}
-
-#define YYTABLES_NAME "yytables"
-
-#line 90 "ts2html.flex"
-
-
-
-int yywrap(yyscan_t scanner)
-{
- return 1;
-}
-
-
-int main(int argc, const char* argv[])
-{
- ++argv, --argc; /* skip over program name */
- FILE* in;
- if ( argc > 0 )
- in = fopen( argv[0], "r" );
- else
- in = stdin;
- std::vector<Token> tokens = std::vector<Token>();
- yyscan_t scanner;
- yylex_init_extra(&tokens,&scanner);
- yyset_in(in,scanner );
- yylex(scanner);
- yylex_destroy(scanner);
- Highlighter highlighter = Highlighter(tokens);
- std::cout << highlighter.highlight();
- return 0;
-}
diff --git a/homework/81352/ts2html-hw1/token.cpp b/homework/81352/ts2html-hw1/token.cpp
deleted file mode 100644
index 97bdcdd..0000000
--- a/homework/81352/ts2html-hw1/token.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "token.h"
-
-Token::Token(std::string text, TokenType type): text(text), type(type) {}
-
-std::string Token::getTypeName() {
- switch(this->type) {
- case KEYWORD: return "keyword";
- case IDENTIFIER: return "identifier";
- case NUMBER: return "number";
- case OPERATOR: return "operator";
- case STRING: return "string";
- case OTHER: return "other";
- case SEMICOLON: return "semicolon";
- case LEFT_BLOCK_BRACKET:
- case RIGHT_BLOCK_BRACKET:
- case LEFT_BRACKET:
- case RIGHT_BRACKET: return "bracket";
- case NEWLINE:
- case WHITESPACE: return "whitespace";
- case DECORATOR: return "decorator";
- case COMMENT: return "comment";
- case UNRECOGNIZED: return "unrecognized";
- }
- return "";
-}
-std::string Token::getTextValue() {
- return this->text;
-}
-
-TokenType Token::getTokenType() {
- return this->type;
-}
diff --git a/homework/81352/ts2html-hw1/token.h b/homework/81352/ts2html-hw1/token.h
deleted file mode 100644
index 977a57c..0000000
--- a/homework/81352/ts2html-hw1/token.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef TOKEN
-#define TOKEN
-
-#include <string>
-
-enum TokenType {
- KEYWORD,
- IDENTIFIER,
- NUMBER,
- OPERATOR,
- STRING,
- SEMICOLON,
- LEFT_BLOCK_BRACKET,
- RIGHT_BLOCK_BRACKET,
- LEFT_BRACKET,
- RIGHT_BRACKET,
- NEWLINE,
- WHITESPACE,
- DECORATOR,
- COMMENT,
- OTHER,
- UNRECOGNIZED
-};
-
-class Token {
- private:
- std::string text;
- TokenType type;
- public:
- Token(std::string, TokenType);
- std::string getTypeName();
- std::string getTextValue();
- TokenType getTokenType();
-};
-#endif \ No newline at end of file
diff --git a/homework/81352/ts2html-hw1/ts2html.flex b/homework/81352/ts2html-hw1/ts2html.flex
deleted file mode 100644
index 8bc6197..0000000
--- a/homework/81352/ts2html-hw1/ts2html.flex
+++ /dev/null
@@ -1,115 +0,0 @@
-%{
-#include <vector>
-#include <iostream>
-#include "token.h"
-#include "highlighter.h"
-%}
-
-%option reentrant
-%option extra-type="std::vector<Token> *"
-
-
-DIGIT [0-9]
-ID [a-zA-Z_$][a-zA-Z0-9_$]*
-STRQ '([^\']|(\\\'))*'
-STRDQ \"([^\"]|(\\\"))*\"
-DECORATOR @[a-zA-Z]+
-LEFT_BLOCK_BRACKET "{"
-RIGHT_BLOCK_BRACKET "}"
-LEFT_BRACKET "("
-RIGHT_BRACKET ")"
-SINGLE_LINE_COMMENT "//"[^\n]*
-MULTI_LINE_COMMENT "/*".*"*/"
-COMMENT {SINGLE_LINE_COMMENT}|{MULTI_LINE_COMMENT}
-%%
-
-{COMMENT} {
- yyextra->push_back(Token(yytext, TokenType::COMMENT));
-}
-
-break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|if|import|in|instanceof|new|null|return|super|switch|this|throw|true|try|typeof|var|void|while|with|as|implements|interface|let|package|private|protected|public|static|yield|any|boolean|constructor|declare|get|module|require|number|set|string|symbol|type|from|of {
- yyextra->push_back(Token(yytext, TokenType::KEYWORD));
-}
-
-{DECORATOR} {
- yyextra->push_back(Token(yytext, TokenType::DECORATOR));
-}
-
-{STRQ}|{STRDQ} {
- yyextra->push_back(Token(yytext, TokenType::STRING));
-}
-
-{DIGIT}+ {
- yyextra->push_back(Token(yytext, TokenType::NUMBER));
-}
-
-{DIGIT}+"."{DIGIT}* {
- yyextra->push_back(Token(yytext, TokenType::NUMBER));
-}
-
-{ID} {
- yyextra->push_back(Token(yytext, TokenType::IDENTIFIER));
-}
-
-":"|"?"|"."|"!"|"~"|"-"|"+"|"++"|"--"|"*"|"/"|"%"|"<<"|">>"|">>>"|"<"|"<="|">"|">="|"=="|"!="|"==="|"!=="|"&"|"^"|"|"|"&&"|"||"|"="|"+="|"-="|"*="|"/="|"%="|"<<="|">>="|">>>="|"&="|"^="|"|="|"=>" {
- yyextra->push_back(Token(yytext, TokenType::OPERATOR));
-}
-
-";" {
- yyextra->push_back(Token(yytext, TokenType::SEMICOLON));
-}
-
-{LEFT_BLOCK_BRACKET} {
- yyextra->push_back(Token(yytext, TokenType::LEFT_BLOCK_BRACKET));
-}
-
-{RIGHT_BLOCK_BRACKET} {
- yyextra->push_back(Token(yytext, TokenType::RIGHT_BLOCK_BRACKET));
-}
-
-{LEFT_BRACKET} {
- yyextra->push_back(Token(yytext, TokenType::LEFT_BRACKET));
-}
-
-{RIGHT_BRACKET} {
- yyextra->push_back(Token(yytext, TokenType::RIGHT_BRACKET));
-}
-
-[\n] {
- yyextra->push_back(Token(yytext, TokenType::NEWLINE));
-}
-
-[ \t]+ {
- yyextra->push_back(Token(yytext, TokenType::WHITESPACE));
-}
-
-. {
- yyextra->push_back(Token(yytext, TokenType::UNRECOGNIZED));
-}
-
-%%
-
-int yywrap(yyscan_t scanner)
-{
- return 1;
-}
-
-
-int main(int argc, const char* argv[])
-{
- ++argv, --argc; /* skip over program name */
- FILE* in;
- if ( argc > 0 )
- in = fopen( argv[0], "r" );
- else
- in = stdin;
- std::vector<Token> tokens = std::vector<Token>();
- yyscan_t scanner;
- yylex_init_extra(&tokens, &scanner);
- yyset_in( in, scanner );
- yylex(scanner);
- yylex_destroy(scanner);
- Highlighter highlighter = Highlighter(tokens);
- std::cout << highlighter.highlight();
- return 0;
-} \ No newline at end of file
diff --git a/homework/81352/ts2html-hw2/Makefile b/homework/81352/ts2html-hw2/Makefile
deleted file mode 100644
index c6059aa..0000000
--- a/homework/81352/ts2html-hw2/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-all: parser
-
-lex.yy.c: ts2html.flex
- flex ts2html.flex
-
-parser.tab.c: parser.y
- bison -d parser.y
-
-parser.tab.h: parser.tab.c
-
-parser: lex.yy.c parser.tab.c parser.tab.h
- g++ -std=c++11 lex.yy.c parser.tab.c -o parser
diff --git a/homework/81352/ts2html-hw2/README.md b/homework/81352/ts2html-hw2/README.md
deleted file mode 100644
index a9b47c7..0000000
--- a/homework/81352/ts2html-hw2/README.md
+++ /dev/null
@@ -1,19 +0,0 @@
-# Homework 2
-
-Extended typescript syntax highlighter.
-
-+ code highlighting
-+ collapsible block structures
-
-### Prerequisites
-
-1. [g++ compiler](http://man7.org/linux/man-pages/man1/g++.1.html)
-2. [make](https://www.gnu.org/software/make/)
-3. [flex](https://www.gnu.org/software/flex/)
-4. [bison](https://www.gnu.org/software/bison/)
-
-### Usage
-```
-make all
-./parser.sh [ts file] > highlighted.html
-``` \ No newline at end of file
diff --git a/homework/81352/ts2html-hw2/example.html b/homework/81352/ts2html-hw2/example.html
deleted file mode 100644
index 6e3e323..0000000
--- a/homework/81352/ts2html-hw2/example.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<html><head><style> .keyword {color:blue;} .operator {color:#0e7c31; font-weight: bold} .number {color:#d119b2;} .string {color:red;} .block {display: inline; overflow: hidden;} .collapsible { background: none; border: 1px black solid;} .comment {color:grey; font-style: italic;} .line_number {opacity: 0.5;} .decorator {color:#1a1f63; font-style: italic;} </style> </head><body><pre><span class="line_number">1. </span><span class="decorator">@Decorator</span>()
-<span class="line_number">2. </span><span class="keyword">class</span> <span class="identifier">A</span> {<button class="collapsible">-</button><div class="block">
-<span class="line_number">3. </span> <span class="keyword">public</span> <span class="identifier">a</span><span class="operator">?</span><span class="operator">:</span> <span class="keyword">string</span>;
-<span class="line_number">4. </span> <span class="keyword">public</span> <span class="identifier">b</span><span class="operator">?</span><span class="operator">:</span> <span class="identifier">A</span>;
-<span class="line_number">5. </span> <span class="keyword">public</span> <span class="identifier">func</span> <span class="operator">=</span> ()<span class="operator">:</span> <span class="keyword">string</span> <span class="operator">=></span> {<button class="collapsible">-</button><div class="block">
-<span class="line_number">6. </span> <span class="keyword">return</span> <span class="keyword">this</span><span class="operator">.</span><span class="identifier">a</span>;
-<span class="line_number">7. </span> </div>}
-<span class="line_number">8. </span></div>}
-<span class="line_number">9. </span>
-<span class="line_number">10. </span><span class="comment">// comment </span>
-<span class="line_number">11. </span><span class="keyword">const</span> <span class="identifier">x</span> <span class="operator">=</span> <span class="string">"hello"</span> <span class="operator">+</span> <span class="string">" "</span> <span class="operator">+</span> <span class="string">"world"</span> <span class="operator">+</span> <span class="number">1</span>;
-<span class="line_number">12. </span>
-<span class="line_number">13. </span>{<button class="collapsible">-</button><div class="block">
-<span class="line_number">14. </span> <span class="keyword">const</span> <span class="identifier">b</span> <span class="operator">=</span> <span class="number">3</span>;
-<span class="line_number">15. </span></div>}</pre><script> var block = document.getElementsByClassName("block"); var j; for (j = 0; j < block.length; j++) { block[j].style.display = "inline"; } var coll = document.getElementsByClassName("collapsible"); var i; for (i = 0; i < coll.length; i++) { coll[i].addEventListener("click", function() { var content = this.nextElementSibling; if (content.style.display === "inline"){ content.style.display = "none"; this.innerHTML = "+"; } else { content.style.display = "inline"; this.innerHTML = "-"; } }); } </script></body></html> \ No newline at end of file
diff --git a/homework/81352/ts2html-hw2/example.ts b/homework/81352/ts2html-hw2/example.ts
deleted file mode 100644
index 01848c6..0000000
--- a/homework/81352/ts2html-hw2/example.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-@Decorator()
-class A {
- public a?: string;
- public b?: A;
- public func = (): string => {
- return this.a;
- }
-}
-
-// comment
-const x = "hello" + " " + "world" + 1;
-
-{
- const b = 3;
-} \ No newline at end of file
diff --git a/homework/81352/ts2html-hw2/lex.yy.c b/homework/81352/ts2html-hw2/lex.yy.c
deleted file mode 100644
index 756990d..0000000
--- a/homework/81352/ts2html-hw2/lex.yy.c
+++ /dev/null
@@ -1,2019 +0,0 @@
-
-#line 3 "lex.yy.c"
-
-#define YY_INT_ALIGNED short int
-
-/* A lexical scanner generated by flex */
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 0
-#if YY_FLEX_SUBMINOR_VERSION > 0
-#define FLEX_BETA
-#endif
-
-/* First, we deal with platform-specific or compiler-specific issues. */
-
-/* begin standard C headers. */
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/* end standard C headers. */
-
-/* flex integer type definitions */
-
-#ifndef FLEXINT_H
-#define FLEXINT_H
-
-/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-
-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-
-/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
- * if you want the limit (max/min) macros for int types.
- */
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS 1
-#endif
-
-#include <inttypes.h>
-typedef int8_t flex_int8_t;
-typedef uint8_t flex_uint8_t;
-typedef int16_t flex_int16_t;
-typedef uint16_t flex_uint16_t;
-typedef int32_t flex_int32_t;
-typedef uint32_t flex_uint32_t;
-#else
-typedef signed char flex_int8_t;
-typedef short int flex_int16_t;
-typedef int flex_int32_t;
-typedef unsigned char flex_uint8_t;
-typedef unsigned short int flex_uint16_t;
-typedef unsigned int flex_uint32_t;
-
-/* Limits of integral types. */
-#ifndef INT8_MIN
-#define INT8_MIN (-128)
-#endif
-#ifndef INT16_MIN
-#define INT16_MIN (-32767-1)
-#endif
-#ifndef INT32_MIN
-#define INT32_MIN (-2147483647-1)
-#endif
-#ifndef INT8_MAX
-#define INT8_MAX (127)
-#endif
-#ifndef INT16_MAX
-#define INT16_MAX (32767)
-#endif
-#ifndef INT32_MAX
-#define INT32_MAX (2147483647)
-#endif
-#ifndef UINT8_MAX
-#define UINT8_MAX (255U)
-#endif
-#ifndef UINT16_MAX
-#define UINT16_MAX (65535U)
-#endif
-#ifndef UINT32_MAX
-#define UINT32_MAX (4294967295U)
-#endif
-
-#endif /* ! C99 */
-
-#endif /* ! FLEXINT_H */
-
-#ifdef __cplusplus
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-/* C99 requires __STDC__ to be defined as 1. */
-#if defined (__STDC__)
-
-#define YY_USE_CONST
-
-#endif /* defined (__STDC__) */
-#endif /* ! __cplusplus */
-
-#ifdef YY_USE_CONST
-#define yyconst const
-#else
-#define yyconst
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN (yy_start) = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state. The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START (((yy_start) - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart(yyin )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#ifndef YY_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k.
- * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
- * Ditto for the __ia64__ case accordingly.
- */
-#define YY_BUF_SIZE 32768
-#else
-#define YY_BUF_SIZE 16384
-#endif /* __ia64__ */
-#endif
-
-/* The state buf must be large enough to hold one state per character in the main buffer.
- */
-#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
-
-#ifndef YY_TYPEDEF_YY_BUFFER_STATE
-#define YY_TYPEDEF_YY_BUFFER_STATE
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-#endif
-
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef size_t yy_size_t;
-#endif
-
-extern yy_size_t yyleng;
-
-extern FILE *yyin, *yyout;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
- #define YY_LESS_LINENO(n)
- #define YY_LINENO_REWIND_TO(ptr)
-
-/* Return all but the first "n" matched characters back to the input stream. */
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- *yy_cp = (yy_hold_char); \
- YY_RESTORE_YY_MORE_OFFSET \
- (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up yytext again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, (yytext_ptr) )
-
-#ifndef YY_STRUCT_YY_BUFFER_STATE
-#define YY_STRUCT_YY_BUFFER_STATE
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- yy_size_t yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- int yy_n_chars;
-
- /* Whether we "own" the buffer - i.e., we know we created it,
- * and can realloc() it to grow it, and should free() it to
- * delete it.
- */
- int yy_is_our_buffer;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether we're considered to be at the beginning of a line.
- * If so, '^' rules will be active on the next match, otherwise
- * not.
- */
- int yy_at_bol;
-
- int yy_bs_lineno; /**< The line count. */
- int yy_bs_column; /**< The column count. */
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via yyrestart()), so that the user can continue scanning by
- * just pointing yyin at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
-
- };
-#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-
-/* Stack of input buffers. */
-static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
-static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
-static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- *
- * Returns the top of the stack, or NULL.
- */
-#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
- ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
- : NULL)
-
-/* Same as previous macro, but useful when we know that the buffer stack is not
- * NULL or when we need an lvalue. For internal use only.
- */
-#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
-
-/* yy_hold_char holds the character lost when yytext is formed. */
-static char yy_hold_char;
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-yy_size_t yyleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 0; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow yywrap()'s to do buffer switches
- * instead of setting up a fresh yyin. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void yyrestart (FILE *input_file );
-void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
-YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
-void yy_delete_buffer (YY_BUFFER_STATE b );
-void yy_flush_buffer (YY_BUFFER_STATE b );
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
-void yypop_buffer_state (void );
-
-static void yyensure_buffer_stack (void );
-static void yy_load_buffer_state (void );
-static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
-
-#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
-
-YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
-YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );
-
-void *yyalloc (yy_size_t );
-void *yyrealloc (void *,yy_size_t );
-void yyfree (void * );
-
-#define yy_new_buffer yy_create_buffer
-
-#define yy_set_interactive(is_interactive) \
- { \
- if ( ! YY_CURRENT_BUFFER ){ \
- yyensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- yy_create_buffer(yyin,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
- }
-
-#define yy_set_bol(at_bol) \
- { \
- if ( ! YY_CURRENT_BUFFER ){\
- yyensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- yy_create_buffer(yyin,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
- }
-
-#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
-
-/* Begin user sect3 */
-
-typedef unsigned char YY_CHAR;
-
-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
-
-typedef int yy_state_type;
-
-extern int yylineno;
-
-int yylineno = 1;
-
-extern char *yytext;
-#ifdef yytext_ptr
-#undef yytext_ptr
-#endif
-#define yytext_ptr yytext
-
-static yy_state_type yy_get_previous_state (void );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
-static int yy_get_next_buffer (void );
-#if defined(__GNUC__) && __GNUC__ >= 3
-__attribute__((__noreturn__))
-#endif
-static void yy_fatal_error (yyconst char msg[] );
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up yytext.
- */
-#define YY_DO_BEFORE_ACTION \
- (yytext_ptr) = yy_bp; \
- yyleng = (size_t) (yy_cp - yy_bp); \
- (yy_hold_char) = *yy_cp; \
- *yy_cp = '\0'; \
- (yy_c_buf_p) = yy_cp;
-
-#define YY_NUM_RULES 12
-#define YY_END_OF_BUFFER 13
-/* This struct is not used in this scanner,
- but its presence is necessary. */
-struct yy_trans_info
- {
- flex_int32_t yy_verify;
- flex_int32_t yy_nxt;
- };
-static yyconst flex_int16_t yy_accept[252] =
- { 0,
- 0, 0, 13, 11, 10, 9, 11, 8, 9, 9,
- 11, 9, 9, 9, 9, 9, 11, 7, 9, 9,
- 9, 11, 9, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 4, 9, 5, 9, 0, 6, 0, 8,
- 9, 0, 0, 0, 2, 7, 0, 7, 9, 9,
- 9, 3, 8, 1, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 1, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-
- 8, 8, 6, 6, 0, 0, 2, 7, 9, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 2, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 1, 8, 8, 8,
- 1, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 0
- } ;
-
-static yyconst YY_CHAR yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 3, 4, 1, 5, 6, 7, 8, 1,
- 1, 9, 10, 1, 11, 12, 13, 14, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 16, 1, 17,
- 18, 19, 20, 21, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 1, 23, 1, 24, 5, 1, 25, 26, 27, 28,
-
- 29, 30, 31, 32, 33, 22, 34, 35, 36, 37,
- 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 22, 49, 50, 51, 52, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-static yyconst YY_CHAR yy_meta[53] =
- { 0,
- 1, 2, 1, 1, 3, 1, 1, 1, 1, 1,
- 1, 1, 1, 3, 3, 1, 1, 1, 1, 1,
- 1, 4, 1, 1, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
- 1, 1
- } ;
-
-static yyconst flex_uint16_t yy_base[258] =
- { 0,
- 0, 0, 370, 371, 371, 351, 49, 0, 350, 47,
- 47, 349, 46, 48, 371, 49, 59, 63, 43, 50,
- 61, 0, 348, 39, 44, 58, 57, 52, 59, 336,
- 68, 335, 325, 62, 332, 69, 332, 72, 76, 84,
- 79, 327, 371, 84, 371, 341, 84, 371, 110, 0,
- 371, 113, 115, 349, 0, 111, 115, 125, 339, 338,
- 113, 0, 307, 0, 316, 324, 99, 327, 314, 117,
- 308, 305, 106, 313, 310, 305, 307, 307, 300, 303,
- 108, 298, 312, 293, 118, 311, 122, 311, 116, 293,
- 94, 296, 301, 297, 124, 114, 293, 290, 297, 296,
-
- 285, 298, 144, 138, 317, 155, 0, 155, 307, 289,
- 298, 293, 294, 278, 129, 275, 283, 292, 287, 286,
- 278, 275, 283, 269, 285, 273, 281, 128, 264, 277,
- 261, 269, 277, 268, 256, 257, 264, 254, 253, 253,
- 262, 265, 250, 266, 249, 252, 260, 259, 259, 251,
- 253, 249, 274, 253, 247, 248, 237, 235, 244, 245,
- 250, 230, 230, 231, 234, 241, 234, 225, 238, 225,
- 240, 223, 228, 233, 236, 235, 230, 225, 224, 215,
- 222, 217, 212, 225, 213, 204, 211, 219, 219, 221,
- 204, 207, 212, 201, 206, 211, 196, 210, 202, 203,
-
- 199, 191, 196, 202, 202, 189, 198, 185, 200, 199,
- 184, 187, 196, 191, 189, 185, 189, 181, 173, 172,
- 186, 185, 170, 170, 163, 172, 180, 181, 182, 177,
- 176, 161, 174, 175, 172, 159, 162, 161, 168, 169,
- 166, 151, 150, 154, 162, 160, 146, 86, 60, 22,
- 371, 172, 174, 178, 53, 182, 186
- } ;
-
-static yyconst flex_int16_t yy_def[258] =
- { 0,
- 251, 1, 251, 251, 251, 251, 252, 253, 251, 251,
- 254, 251, 251, 251, 251, 251, 251, 251, 251, 251,
- 251, 255, 251, 253, 253, 253, 253, 253, 253, 253,
- 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
- 253, 253, 251, 251, 251, 251, 252, 251, 252, 253,
- 251, 254, 254, 256, 257, 251, 251, 251, 251, 251,
- 251, 255, 253, 253, 253, 253, 253, 253, 253, 253,
- 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
- 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
- 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
-
- 253, 253, 252, 254, 256, 256, 257, 251, 251, 253,
- 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
- 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
- 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
- 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
- 253, 253, 256, 253, 253, 253, 253, 253, 253, 253,
- 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
- 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
- 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
- 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
-
- 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
- 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
- 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
- 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
- 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
- 0, 251, 251, 251, 251, 251, 251
- } ;
-
-static yyconst flex_uint16_t yy_nxt[424] =
- { 0,
- 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
- 14, 15, 16, 17, 18, 15, 19, 20, 21, 15,
- 22, 8, 4, 23, 24, 25, 26, 27, 28, 29,
- 30, 8, 31, 8, 32, 33, 34, 35, 36, 8,
- 37, 38, 39, 8, 40, 41, 8, 42, 43, 44,
- 45, 15, 48, 51, 48, 51, 62, 54, 51, 59,
- 51, 55, 64, 51, 51, 51, 51, 60, 51, 53,
- 56, 49, 57, 57, 56, 63, 58, 58, 51, 61,
- 64, 65, 67, 74, 66, 70, 71, 48, 72, 64,
- 84, 75, 68, 86, 64, 69, 76, 64, 73, 77,
-
- 90, 51, 78, 80, 81, 85, 49, 95, 98, 87,
- 100, 101, 88, 103, 91, 92, 96, 93, 140, 94,
- 48, 99, 104, 97, 108, 108, 56, 64, 57, 57,
- 51, 109, 49, 51, 141, 53, 56, 53, 58, 58,
- 112, 113, 116, 117, 122, 48, 118, 48, 123, 129,
- 130, 119, 132, 133, 135, 138, 145, 147, 139, 136,
- 53, 64, 169, 106, 146, 170, 49, 153, 108, 108,
- 158, 159, 47, 47, 47, 47, 50, 50, 52, 52,
- 52, 52, 105, 250, 105, 105, 107, 64, 107, 107,
- 64, 249, 248, 247, 246, 245, 244, 243, 64, 64,
-
- 64, 242, 64, 241, 64, 64, 240, 239, 238, 237,
- 64, 64, 64, 64, 236, 235, 234, 64, 64, 64,
- 64, 64, 64, 64, 233, 64, 232, 231, 230, 64,
- 64, 229, 228, 64, 227, 226, 225, 224, 64, 64,
- 223, 222, 221, 220, 219, 218, 64, 64, 217, 64,
- 216, 215, 64, 214, 213, 212, 211, 210, 209, 208,
- 207, 206, 205, 204, 203, 202, 201, 200, 199, 64,
- 198, 197, 196, 195, 194, 193, 192, 191, 64, 64,
- 64, 190, 106, 189, 64, 188, 64, 187, 64, 186,
- 64, 185, 184, 183, 182, 181, 180, 179, 178, 177,
-
- 176, 175, 174, 64, 173, 172, 171, 168, 64, 167,
- 166, 165, 164, 64, 64, 163, 162, 161, 160, 157,
- 156, 64, 155, 154, 51, 106, 152, 151, 150, 149,
- 64, 148, 144, 143, 142, 64, 137, 134, 64, 131,
- 64, 128, 64, 127, 126, 64, 125, 124, 121, 120,
- 115, 114, 111, 110, 64, 51, 51, 106, 51, 102,
- 89, 64, 83, 82, 79, 51, 51, 51, 46, 251,
- 3, 251, 251, 251, 251, 251, 251, 251, 251, 251,
- 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
- 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
-
- 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
- 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
- 251, 251, 251
- } ;
-
-static yyconst flex_int16_t yy_chk[424] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 7, 10, 11, 13, 255, 16, 14, 19,
- 19, 16, 250, 13, 10, 14, 16, 20, 20, 11,
- 17, 7, 17, 17, 18, 24, 18, 18, 21, 21,
- 24, 25, 26, 29, 25, 27, 28, 47, 28, 249,
- 34, 29, 26, 36, 27, 26, 29, 31, 28, 29,
-
- 38, 44, 29, 31, 31, 34, 47, 39, 40, 36,
- 41, 41, 36, 49, 38, 38, 39, 38, 91, 38,
- 52, 40, 53, 39, 56, 56, 57, 248, 57, 57,
- 61, 61, 49, 44, 91, 52, 58, 53, 58, 58,
- 67, 67, 70, 70, 73, 104, 70, 103, 73, 81,
- 81, 70, 85, 85, 87, 89, 95, 96, 89, 87,
- 104, 96, 128, 106, 95, 128, 103, 106, 108, 108,
- 115, 115, 252, 252, 252, 252, 253, 253, 254, 254,
- 254, 254, 256, 247, 256, 256, 257, 246, 257, 257,
- 245, 244, 243, 242, 241, 240, 239, 238, 237, 236,
-
- 235, 234, 233, 232, 231, 230, 229, 228, 227, 226,
- 225, 224, 223, 222, 221, 220, 219, 218, 217, 216,
- 215, 214, 213, 212, 211, 210, 209, 208, 207, 206,
- 205, 204, 203, 202, 201, 200, 199, 198, 197, 196,
- 195, 194, 193, 192, 191, 190, 189, 188, 187, 186,
- 185, 184, 183, 182, 181, 180, 179, 178, 177, 176,
- 175, 174, 173, 172, 171, 170, 169, 168, 167, 166,
- 165, 164, 163, 162, 161, 160, 159, 158, 157, 156,
- 155, 154, 153, 152, 151, 150, 149, 148, 147, 146,
- 145, 144, 143, 142, 141, 140, 139, 138, 137, 136,
-
- 135, 134, 133, 132, 131, 130, 129, 127, 126, 125,
- 124, 123, 122, 121, 120, 119, 118, 117, 116, 114,
- 113, 112, 111, 110, 109, 105, 102, 101, 100, 99,
- 98, 97, 94, 93, 92, 90, 88, 86, 84, 83,
- 82, 80, 79, 78, 77, 76, 75, 74, 72, 71,
- 69, 68, 66, 65, 63, 60, 59, 54, 46, 42,
- 37, 35, 33, 32, 30, 23, 12, 9, 6, 3,
- 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
- 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
- 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
-
- 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
- 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
- 251, 251, 251
- } ;
-
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-extern int yy_flex_debug;
-int yy_flex_debug = 0;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-char *yytext;
-#line 1 "ts2html.flex"
-#line 2 "ts2html.flex"
-#include "parser.tab.h"
-#line 645 "lex.yy.c"
-
-#define INITIAL 0
-
-#ifndef YY_NO_UNISTD_H
-/* Special case for "unistd.h", since it is non-ANSI. We include it way
- * down here because we want the user's section 1 to have been scanned first.
- * The user has a chance to override it with an option.
- */
-#include <unistd.h>
-#endif
-
-#ifndef YY_EXTRA_TYPE
-#define YY_EXTRA_TYPE void *
-#endif
-
-static int yy_init_globals (void );
-
-/* Accessor methods to globals.
- These are made visible to non-reentrant scanners for convenience. */
-
-int yylex_destroy (void );
-
-int yyget_debug (void );
-
-void yyset_debug (int debug_flag );
-
-YY_EXTRA_TYPE yyget_extra (void );
-
-void yyset_extra (YY_EXTRA_TYPE user_defined );
-
-FILE *yyget_in (void );
-
-void yyset_in (FILE * _in_str );
-
-FILE *yyget_out (void );
-
-void yyset_out (FILE * _out_str );
-
-yy_size_t yyget_leng (void );
-
-char *yyget_text (void );
-
-int yyget_lineno (void );
-
-void yyset_lineno (int _line_number );
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int yywrap (void );
-#else
-extern int yywrap (void );
-#endif
-#endif
-
-#ifndef YY_NO_UNPUT
-
- static void yyunput (int c,char *buf_ptr );
-
-#endif
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int );
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * );
-#endif
-
-#ifndef YY_NO_INPUT
-
-#ifdef __cplusplus
-static int yyinput (void );
-#else
-static int input (void );
-#endif
-
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k */
-#define YY_READ_BUF_SIZE 16384
-#else
-#define YY_READ_BUF_SIZE 8192
-#endif /* __ia64__ */
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
- { \
- int c = '*'; \
- size_t n; \
- for ( n = 0; n < max_size && \
- (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
- buf[n] = (char) c; \
- if ( c == '\n' ) \
- buf[n++] = (char) c; \
- if ( c == EOF && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- result = n; \
- } \
- else \
- { \
- errno=0; \
- while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
- { \
- if( errno != EINTR) \
- { \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- break; \
- } \
- errno=0; \
- clearerr(yyin); \
- } \
- }\
-\
-
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* end tables serialization structures and prototypes */
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL_IS_OURS 1
-
-extern int yylex (void);
-
-#define YY_DECL int yylex (void)
-#endif /* !YY_DECL */
-
-/* Code executed at the beginning of each rule, after yytext and yyleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK /*LINTED*/break;
-#endif
-
-#define YY_RULE_SETUP \
- YY_USER_ACTION
-
-/** The main scanner function which does all the work.
- */
-YY_DECL
-{
- yy_state_type yy_current_state;
- char *yy_cp, *yy_bp;
- int yy_act;
-
- if ( !(yy_init) )
- {
- (yy_init) = 1;
-
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! (yy_start) )
- (yy_start) = 1; /* first start state */
-
- if ( ! yyin )
- yyin = stdin;
-
- if ( ! yyout )
- yyout = stdout;
-
- if ( ! YY_CURRENT_BUFFER ) {
- yyensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- yy_create_buffer(yyin,YY_BUF_SIZE );
- }
-
- yy_load_buffer_state( );
- }
-
- {
-#line 15 "ts2html.flex"
-
-
-#line 866 "lex.yy.c"
-
- while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
- {
- yy_cp = (yy_c_buf_p);
-
- /* Support of yytext. */
- *yy_cp = (yy_hold_char);
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = (yy_start);
-yy_match:
- do
- {
- YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 252 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- ++yy_cp;
- }
- while ( yy_base[yy_current_state] != 371 );
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
- if ( yy_act == 0 )
- { /* have to back up */
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- yy_act = yy_accept[yy_current_state];
- }
-
- YY_DO_BEFORE_ACTION;
-
-do_action: /* This label is used only to access EOF actions. */
-
- switch ( yy_act )
- { /* beginning of action switch */
- case 0: /* must back up */
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = (yy_hold_char);
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- goto yy_find_action;
-
-case 1:
-YY_RULE_SETUP
-#line 17 "ts2html.flex"
-{
- yylval = yytext;
- return KEYWORD;
-}
- YY_BREAK
-case 2:
-YY_RULE_SETUP
-#line 22 "ts2html.flex"
-{
- yylval = yytext;
- return COMMENT;
-}
- YY_BREAK
-case 3:
-YY_RULE_SETUP
-#line 27 "ts2html.flex"
-{
- yylval = yytext;
- return DECORATOR;
-}
- YY_BREAK
-case 4:
-YY_RULE_SETUP
-#line 32 "ts2html.flex"
-{ return '{'; }
- YY_BREAK
-case 5:
-YY_RULE_SETUP
-#line 34 "ts2html.flex"
-{ return '}'; }
- YY_BREAK
-case 6:
-/* rule 6 can match eol */
-YY_RULE_SETUP
-#line 36 "ts2html.flex"
-{
- yylval = yytext;
- return STRING;
-}
- YY_BREAK
-case 7:
-YY_RULE_SETUP
-#line 41 "ts2html.flex"
-{
- yylval = yytext;
- return NUMBER;
-}
- YY_BREAK
-case 8:
-YY_RULE_SETUP
-#line 46 "ts2html.flex"
-{
- yylval = yytext;
- return IDENTIFIER;
-}
- YY_BREAK
-case 9:
-YY_RULE_SETUP
-#line 51 "ts2html.flex"
-{
- yylval = yytext;
- return OPERATOR;
-}
- YY_BREAK
-case 10:
-/* rule 10 can match eol */
-YY_RULE_SETUP
-#line 56 "ts2html.flex"
-{
- yylval = yytext;
- return NEWLINE;
-}
- YY_BREAK
-case 11:
-YY_RULE_SETUP
-#line 61 "ts2html.flex"
-{
- yylval = yytext;
- return OTHER;
-}
- YY_BREAK
-case 12:
-YY_RULE_SETUP
-#line 66 "ts2html.flex"
-ECHO;
- YY_BREAK
-#line 1012 "lex.yy.c"
-case YY_STATE_EOF(INITIAL):
- yyterminate();
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = (yy_hold_char);
- YY_RESTORE_YY_MORE_OFFSET
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed yyin at a new source and called
- * yylex(). If so, then we have to assure
- * consistency between YY_CURRENT_BUFFER and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++(yy_c_buf_p);
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = (yy_c_buf_p);
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_END_OF_FILE:
- {
- (yy_did_buffer_switch_on_eof) = 0;
-
- if ( yywrap( ) )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * yytext, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) =
- (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- (yy_c_buf_p) =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
- } /* end of user's declarations */
-} /* end of yylex */
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-static int yy_get_next_buffer (void)
-{
- char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
- char *source = (yytext_ptr);
- yy_size_t number_to_move, i;
- int ret_val;
-
- if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
- {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
-
- else
- {
- yy_size_t num_to_read =
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
-
- int yy_c_buf_p_offset =
- (int) ((yy_c_buf_p) - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer )
- {
- yy_size_t new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 )
- b->yy_buf_size += b->yy_buf_size / 8;
- else
- b->yy_buf_size *= 2;
-
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
- }
- else
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
- number_to_move - 1;
-
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- (yy_n_chars), num_to_read );
-
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- if ( (yy_n_chars) == 0 )
- {
- if ( number_to_move == YY_MORE_ADJ )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- yyrestart(yyin );
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- if ((int) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
- /* Extend the array by 50%, plus the number we really need. */
- int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
- if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
- }
-
- (yy_n_chars) += number_to_move;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
-
- (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
-
- return ret_val;
-}
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
- static yy_state_type yy_get_previous_state (void)
-{
- yy_state_type yy_current_state;
- char *yy_cp;
-
- yy_current_state = (yy_start);
-
- for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
- {
- YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 252 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- }
-
- return yy_current_state;
-}
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
- static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
-{
- int yy_is_jam;
- char *yy_cp = (yy_c_buf_p);
-
- YY_CHAR yy_c = 1;
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 252 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 251);
-
- return yy_is_jam ? 0 : yy_current_state;
-}
-
-#ifndef YY_NO_UNPUT
-
- static void yyunput (int c, char * yy_bp )
-{
- char *yy_cp;
-
- yy_cp = (yy_c_buf_p);
-
- /* undo effects of setting up yytext */
- *yy_cp = (yy_hold_char);
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- /* +2 for EOB chars. */
- yy_size_t number_to_move = (yy_n_chars) + 2;
- char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
- char *source =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
-
- while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += (int) (dest - source);
- yy_bp += (int) (dest - source);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- *--yy_cp = (char) c;
-
- (yytext_ptr) = yy_bp;
- (yy_hold_char) = *yy_cp;
- (yy_c_buf_p) = yy_cp;
-}
-
-#endif
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
- static int yyinput (void)
-#else
- static int input (void)
-#endif
-
-{
- int c;
-
- *(yy_c_buf_p) = (yy_hold_char);
-
- if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- /* This was really a NUL. */
- *(yy_c_buf_p) = '\0';
-
- else
- { /* need more input */
- yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
- ++(yy_c_buf_p);
-
- switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_LAST_MATCH:
- /* This happens because yy_g_n_b()
- * sees that we've accumulated a
- * token and flags that we need to
- * try matching the token before
- * proceeding. But for input(),
- * there's no matching to consider.
- * So convert the EOB_ACT_LAST_MATCH
- * to EOB_ACT_END_OF_FILE.
- */
-
- /* Reset buffer status. */
- yyrestart(yyin );
-
- /*FALLTHROUGH*/
-
- case EOB_ACT_END_OF_FILE:
- {
- if ( yywrap( ) )
- return EOF;
-
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) = (yytext_ptr) + offset;
- break;
- }
- }
- }
-
- c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
- *(yy_c_buf_p) = '\0'; /* preserve yytext */
- (yy_hold_char) = *++(yy_c_buf_p);
-
- return c;
-}
-#endif /* ifndef YY_NO_INPUT */
-
-/** Immediately switch to a different input stream.
- * @param input_file A readable stream.
- *
- * @note This function does not reset the start condition to @c INITIAL .
- */
- void yyrestart (FILE * input_file )
-{
-
- if ( ! YY_CURRENT_BUFFER ){
- yyensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- yy_create_buffer(yyin,YY_BUF_SIZE );
- }
-
- yy_init_buffer(YY_CURRENT_BUFFER,input_file );
- yy_load_buffer_state( );
-}
-
-/** Switch to a different input buffer.
- * @param new_buffer The new input buffer.
- *
- */
- void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
-{
-
- /* TODO. We should be able to replace this entire function body
- * with
- * yypop_buffer_state();
- * yypush_buffer_state(new_buffer);
- */
- yyensure_buffer_stack ();
- if ( YY_CURRENT_BUFFER == new_buffer )
- return;
-
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
- yy_load_buffer_state( );
-
- /* We don't actually know whether we did this switch during
- * EOF (yywrap()) processing, but the only time this flag
- * is looked at is after yywrap() is called, so it's safe
- * to go ahead and always set it.
- */
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-static void yy_load_buffer_state (void)
-{
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
- yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
- (yy_hold_char) = *(yy_c_buf_p);
-}
-
-/** Allocate and initialize an input buffer state.
- * @param file A readable stream.
- * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
- *
- * @return the allocated buffer state.
- */
- YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
-{
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_buf_size = (yy_size_t)size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_is_our_buffer = 1;
-
- yy_init_buffer(b,file );
-
- return b;
-}
-
-/** Destroy the buffer.
- * @param b a buffer created with yy_create_buffer()
- *
- */
- void yy_delete_buffer (YY_BUFFER_STATE b )
-{
-
- if ( ! b )
- return;
-
- if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
- YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
-
- if ( b->yy_is_our_buffer )
- yyfree((void *) b->yy_ch_buf );
-
- yyfree((void *) b );
-}
-
-/* Initializes or reinitializes a buffer.
- * This function is sometimes called more than once on the same buffer,
- * such as during a yyrestart() or at EOF.
- */
- static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
-
-{
- int oerrno = errno;
-
- yy_flush_buffer(b );
-
- b->yy_input_file = file;
- b->yy_fill_buffer = 1;
-
- /* If b is the current buffer, then yy_init_buffer was _probably_
- * called from yyrestart() or through yy_get_next_buffer.
- * In that case, we don't want to reset the lineno or column.
- */
- if (b != YY_CURRENT_BUFFER){
- b->yy_bs_lineno = 1;
- b->yy_bs_column = 0;
- }
-
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-
- errno = oerrno;
-}
-
-/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
- * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
- *
- */
- void yy_flush_buffer (YY_BUFFER_STATE b )
-{
- if ( ! b )
- return;
-
- b->yy_n_chars = 0;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[0];
-
- b->yy_at_bol = 1;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- if ( b == YY_CURRENT_BUFFER )
- yy_load_buffer_state( );
-}
-
-/** Pushes the new state onto the stack. The new state becomes
- * the current state. This function will allocate the stack
- * if necessary.
- * @param new_buffer The new state.
- *
- */
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
-{
- if (new_buffer == NULL)
- return;
-
- yyensure_buffer_stack();
-
- /* This block is copied from yy_switch_to_buffer. */
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- /* Only push if top exists. Otherwise, replace top. */
- if (YY_CURRENT_BUFFER)
- (yy_buffer_stack_top)++;
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
-
- /* copied from yy_switch_to_buffer. */
- yy_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-/** Removes and deletes the top of the stack, if present.
- * The next element becomes the new top.
- *
- */
-void yypop_buffer_state (void)
-{
- if (!YY_CURRENT_BUFFER)
- return;
-
- yy_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- if ((yy_buffer_stack_top) > 0)
- --(yy_buffer_stack_top);
-
- if (YY_CURRENT_BUFFER) {
- yy_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
- }
-}
-
-/* Allocates the stack if it does not exist.
- * Guarantees space for at least one push.
- */
-static void yyensure_buffer_stack (void)
-{
- yy_size_t num_to_alloc;
-
- if (!(yy_buffer_stack)) {
-
- /* First allocation is just for 2 elements, since we don't know if this
- * scanner will even need a stack. We use 2 instead of 1 to avoid an
- * immediate realloc on the next call.
- */
- num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
- (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
- (num_to_alloc * sizeof(struct yy_buffer_state*)
- );
- if ( ! (yy_buffer_stack) )
- YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
-
- memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-
- (yy_buffer_stack_max) = num_to_alloc;
- (yy_buffer_stack_top) = 0;
- return;
- }
-
- if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
-
- /* Increase the buffer to prepare for a possible push. */
- yy_size_t grow_size = 8 /* arbitrary grow size */;
-
- num_to_alloc = (yy_buffer_stack_max) + grow_size;
- (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
- ((yy_buffer_stack),
- num_to_alloc * sizeof(struct yy_buffer_state*)
- );
- if ( ! (yy_buffer_stack) )
- YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
-
- /* zero only the new slots.*/
- memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
- (yy_buffer_stack_max) = num_to_alloc;
- }
-}
-
-/** Setup the input buffer state to scan directly from a user-specified character buffer.
- * @param base the character buffer
- * @param size the size in bytes of the character buffer
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
-{
- YY_BUFFER_STATE b;
-
- if ( size < 2 ||
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
- base[size-1] != YY_END_OF_BUFFER_CHAR )
- /* They forgot to leave room for the EOB's. */
- return 0;
-
- b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
-
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
- b->yy_buf_pos = b->yy_ch_buf = base;
- b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
- b->yy_n_chars = b->yy_buf_size;
- b->yy_is_interactive = 0;
- b->yy_at_bol = 1;
- b->yy_fill_buffer = 0;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- yy_switch_to_buffer(b );
-
- return b;
-}
-
-/** Setup the input buffer state to scan a string. The next call to yylex() will
- * scan from a @e copy of @a str.
- * @param yystr a NUL-terminated string to scan
- *
- * @return the newly allocated buffer state object.
- * @note If you want to scan bytes that may contain NUL values, then use
- * yy_scan_bytes() instead.
- */
-YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
-{
-
- return yy_scan_bytes(yystr,strlen(yystr) );
-}
-
-/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
- * scan from a @e copy of @a bytes.
- * @param yybytes the byte buffer to scan
- * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
-{
- YY_BUFFER_STATE b;
- char *buf;
- yy_size_t n;
- yy_size_t i;
-
- /* Get memory for full buffer, including space for trailing EOB's. */
- n = _yybytes_len + 2;
- buf = (char *) yyalloc(n );
- if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
-
- for ( i = 0; i < _yybytes_len; ++i )
- buf[i] = yybytes[i];
-
- buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
-
- b = yy_scan_buffer(buf,n );
- if ( ! b )
- YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
-
- /* It's okay to grow etc. this buffer, and we should throw it
- * away when we're done.
- */
- b->yy_is_our_buffer = 1;
-
- return b;
-}
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-static void yy_fatal_error (yyconst char* msg )
-{
- (void) fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
-}
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- yytext[yyleng] = (yy_hold_char); \
- (yy_c_buf_p) = yytext + yyless_macro_arg; \
- (yy_hold_char) = *(yy_c_buf_p); \
- *(yy_c_buf_p) = '\0'; \
- yyleng = yyless_macro_arg; \
- } \
- while ( 0 )
-
-/* Accessor methods (get/set functions) to struct members. */
-
-/** Get the current line number.
- *
- */
-int yyget_lineno (void)
-{
-
- return yylineno;
-}
-
-/** Get the input stream.
- *
- */
-FILE *yyget_in (void)
-{
- return yyin;
-}
-
-/** Get the output stream.
- *
- */
-FILE *yyget_out (void)
-{
- return yyout;
-}
-
-/** Get the length of the current token.
- *
- */
-yy_size_t yyget_leng (void)
-{
- return yyleng;
-}
-
-/** Get the current token.
- *
- */
-
-char *yyget_text (void)
-{
- return yytext;
-}
-
-/** Set the current line number.
- * @param _line_number line number
- *
- */
-void yyset_lineno (int _line_number )
-{
-
- yylineno = _line_number;
-}
-
-/** Set the input stream. This does not discard the current
- * input buffer.
- * @param _in_str A readable stream.
- *
- * @see yy_switch_to_buffer
- */
-void yyset_in (FILE * _in_str )
-{
- yyin = _in_str ;
-}
-
-void yyset_out (FILE * _out_str )
-{
- yyout = _out_str ;
-}
-
-int yyget_debug (void)
-{
- return yy_flex_debug;
-}
-
-void yyset_debug (int _bdebug )
-{
- yy_flex_debug = _bdebug ;
-}
-
-static int yy_init_globals (void)
-{
- /* Initialization is the same as for the non-reentrant scanner.
- * This function is called from yylex_destroy(), so don't allocate here.
- */
-
- (yy_buffer_stack) = 0;
- (yy_buffer_stack_top) = 0;
- (yy_buffer_stack_max) = 0;
- (yy_c_buf_p) = (char *) 0;
- (yy_init) = 0;
- (yy_start) = 0;
-
-/* Defined in main.c */
-#ifdef YY_STDINIT
- yyin = stdin;
- yyout = stdout;
-#else
- yyin = (FILE *) 0;
- yyout = (FILE *) 0;
-#endif
-
- /* For future reference: Set errno on error, since we are called by
- * yylex_init()
- */
- return 0;
-}
-
-/* yylex_destroy is for both reentrant and non-reentrant scanners. */
-int yylex_destroy (void)
-{
-
- /* Pop the buffer stack, destroying each element. */
- while(YY_CURRENT_BUFFER){
- yy_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- yypop_buffer_state();
- }
-
- /* Destroy the stack itself. */
- yyfree((yy_buffer_stack) );
- (yy_buffer_stack) = NULL;
-
- /* Reset the globals. This is important in a non-reentrant scanner so the next time
- * yylex() is called, initialization will occur. */
- yy_init_globals( );
-
- return 0;
-}
-
-/*
- * Internal utility routines.
- */
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
-{
-
- int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
-}
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s )
-{
- int n;
- for ( n = 0; s[n]; ++n )
- ;
-
- return n;
-}
-#endif
-
-void *yyalloc (yy_size_t size )
-{
- return (void *) malloc( size );
-}
-
-void *yyrealloc (void * ptr, yy_size_t size )
-{
-
- /* The cast to (char *) in the following accommodates both
- * implementations that use char* generic pointers, and those
- * that use void* generic pointers. It works with the latter
- * because both ANSI C and C++ allow castless assignment from
- * any pointer type to void*, and deal with argument conversions
- * as though doing an assignment.
- */
- return (void *) realloc( (char *) ptr, size );
-}
-
-void yyfree (void * ptr )
-{
- free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
-}
-
-#define YYTABLES_NAME "yytables"
-
-#line 66 "ts2html.flex"
-
-
-
-int yywrap()
-{
- return 1;
-}
diff --git a/homework/81352/ts2html-hw2/parser.sh b/homework/81352/ts2html-hw2/parser.sh
deleted file mode 100755
index 08df4ca..0000000
--- a/homework/81352/ts2html-hw2/parser.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-cat $1 | ./parser \ No newline at end of file
diff --git a/homework/81352/ts2html-hw2/parser.tab.c b/homework/81352/ts2html-hw2/parser.tab.c
deleted file mode 100644
index 35d2b19..0000000
--- a/homework/81352/ts2html-hw2/parser.tab.c
+++ /dev/null
@@ -1,1551 +0,0 @@
-/* A Bison parser, made by GNU Bison 3.0.4. */
-
-/* Bison implementation for Yacc-like parsers in C
-
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-/* C LALR(1) parser skeleton written by Richard Stallman, by
- simplifying the original so-called "semantic" parser. */
-
-/* All symbols defined below should begin with yy or YY, to avoid
- infringing on user name space. This should be done even for local
- variables, as they might otherwise be expanded by user macros.
- There are some unavoidable exceptions within include files to
- define necessary library symbols; they are noted "INFRINGES ON
- USER NAME SPACE" below. */
-
-/* Identify Bison output. */
-#define YYBISON 1
-
-/* Bison version. */
-#define YYBISON_VERSION "3.0.4"
-
-/* Skeleton name. */
-#define YYSKELETON_NAME "yacc.c"
-
-/* Pure parsers. */
-#define YYPURE 0
-
-/* Push parsers. */
-#define YYPUSH 0
-
-/* Pull parsers. */
-#define YYPULL 1
-
-
-
-
-/* Copy the first part of user declarations. */
-#line 1 "parser.y" /* yacc.c:339 */
-
-#include <iostream>
-int yylex();
-int yyerror(const char* error);
-int current_line = 1;
-
-#line 73 "parser.tab.c" /* yacc.c:339 */
-
-# ifndef YY_NULLPTR
-# if defined __cplusplus && 201103L <= __cplusplus
-# define YY_NULLPTR nullptr
-# else
-# define YY_NULLPTR 0
-# endif
-# endif
-
-/* Enabling verbose error messages. */
-#ifdef YYERROR_VERBOSE
-# undef YYERROR_VERBOSE
-# define YYERROR_VERBOSE 1
-#else
-# define YYERROR_VERBOSE 0
-#endif
-
-/* In a future release of Bison, this section will be replaced
- by #include "parser.tab.h". */
-#ifndef YY_YY_PARSER_TAB_H_INCLUDED
-# define YY_YY_PARSER_TAB_H_INCLUDED
-/* Debug traces. */
-#ifndef YYDEBUG
-# define YYDEBUG 0
-#endif
-#if YYDEBUG
-extern int yydebug;
-#endif
-/* "%code requires" blocks. */
-#line 8 "parser.y" /* yacc.c:355 */
-#include <string>
-
-#line 106 "parser.tab.c" /* yacc.c:355 */
-
-/* Token type. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- enum yytokentype
- {
- KEYWORD = 258,
- STRING = 259,
- NUMBER = 260,
- IDENTIFIER = 261,
- OPERATOR = 262,
- OTHER = 263,
- NEWLINE = 264,
- DECORATOR = 265,
- COMMENT = 266
- };
-#endif
-
-/* Value type. */
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef std::string YYSTYPE;
-# define YYSTYPE_IS_TRIVIAL 1
-# define YYSTYPE_IS_DECLARED 1
-#endif
-
-
-extern YYSTYPE yylval;
-
-int yyparse (void);
-
-#endif /* !YY_YY_PARSER_TAB_H_INCLUDED */
-
-/* Copy the second part of user declarations. */
-
-#line 141 "parser.tab.c" /* yacc.c:358 */
-
-#ifdef short
-# undef short
-#endif
-
-#ifdef YYTYPE_UINT8
-typedef YYTYPE_UINT8 yytype_uint8;
-#else
-typedef unsigned char yytype_uint8;
-#endif
-
-#ifdef YYTYPE_INT8
-typedef YYTYPE_INT8 yytype_int8;
-#else
-typedef signed char yytype_int8;
-#endif
-
-#ifdef YYTYPE_UINT16
-typedef YYTYPE_UINT16 yytype_uint16;
-#else
-typedef unsigned short int yytype_uint16;
-#endif
-
-#ifdef YYTYPE_INT16
-typedef YYTYPE_INT16 yytype_int16;
-#else
-typedef short int yytype_int16;
-#endif
-
-#ifndef YYSIZE_T
-# ifdef __SIZE_TYPE__
-# define YYSIZE_T __SIZE_TYPE__
-# elif defined size_t
-# define YYSIZE_T size_t
-# elif ! defined YYSIZE_T
-# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# else
-# define YYSIZE_T unsigned int
-# endif
-#endif
-
-#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
-
-#ifndef YY_
-# if defined YYENABLE_NLS && YYENABLE_NLS
-# if ENABLE_NLS
-# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
-# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
-# endif
-# endif
-# ifndef YY_
-# define YY_(Msgid) Msgid
-# endif
-#endif
-
-#ifndef YY_ATTRIBUTE
-# if (defined __GNUC__ \
- && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
- || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
-# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
-# else
-# define YY_ATTRIBUTE(Spec) /* empty */
-# endif
-#endif
-
-#ifndef YY_ATTRIBUTE_PURE
-# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
-#endif
-
-#ifndef YY_ATTRIBUTE_UNUSED
-# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
-#endif
-
-#if !defined _Noreturn \
- && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
-# if defined _MSC_VER && 1200 <= _MSC_VER
-# define _Noreturn __declspec (noreturn)
-# else
-# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
-# endif
-#endif
-
-/* Suppress unused-variable warnings by "using" E. */
-#if ! defined lint || defined __GNUC__
-# define YYUSE(E) ((void) (E))
-#else
-# define YYUSE(E) /* empty */
-#endif
-
-#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
-/* Suppress an incorrect diagnostic about yylval being uninitialized. */
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
- _Pragma ("GCC diagnostic push") \
- _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
- _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
-# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
- _Pragma ("GCC diagnostic pop")
-#else
-# define YY_INITIAL_VALUE(Value) Value
-#endif
-#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
-# define YY_IGNORE_MAYBE_UNINITIALIZED_END
-#endif
-#ifndef YY_INITIAL_VALUE
-# define YY_INITIAL_VALUE(Value) /* Nothing. */
-#endif
-
-
-#if ! defined yyoverflow || YYERROR_VERBOSE
-
-/* The parser invokes alloca or malloc; define the necessary symbols. */
-
-# ifdef YYSTACK_USE_ALLOCA
-# if YYSTACK_USE_ALLOCA
-# ifdef __GNUC__
-# define YYSTACK_ALLOC __builtin_alloca
-# elif defined __BUILTIN_VA_ARG_INCR
-# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
-# elif defined _AIX
-# define YYSTACK_ALLOC __alloca
-# elif defined _MSC_VER
-# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
-# define alloca _alloca
-# else
-# define YYSTACK_ALLOC alloca
-# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
- /* Use EXIT_SUCCESS as a witness for stdlib.h. */
-# ifndef EXIT_SUCCESS
-# define EXIT_SUCCESS 0
-# endif
-# endif
-# endif
-# endif
-# endif
-
-# ifdef YYSTACK_ALLOC
- /* Pacify GCC's 'empty if-body' warning. */
-# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
-# ifndef YYSTACK_ALLOC_MAXIMUM
- /* The OS might guarantee only one guard page at the bottom of the stack,
- and a page size can be as small as 4096 bytes. So we cannot safely
- invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
- to allow for a few compiler-allocated temporary stack slots. */
-# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
-# endif
-# else
-# define YYSTACK_ALLOC YYMALLOC
-# define YYSTACK_FREE YYFREE
-# ifndef YYSTACK_ALLOC_MAXIMUM
-# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
-# endif
-# if (defined __cplusplus && ! defined EXIT_SUCCESS \
- && ! ((defined YYMALLOC || defined malloc) \
- && (defined YYFREE || defined free)))
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef EXIT_SUCCESS
-# define EXIT_SUCCESS 0
-# endif
-# endif
-# ifndef YYMALLOC
-# define YYMALLOC malloc
-# if ! defined malloc && ! defined EXIT_SUCCESS
-void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# ifndef YYFREE
-# define YYFREE free
-# if ! defined free && ! defined EXIT_SUCCESS
-void free (void *); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# endif
-#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
-
-
-#if (! defined yyoverflow \
- && (! defined __cplusplus \
- || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
-
-/* A type that is properly aligned for any stack member. */
-union yyalloc
-{
- yytype_int16 yyss_alloc;
- YYSTYPE yyvs_alloc;
-};
-
-/* The size of the maximum gap between one aligned stack and the next. */
-# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
-
-/* The size of an array large to enough to hold all stacks, each with
- N elements. */
-# define YYSTACK_BYTES(N) \
- ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
- + YYSTACK_GAP_MAXIMUM)
-
-# define YYCOPY_NEEDED 1
-
-/* Relocate STACK from its old location to the new one. The
- local variables YYSIZE and YYSTACKSIZE give the old and new number of
- elements in the stack, and YYPTR gives the new location of the
- stack. Advance YYPTR to a properly aligned location for the next
- stack. */
-# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
- do \
- { \
- YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
- Stack = &yyptr->Stack_alloc; \
- yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
- yyptr += yynewbytes / sizeof (*yyptr); \
- } \
- while (0)
-
-#endif
-
-#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
-/* Copy COUNT objects from SRC to DST. The source and destination do
- not overlap. */
-# ifndef YYCOPY
-# if defined __GNUC__ && 1 < __GNUC__
-# define YYCOPY(Dst, Src, Count) \
- __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
-# else
-# define YYCOPY(Dst, Src, Count) \
- do \
- { \
- YYSIZE_T yyi; \
- for (yyi = 0; yyi < (Count); yyi++) \
- (Dst)[yyi] = (Src)[yyi]; \
- } \
- while (0)
-# endif
-# endif
-#endif /* !YYCOPY_NEEDED */
-
-/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 17
-/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 25
-
-/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 14
-/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 6
-/* YYNRULES -- Number of rules. */
-#define YYNRULES 17
-/* YYNSTATES -- Number of states. */
-#define YYNSTATES 20
-
-/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
- by yylex, with out-of-bounds checking. */
-#define YYUNDEFTOK 2
-#define YYMAXUTOK 266
-
-#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
-
-/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
- as returned by yylex, without out-of-bounds checking. */
-static const yytype_uint8 yytranslate[] =
-{
- 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 12, 2, 13, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
- 5, 6, 7, 8, 9, 10, 11
-};
-
-#if YYDEBUG
- /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
-static const yytype_uint8 yyrline[] =
-{
- 0, 25, 25, 26, 58, 59, 61, 62, 64, 65,
- 66, 67, 68, 69, 70, 71, 72, 74
-};
-#endif
-
-#if YYDEBUG || YYERROR_VERBOSE || 0
-/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
- First, the terminals, then, starting at YYNTOKENS, nonterminals. */
-static const char *const yytname[] =
-{
- "$end", "error", "$undefined", "KEYWORD", "STRING", "NUMBER",
- "IDENTIFIER", "OPERATOR", "OTHER", "NEWLINE", "DECORATOR", "COMMENT",
- "'{'", "'}'", "$accept", "input", "program", "expr", "nonblock", "block", YY_NULLPTR
-};
-#endif
-
-# ifdef YYPRINT
-/* YYTOKNUM[NUM] -- (External) token number corresponding to the
- (internal) symbol number NUM (which must be that of a token). */
-static const yytype_uint16 yytoknum[] =
-{
- 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
- 265, 266, 123, 125
-};
-# endif
-
-#define YYPACT_NINF -4
-
-#define yypact_value_is_default(Yystate) \
- (!!((Yystate) == (-4)))
-
-#define YYTABLE_NINF -1
-
-#define yytable_value_is_error(Yytable_value) \
- 0
-
- /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
- STATE-NUM. */
-static const yytype_int8 yypact[] =
-{
- 8, -4, -4, -4, -4, -4, -4, -4, -4, -4,
- 8, 22, 8, -4, -4, -4, -3, -4, -4, -4
-};
-
- /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
- Performed when YYTABLE does not specify something else to do. Zero
- means the default is an error. */
-static const yytype_uint8 yydefact[] =
-{
- 2, 8, 9, 10, 11, 12, 16, 13, 15, 14,
- 0, 0, 3, 4, 7, 6, 0, 1, 5, 17
-};
-
- /* YYPGOTO[NTERM-NUM]. */
-static const yytype_int8 yypgoto[] =
-{
- -4, -4, 13, 9, -4, -4
-};
-
- /* YYDEFGOTO[NTERM-NUM]. */
-static const yytype_int8 yydefgoto[] =
-{
- -1, 11, 12, 13, 14, 15
-};
-
- /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
- positive, shift that token. If negative, reduce the rule whose
- number is the opposite. If YYTABLE_NINF, syntax error. */
-static const yytype_uint8 yytable[] =
-{
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
- 19, 1, 2, 3, 4, 5, 6, 7, 8, 9,
- 10, 18, 17, 16, 0, 18
-};
-
-static const yytype_int8 yycheck[] =
-{
- 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
- 13, 3, 4, 5, 6, 7, 8, 9, 10, 11,
- 12, 12, 0, 10, -1, 16
-};
-
- /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
- symbol of state STATE-NUM. */
-static const yytype_uint8 yystos[] =
-{
- 0, 3, 4, 5, 6, 7, 8, 9, 10, 11,
- 12, 15, 16, 17, 18, 19, 16, 0, 17, 13
-};
-
- /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
-static const yytype_uint8 yyr1[] =
-{
- 0, 14, 15, 15, 16, 16, 17, 17, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 19
-};
-
- /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
-static const yytype_uint8 yyr2[] =
-{
- 0, 2, 0, 1, 1, 2, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 3
-};
-
-
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY (-2)
-#define YYEOF 0
-
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrorlab
-
-
-#define YYRECOVERING() (!!yyerrstatus)
-
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- YYPOPSTACK (yylen); \
- yystate = *yyssp; \
- goto yybackup; \
- } \
- else \
- { \
- yyerror (YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (0)
-
-/* Error token number */
-#define YYTERROR 1
-#define YYERRCODE 256
-
-
-
-/* Enable debugging if requested. */
-#if YYDEBUG
-
-# ifndef YYFPRINTF
-# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
-# define YYFPRINTF fprintf
-# endif
-
-# define YYDPRINTF(Args) \
-do { \
- if (yydebug) \
- YYFPRINTF Args; \
-} while (0)
-
-/* This macro is provided for backward compatibility. */
-#ifndef YY_LOCATION_PRINT
-# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
-#endif
-
-
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
-do { \
- if (yydebug) \
- { \
- YYFPRINTF (stderr, "%s ", Title); \
- yy_symbol_print (stderr, \
- Type, Value); \
- YYFPRINTF (stderr, "\n"); \
- } \
-} while (0)
-
-
-/*----------------------------------------.
-| Print this symbol's value on YYOUTPUT. |
-`----------------------------------------*/
-
-static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-{
- FILE *yyo = yyoutput;
- YYUSE (yyo);
- if (!yyvaluep)
- return;
-# ifdef YYPRINT
- if (yytype < YYNTOKENS)
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# endif
- YYUSE (yytype);
-}
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-{
- YYFPRINTF (yyoutput, "%s %s (",
- yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
-
- yy_symbol_value_print (yyoutput, yytype, yyvaluep);
- YYFPRINTF (yyoutput, ")");
-}
-
-/*------------------------------------------------------------------.
-| yy_stack_print -- Print the state stack from its BOTTOM up to its |
-| TOP (included). |
-`------------------------------------------------------------------*/
-
-static void
-yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
-{
- YYFPRINTF (stderr, "Stack now");
- for (; yybottom <= yytop; yybottom++)
- {
- int yybot = *yybottom;
- YYFPRINTF (stderr, " %d", yybot);
- }
- YYFPRINTF (stderr, "\n");
-}
-
-# define YY_STACK_PRINT(Bottom, Top) \
-do { \
- if (yydebug) \
- yy_stack_print ((Bottom), (Top)); \
-} while (0)
-
-
-/*------------------------------------------------.
-| Report that the YYRULE is going to be reduced. |
-`------------------------------------------------*/
-
-static void
-yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
-{
- unsigned long int yylno = yyrline[yyrule];
- int yynrhs = yyr2[yyrule];
- int yyi;
- YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
- yyrule - 1, yylno);
- /* The symbols being reduced. */
- for (yyi = 0; yyi < yynrhs; yyi++)
- {
- YYFPRINTF (stderr, " $%d = ", yyi + 1);
- yy_symbol_print (stderr,
- yystos[yyssp[yyi + 1 - yynrhs]],
- &(yyvsp[(yyi + 1) - (yynrhs)])
- );
- YYFPRINTF (stderr, "\n");
- }
-}
-
-# define YY_REDUCE_PRINT(Rule) \
-do { \
- if (yydebug) \
- yy_reduce_print (yyssp, yyvsp, Rule); \
-} while (0)
-
-/* Nonzero means print parse trace. It is left uninitialized so that
- multiple parsers can coexist. */
-int yydebug;
-#else /* !YYDEBUG */
-# define YYDPRINTF(Args)
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
-# define YY_STACK_PRINT(Bottom, Top)
-# define YY_REDUCE_PRINT(Rule)
-#endif /* !YYDEBUG */
-
-
-/* YYINITDEPTH -- initial size of the parser's stacks. */
-#ifndef YYINITDEPTH
-# define YYINITDEPTH 200
-#endif
-
-/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
- if the built-in stack extension method is used).
-
- Do not make this value too large; the results are undefined if
- YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
- evaluated with infinite-precision integer arithmetic. */
-
-#ifndef YYMAXDEPTH
-# define YYMAXDEPTH 10000
-#endif
-
-
-#if YYERROR_VERBOSE
-
-# ifndef yystrlen
-# if defined __GLIBC__ && defined _STRING_H
-# define yystrlen strlen
-# else
-/* Return the length of YYSTR. */
-static YYSIZE_T
-yystrlen (const char *yystr)
-{
- YYSIZE_T yylen;
- for (yylen = 0; yystr[yylen]; yylen++)
- continue;
- return yylen;
-}
-# endif
-# endif
-
-# ifndef yystpcpy
-# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
-# define yystpcpy stpcpy
-# else
-/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
- YYDEST. */
-static char *
-yystpcpy (char *yydest, const char *yysrc)
-{
- char *yyd = yydest;
- const char *yys = yysrc;
-
- while ((*yyd++ = *yys++) != '\0')
- continue;
-
- return yyd - 1;
-}
-# endif
-# endif
-
-# ifndef yytnamerr
-/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
- quotes and backslashes, so that it's suitable for yyerror. The
- heuristic is that double-quoting is unnecessary unless the string
- contains an apostrophe, a comma, or backslash (other than
- backslash-backslash). YYSTR is taken from yytname. If YYRES is
- null, do not copy; instead, return the length of what the result
- would have been. */
-static YYSIZE_T
-yytnamerr (char *yyres, const char *yystr)
-{
- if (*yystr == '"')
- {
- YYSIZE_T yyn = 0;
- char const *yyp = yystr;
-
- for (;;)
- switch (*++yyp)
- {
- case '\'':
- case ',':
- goto do_not_strip_quotes;
-
- case '\\':
- if (*++yyp != '\\')
- goto do_not_strip_quotes;
- /* Fall through. */
- default:
- if (yyres)
- yyres[yyn] = *yyp;
- yyn++;
- break;
-
- case '"':
- if (yyres)
- yyres[yyn] = '\0';
- return yyn;
- }
- do_not_strip_quotes: ;
- }
-
- if (! yyres)
- return yystrlen (yystr);
-
- return yystpcpy (yyres, yystr) - yyres;
-}
-# endif
-
-/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
- about the unexpected token YYTOKEN for the state stack whose top is
- YYSSP.
-
- Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
- not large enough to hold the message. In that case, also set
- *YYMSG_ALLOC to the required number of bytes. Return 2 if the
- required number of bytes is too large to store. */
-static int
-yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
- yytype_int16 *yyssp, int yytoken)
-{
- YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
- YYSIZE_T yysize = yysize0;
- enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
- /* Internationalized format string. */
- const char *yyformat = YY_NULLPTR;
- /* Arguments of yyformat. */
- char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
- /* Number of reported tokens (one for the "unexpected", one per
- "expected"). */
- int yycount = 0;
-
- /* There are many possibilities here to consider:
- - If this state is a consistent state with a default action, then
- the only way this function was invoked is if the default action
- is an error action. In that case, don't check for expected
- tokens because there are none.
- - The only way there can be no lookahead present (in yychar) is if
- this state is a consistent state with a default action. Thus,
- detecting the absence of a lookahead is sufficient to determine
- that there is no unexpected or expected token to report. In that
- case, just report a simple "syntax error".
- - Don't assume there isn't a lookahead just because this state is a
- consistent state with a default action. There might have been a
- previous inconsistent state, consistent state with a non-default
- action, or user semantic action that manipulated yychar.
- - Of course, the expected token list depends on states to have
- correct lookahead information, and it depends on the parser not
- to perform extra reductions after fetching a lookahead from the
- scanner and before detecting a syntax error. Thus, state merging
- (from LALR or IELR) and default reductions corrupt the expected
- token list. However, the list is correct for canonical LR with
- one exception: it will still contain any token that will not be
- accepted due to an error action in a later state.
- */
- if (yytoken != YYEMPTY)
- {
- int yyn = yypact[*yyssp];
- yyarg[yycount++] = yytname[yytoken];
- if (!yypact_value_is_default (yyn))
- {
- /* Start YYX at -YYN if negative to avoid negative indexes in
- YYCHECK. In other words, skip the first -YYN actions for
- this state because they are default actions. */
- int yyxbegin = yyn < 0 ? -yyn : 0;
- /* Stay within bounds of both yycheck and yytname. */
- int yychecklim = YYLAST - yyn + 1;
- int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
- int yyx;
-
- for (yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
- && !yytable_value_is_error (yytable[yyx + yyn]))
- {
- if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
- {
- yycount = 1;
- yysize = yysize0;
- break;
- }
- yyarg[yycount++] = yytname[yyx];
- {
- YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
- if (! (yysize <= yysize1
- && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
- return 2;
- yysize = yysize1;
- }
- }
- }
- }
-
- switch (yycount)
- {
-# define YYCASE_(N, S) \
- case N: \
- yyformat = S; \
- break
- YYCASE_(0, YY_("syntax error"));
- YYCASE_(1, YY_("syntax error, unexpected %s"));
- YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
- YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
- YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
- YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
-# undef YYCASE_
- }
-
- {
- YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
- if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
- return 2;
- yysize = yysize1;
- }
-
- if (*yymsg_alloc < yysize)
- {
- *yymsg_alloc = 2 * yysize;
- if (! (yysize <= *yymsg_alloc
- && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
- *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
- return 1;
- }
-
- /* Avoid sprintf, as that infringes on the user's name space.
- Don't have undefined behavior even if the translation
- produced a string with the wrong number of "%s"s. */
- {
- char *yyp = *yymsg;
- int yyi = 0;
- while ((*yyp = *yyformat) != '\0')
- if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
- {
- yyp += yytnamerr (yyp, yyarg[yyi++]);
- yyformat += 2;
- }
- else
- {
- yyp++;
- yyformat++;
- }
- }
- return 0;
-}
-#endif /* YYERROR_VERBOSE */
-
-/*-----------------------------------------------.
-| Release the memory associated to this symbol. |
-`-----------------------------------------------*/
-
-static void
-yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
-{
- YYUSE (yyvaluep);
- if (!yymsg)
- yymsg = "Deleting";
- YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
-
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
- YYUSE (yytype);
- YY_IGNORE_MAYBE_UNINITIALIZED_END
-}
-
-
-
-
-/* The lookahead symbol. */
-int yychar;
-
-/* The semantic value of the lookahead symbol. */
-YYSTYPE yylval;
-/* Number of syntax errors so far. */
-int yynerrs;
-
-
-/*----------.
-| yyparse. |
-`----------*/
-
-int
-yyparse (void)
-{
- int yystate;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
-
- /* The stacks and their tools:
- 'yyss': related to states.
- 'yyvs': related to semantic values.
-
- Refer to the stacks through separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
-
- /* The state stack. */
- yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyss;
- yytype_int16 *yyssp;
-
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs;
- YYSTYPE *yyvsp;
-
- YYSIZE_T yystacksize;
-
- int yyn;
- int yyresult;
- /* Lookahead token as an internal (translated) token number. */
- int yytoken = 0;
- /* The variables used to return semantic value and location from the
- action routines. */
- YYSTYPE yyval;
-
-#if YYERROR_VERBOSE
- /* Buffer for error messages, and its allocated size. */
- char yymsgbuf[128];
- char *yymsg = yymsgbuf;
- YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
-#endif
-
-#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
-
- /* The number of symbols on the RHS of the reduced rule.
- Keep to zero when no symbol should be popped. */
- int yylen = 0;
-
- yyssp = yyss = yyssa;
- yyvsp = yyvs = yyvsa;
- yystacksize = YYINITDEPTH;
-
- YYDPRINTF ((stderr, "Starting parse\n"));
-
- yystate = 0;
- yyerrstatus = 0;
- yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
- goto yysetstate;
-
-/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
-`------------------------------------------------------------*/
- yynewstate:
- /* In all cases, when you get here, the value and location stacks
- have just been pushed. So pushing a state here evens the stacks. */
- yyssp++;
-
- yysetstate:
- *yyssp = yystate;
-
- if (yyss + yystacksize - 1 <= yyssp)
- {
- /* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
-
-#ifdef yyoverflow
- {
- /* Give user a chance to reallocate the stack. Use copies of
- these so that the &'s don't force the real ones into
- memory. */
- YYSTYPE *yyvs1 = yyvs;
- yytype_int16 *yyss1 = yyss;
-
- /* Each stack pointer address is followed by the size of the
- data in use in that stack, in bytes. This used to be a
- conditional around just the two extra args, but that might
- be undefined if yyoverflow is a macro. */
- yyoverflow (YY_("memory exhausted"),
- &yyss1, yysize * sizeof (*yyssp),
- &yyvs1, yysize * sizeof (*yyvsp),
- &yystacksize);
-
- yyss = yyss1;
- yyvs = yyvs1;
- }
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyexhaustedlab;
-# else
- /* Extend the stack our own way. */
- if (YYMAXDEPTH <= yystacksize)
- goto yyexhaustedlab;
- yystacksize *= 2;
- if (YYMAXDEPTH < yystacksize)
- yystacksize = YYMAXDEPTH;
-
- {
- yytype_int16 *yyss1 = yyss;
- union yyalloc *yyptr =
- (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
- if (! yyptr)
- goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss_alloc, yyss);
- YYSTACK_RELOCATE (yyvs_alloc, yyvs);
-# undef YYSTACK_RELOCATE
- if (yyss1 != yyssa)
- YYSTACK_FREE (yyss1);
- }
-# endif
-#endif /* no yyoverflow */
-
- yyssp = yyss + yysize - 1;
- yyvsp = yyvs + yysize - 1;
-
- YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
-
- if (yyss + yystacksize - 1 <= yyssp)
- YYABORT;
- }
-
- YYDPRINTF ((stderr, "Entering state %d\n", yystate));
-
- if (yystate == YYFINAL)
- YYACCEPT;
-
- goto yybackup;
-
-/*-----------.
-| yybackup. |
-`-----------*/
-yybackup:
-
- /* Do appropriate processing given the current state. Read a
- lookahead token if we need one and don't already have one. */
-
- /* First try to decide what to do without reference to lookahead token. */
- yyn = yypact[yystate];
- if (yypact_value_is_default (yyn))
- goto yydefault;
-
- /* Not known => get a lookahead token if don't already have one. */
-
- /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
- if (yychar == YYEMPTY)
- {
- YYDPRINTF ((stderr, "Reading a token: "));
- yychar = yylex ();
- }
-
- if (yychar <= YYEOF)
- {
- yychar = yytoken = YYEOF;
- YYDPRINTF ((stderr, "Now at end of input.\n"));
- }
- else
- {
- yytoken = YYTRANSLATE (yychar);
- YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
- }
-
- /* If the proper action on seeing token YYTOKEN is to reduce or to
- detect an error, take that action. */
- yyn += yytoken;
- if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
- goto yydefault;
- yyn = yytable[yyn];
- if (yyn <= 0)
- {
- if (yytable_value_is_error (yyn))
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
- }
-
- /* Count tokens shifted since error; after three, turn off error
- status. */
- if (yyerrstatus)
- yyerrstatus--;
-
- /* Shift the lookahead token. */
- YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
-
- /* Discard the shifted token. */
- yychar = YYEMPTY;
-
- yystate = yyn;
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
- *++yyvsp = yylval;
- YY_IGNORE_MAYBE_UNINITIALIZED_END
-
- goto yynewstate;
-
-
-/*-----------------------------------------------------------.
-| yydefault -- do the default action for the current state. |
-`-----------------------------------------------------------*/
-yydefault:
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
- goto yyreduce;
-
-
-/*-----------------------------.
-| yyreduce -- Do a reduction. |
-`-----------------------------*/
-yyreduce:
- /* yyn is the number of a rule to reduce with. */
- yylen = yyr2[yyn];
-
- /* If YYLEN is nonzero, implement the default value of the action:
- '$$ = $1'.
-
- Otherwise, the following line sets YYVAL to garbage.
- This behavior is undocumented and Bison
- users should not rely upon it. Assigning to YYVAL
- unconditionally makes the parser a bit smaller, and it avoids a
- GCC warning that YYVAL may be used uninitialized. */
- yyval = yyvsp[1-yylen];
-
-
- YY_REDUCE_PRINT (yyn);
- switch (yyn)
- {
- case 3:
-#line 26 "parser.y" /* yacc.c:1646 */
- { std::cout << "<html><head><style> \
- .keyword {color:blue;} \
- .operator {color:#0e7c31; font-weight: bold} \
- .number {color:#d119b2;} .string {color:red;} \
- .block {display: inline; overflow: hidden;} \
- .collapsible { background: none; border: 1px black solid;} \
- .comment {color:grey; font-style: italic;} \
- .line_number {opacity: 0.5;} \
- .decorator {color:#1a1f63; font-style: italic;} \
- </style> \
- </head><body><pre><span class=\"line_number\">1. </span>" << (yyvsp[0]) << "</pre><script> \
- var block = document.getElementsByClassName(\"block\"); \
- var j; \
- for (j = 0; j < block.length; j++) { \
- block[j].style.display = \"inline\"; \
- } \
- var coll = document.getElementsByClassName(\"collapsible\"); \
- var i; \
- for (i = 0; i < coll.length; i++) { \
- coll[i].addEventListener(\"click\", function() { \
- var content = this.nextElementSibling; \
- if (content.style.display === \"inline\"){ \
- content.style.display = \"none\"; \
- this.innerHTML = \"+\"; \
- } else { \
- content.style.display = \"inline\"; \
- this.innerHTML = \"-\"; \
- } \
- }); \
- } \
- </script></body></html>"; }
-#line 1249 "parser.tab.c" /* yacc.c:1646 */
- break;
-
- case 5:
-#line 59 "parser.y" /* yacc.c:1646 */
- {(yyval) = (yyvsp[-1]) + (yyvsp[0]);}
-#line 1255 "parser.tab.c" /* yacc.c:1646 */
- break;
-
- case 8:
-#line 64 "parser.y" /* yacc.c:1646 */
- { (yyval) = "<span class=\"keyword\">" + (yyvsp[0]) + "</span>"; }
-#line 1261 "parser.tab.c" /* yacc.c:1646 */
- break;
-
- case 9:
-#line 65 "parser.y" /* yacc.c:1646 */
- { (yyval) = "<span class=\"string\">" + (yyvsp[0]) + "</span>"; }
-#line 1267 "parser.tab.c" /* yacc.c:1646 */
- break;
-
- case 10:
-#line 66 "parser.y" /* yacc.c:1646 */
- { (yyval) = "<span class=\"number\">" + (yyvsp[0]) + "</span>"; }
-#line 1273 "parser.tab.c" /* yacc.c:1646 */
- break;
-
- case 11:
-#line 67 "parser.y" /* yacc.c:1646 */
- { (yyval) = "<span class=\"identifier\">" + (yyvsp[0]) + "</span>"; }
-#line 1279 "parser.tab.c" /* yacc.c:1646 */
- break;
-
- case 12:
-#line 68 "parser.y" /* yacc.c:1646 */
- { (yyval) = "<span class=\"operator\">" + (yyvsp[0]) + "</span>"; }
-#line 1285 "parser.tab.c" /* yacc.c:1646 */
- break;
-
- case 13:
-#line 69 "parser.y" /* yacc.c:1646 */
- { (yyval) = (yyvsp[0]) + "<span class=\"line_number\">" + std::to_string(++current_line) + ". </span>";}
-#line 1291 "parser.tab.c" /* yacc.c:1646 */
- break;
-
- case 14:
-#line 70 "parser.y" /* yacc.c:1646 */
- { (yyval) = "<span class=\"comment\">" + (yyvsp[0]) + "</span>"; }
-#line 1297 "parser.tab.c" /* yacc.c:1646 */
- break;
-
- case 15:
-#line 71 "parser.y" /* yacc.c:1646 */
- { (yyval) = "<span class=\"decorator\">" + (yyvsp[0]) + "</span>"; }
-#line 1303 "parser.tab.c" /* yacc.c:1646 */
- break;
-
- case 17:
-#line 74 "parser.y" /* yacc.c:1646 */
- {(yyval) = "{" + std::string("<button class=\"collapsible\">-</button><div class=\"block\">") + (yyvsp[-1]) + "</div>}";}
-#line 1309 "parser.tab.c" /* yacc.c:1646 */
- break;
-
-
-#line 1313 "parser.tab.c" /* yacc.c:1646 */
- default: break;
- }
- /* User semantic actions sometimes alter yychar, and that requires
- that yytoken be updated with the new translation. We take the
- approach of translating immediately before every use of yytoken.
- One alternative is translating here after every semantic action,
- but that translation would be missed if the semantic action invokes
- YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
- if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
- incorrect destructor might then be invoked immediately. In the
- case of YYERROR or YYBACKUP, subsequent parser actions might lead
- to an incorrect destructor call or verbose syntax error message
- before the lookahead is translated. */
- YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
-
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
-
- *++yyvsp = yyval;
-
- /* Now 'shift' the result of the reduction. Determine what state
- that goes to, based on the state we popped back to and the rule
- number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
-
- goto yynewstate;
-
-
-/*--------------------------------------.
-| yyerrlab -- here on detecting error. |
-`--------------------------------------*/
-yyerrlab:
- /* Make sure we have latest lookahead translation. See comments at
- user semantic actions for why this is necessary. */
- yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
-
- /* If not already recovering from an error, report this error. */
- if (!yyerrstatus)
- {
- ++yynerrs;
-#if ! YYERROR_VERBOSE
- yyerror (YY_("syntax error"));
-#else
-# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
- yyssp, yytoken)
- {
- char const *yymsgp = YY_("syntax error");
- int yysyntax_error_status;
- yysyntax_error_status = YYSYNTAX_ERROR;
- if (yysyntax_error_status == 0)
- yymsgp = yymsg;
- else if (yysyntax_error_status == 1)
- {
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
- yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
- if (!yymsg)
- {
- yymsg = yymsgbuf;
- yymsg_alloc = sizeof yymsgbuf;
- yysyntax_error_status = 2;
- }
- else
- {
- yysyntax_error_status = YYSYNTAX_ERROR;
- yymsgp = yymsg;
- }
- }
- yyerror (yymsgp);
- if (yysyntax_error_status == 2)
- goto yyexhaustedlab;
- }
-# undef YYSYNTAX_ERROR
-#endif
- }
-
-
-
- if (yyerrstatus == 3)
- {
- /* If just tried and failed to reuse lookahead token after an
- error, discard it. */
-
- if (yychar <= YYEOF)
- {
- /* Return failure if at end of input. */
- if (yychar == YYEOF)
- YYABORT;
- }
- else
- {
- yydestruct ("Error: discarding",
- yytoken, &yylval);
- yychar = YYEMPTY;
- }
- }
-
- /* Else will try to reuse lookahead token after shifting the error
- token. */
- goto yyerrlab1;
-
-
-/*---------------------------------------------------.
-| yyerrorlab -- error raised explicitly by YYERROR. |
-`---------------------------------------------------*/
-yyerrorlab:
-
- /* Pacify compilers like GCC when the user code never invokes
- YYERROR and the label yyerrorlab therefore never appears in user
- code. */
- if (/*CONSTCOND*/ 0)
- goto yyerrorlab;
-
- /* Do not reclaim the symbols of the rule whose action triggered
- this YYERROR. */
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
- yystate = *yyssp;
- goto yyerrlab1;
-
-
-/*-------------------------------------------------------------.
-| yyerrlab1 -- common code for both syntax error and YYERROR. |
-`-------------------------------------------------------------*/
-yyerrlab1:
- yyerrstatus = 3; /* Each real token shifted decrements this. */
-
- for (;;)
- {
- yyn = yypact[yystate];
- if (!yypact_value_is_default (yyn))
- {
- yyn += YYTERROR;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
- {
- yyn = yytable[yyn];
- if (0 < yyn)
- break;
- }
- }
-
- /* Pop the current state because it cannot handle the error token. */
- if (yyssp == yyss)
- YYABORT;
-
-
- yydestruct ("Error: popping",
- yystos[yystate], yyvsp);
- YYPOPSTACK (1);
- yystate = *yyssp;
- YY_STACK_PRINT (yyss, yyssp);
- }
-
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
- *++yyvsp = yylval;
- YY_IGNORE_MAYBE_UNINITIALIZED_END
-
-
- /* Shift the error token. */
- YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
-
- yystate = yyn;
- goto yynewstate;
-
-
-/*-------------------------------------.
-| yyacceptlab -- YYACCEPT comes here. |
-`-------------------------------------*/
-yyacceptlab:
- yyresult = 0;
- goto yyreturn;
-
-/*-----------------------------------.
-| yyabortlab -- YYABORT comes here. |
-`-----------------------------------*/
-yyabortlab:
- yyresult = 1;
- goto yyreturn;
-
-#if !defined yyoverflow || YYERROR_VERBOSE
-/*-------------------------------------------------.
-| yyexhaustedlab -- memory exhaustion comes here. |
-`-------------------------------------------------*/
-yyexhaustedlab:
- yyerror (YY_("memory exhausted"));
- yyresult = 2;
- /* Fall through. */
-#endif
-
-yyreturn:
- if (yychar != YYEMPTY)
- {
- /* Make sure we have latest lookahead translation. See comments at
- user semantic actions for why this is necessary. */
- yytoken = YYTRANSLATE (yychar);
- yydestruct ("Cleanup: discarding lookahead",
- yytoken, &yylval);
- }
- /* Do not reclaim the symbols of the rule whose action triggered
- this YYABORT or YYACCEPT. */
- YYPOPSTACK (yylen);
- YY_STACK_PRINT (yyss, yyssp);
- while (yyssp != yyss)
- {
- yydestruct ("Cleanup: popping",
- yystos[*yyssp], yyvsp);
- YYPOPSTACK (1);
- }
-#ifndef yyoverflow
- if (yyss != yyssa)
- YYSTACK_FREE (yyss);
-#endif
-#if YYERROR_VERBOSE
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
-#endif
- return yyresult;
-}
-#line 76 "parser.y" /* yacc.c:1906 */
-
-int yyerror(const char* error)
-{
- std::cerr << "error:\n" << error;
- return 0;
-}
-int main()
-{
- yyparse();
- return 0;
-}
diff --git a/homework/81352/ts2html-hw2/parser.tab.h b/homework/81352/ts2html-hw2/parser.tab.h
deleted file mode 100644
index 24b5cc0..0000000
--- a/homework/81352/ts2html-hw2/parser.tab.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* A Bison parser, made by GNU Bison 3.0.4. */
-
-/* Bison interface for Yacc-like parsers in C
-
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-#ifndef YY_YY_PARSER_TAB_H_INCLUDED
-# define YY_YY_PARSER_TAB_H_INCLUDED
-/* Debug traces. */
-#ifndef YYDEBUG
-# define YYDEBUG 0
-#endif
-#if YYDEBUG
-extern int yydebug;
-#endif
-/* "%code requires" blocks. */
-#line 8 "parser.y" /* yacc.c:1909 */
-#include <string>
-
-#line 47 "parser.tab.h" /* yacc.c:1909 */
-
-/* Token type. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- enum yytokentype
- {
- KEYWORD = 258,
- STRING = 259,
- NUMBER = 260,
- IDENTIFIER = 261,
- OPERATOR = 262,
- OTHER = 263,
- NEWLINE = 264,
- DECORATOR = 265,
- COMMENT = 266
- };
-#endif
-
-/* Value type. */
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef std::string YYSTYPE;
-# define YYSTYPE_IS_TRIVIAL 1
-# define YYSTYPE_IS_DECLARED 1
-#endif
-
-
-extern YYSTYPE yylval;
-
-int yyparse (void);
-
-#endif /* !YY_YY_PARSER_TAB_H_INCLUDED */
diff --git a/homework/81352/ts2html-hw2/parser.y b/homework/81352/ts2html-hw2/parser.y
deleted file mode 100644
index 53a56c4..0000000
--- a/homework/81352/ts2html-hw2/parser.y
+++ /dev/null
@@ -1,86 +0,0 @@
-%{
-#include <iostream>
-int yylex();
-int yyerror(const char* error);
-int current_line = 1;
-%}
-
-%code requires {#include <string>}
-%start input
-%define api.value.type {std::string}
-
-%token KEYWORD
-%token STRING
-%token NUMBER
-%token IDENTIFIER
-%token OPERATOR
-%token OTHER
-%token NEWLINE
-%token DECORATOR
-%token COMMENT
-
-
-%%
-
-input: %empty
- | program { std::cout << "<html><head><style> \
- .keyword {color:blue;} \
- .operator {color:#0e7c31; font-weight: bold} \
- .number {color:#d119b2;} .string {color:red;} \
- .block {display: inline; overflow: hidden;} \
- .collapsible { background: none; border: 1px black solid;} \
- .comment {color:grey; font-style: italic;} \
- .line_number {opacity: 0.5;} \
- .decorator {color:#1a1f63; font-style: italic;} \
- </style> \
- </head><body><pre><span class=\"line_number\">1. </span>" << $1 << "</pre><script> \
- var block = document.getElementsByClassName(\"block\"); \
- var j; \
- for (j = 0; j < block.length; j++) { \
- block[j].style.display = \"inline\"; \
- } \
- var coll = document.getElementsByClassName(\"collapsible\"); \
- var i; \
- for (i = 0; i < coll.length; i++) { \
- coll[i].addEventListener(\"click\", function() { \
- var content = this.nextElementSibling; \
- if (content.style.display === \"inline\"){ \
- content.style.display = \"none\"; \
- this.innerHTML = \"+\"; \
- } else { \
- content.style.display = \"inline\"; \
- this.innerHTML = \"-\"; \
- } \
- }); \
- } \
- </script></body></html>"; }
-
-program: expr
- | program expr {$$ = $1 + $2;}
-
-expr: block
- | nonblock
-
-nonblock: KEYWORD { $$ = "<span class=\"keyword\">" + $1 + "</span>"; }
- | STRING { $$ = "<span class=\"string\">" + $1 + "</span>"; }
- | NUMBER { $$ = "<span class=\"number\">" + $1 + "</span>"; }
- | IDENTIFIER { $$ = "<span class=\"identifier\">" + $1 + "</span>"; }
- | OPERATOR { $$ = "<span class=\"operator\">" + $1 + "</span>"; }
- | NEWLINE { $$ = $1 + "<span class=\"line_number\">" + std::to_string(++current_line) + ". </span>";}
- | COMMENT { $$ = "<span class=\"comment\">" + $1 + "</span>"; }
- | DECORATOR { $$ = "<span class=\"decorator\">" + $1 + "</span>"; }
- | OTHER
-
-block: '{' program '}' {$$ = "{" + std::string("<button class=\"collapsible\">-</button><div class=\"block\">") + $2 + "</div>}";}
-
-%%
-int yyerror(const char* error)
-{
- std::cerr << "error:\n" << error;
- return 0;
-}
-int main()
-{
- yyparse();
- return 0;
-}
diff --git a/homework/81352/ts2html-hw2/ts2html.flex b/homework/81352/ts2html-hw2/ts2html.flex
deleted file mode 100644
index 4b2ef00..0000000
--- a/homework/81352/ts2html-hw2/ts2html.flex
+++ /dev/null
@@ -1,71 +0,0 @@
-%{
-#include "parser.tab.h"
-%}
-
-DIGIT [0-9]
-NUMBER [1-9]{DIGIT}*
-FNUMBER {DIGIT}+"."{DIGIT}*
-ID [a-zA-Z_$][a-zA-Z0-9_$]*
-STRQ '([^\']|(\\\'))*'
-STRDQ \"([^\"]|(\\\"))*\"
-SINGLE_LINE_COMMENT "//"[^\n]*
-MULTI_LINE_COMMENT "/*".*"*/"
-COMMENT {SINGLE_LINE_COMMENT}|{MULTI_LINE_COMMENT}
-DECORATOR @[a-zA-Z]+
-%%
-
-break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|if|import|in|instanceof|new|null|return|super|switch|this|throw|true|try|typeof|var|void|while|with|as|implements|interface|let|package|private|protected|public|static|yield|any|boolean|constructor|declare|get|module|require|number|set|string|symbol|type|from|of {
- yylval = yytext;
- return KEYWORD;
-}
-
-{COMMENT} {
- yylval = yytext;
- return COMMENT;
-}
-
-{DECORATOR} {
- yylval = yytext;
- return DECORATOR;
-}
-
-"{" { return '{'; }
-
-"}" { return '}'; }
-
-{STRQ}|{STRDQ} {
- yylval = yytext;
- return STRING;
-}
-
-{NUMBER}|{FNUMBER} {
- yylval = yytext;
- return NUMBER;
-}
-
-{ID} {
- yylval = yytext;
- return IDENTIFIER;
-}
-
-":"|"?"|"."|"!"|"~"|"-"|"+"|"++"|"--"|"*"|"/"|"%"|"<<"|">>"|">>>"|"<"|"<="|">"|">="|"=="|"!="|"==="|"!=="|"&"|"^"|"|"|"&&"|"||"|"="|"+="|"-="|"*="|"/="|"%="|"<<="|">>="|">>>="|"&="|"^="|"|="|"=>" {
- yylval = yytext;
- return OPERATOR;
-}
-
-\n {
- yylval = yytext;
- return NEWLINE;
-}
-
-. {
- yylval = yytext;
- return OTHER;
-}
-
-%%
-
-int yywrap()
-{
- return 1;
-} \ No newline at end of file
diff --git a/homework/81459/js2html/README.md b/homework/81459/js2html/README.md
deleted file mode 100644
index bb0d3a7..0000000
--- a/homework/81459/js2html/README.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# Requirements
-- [Node.js](https://nodejs.org/en/)
-
-# Usage
-```bash
-node highlight.js <input-file> <output-file>
-```
-`<input-file>` - the file with code to highlight (**testfile.js**)<br>
-`<output-file>` - the file where to save the computed html (**output.html**) *If missing the result will be printed on the console*
diff --git a/homework/81459/js2html/highlight.js b/homework/81459/js2html/highlight.js
deleted file mode 100644
index 947ae5f..0000000
--- a/homework/81459/js2html/highlight.js
+++ /dev/null
@@ -1,103 +0,0 @@
-(() => {
- const inputFile = process.argv[2];
- const outputFile = process.argv[3];
-
- const fs = require('fs');
-
- fs.readFile(inputFile, 'utf8', (err, contents) => {
- if (err) {
- throw err;
- }
-
- const html = generateHtml(contents);
-
- if (outputFile) {
- fs.writeFile(outputFile, html, 'utf8', (err) => {
- if (err) {
- throw err;
- }
- });
- } else {
- console.log(html);
- }
- });
-})();
-
-const tokens = [
- {type: 'KEYWORD', className: 'orange', regex: /^(break|case|catch|class|const|continue|debugger|default|delete|do|else|export|extends|finally|for|function|if|import|in|instanceof|new|of|return|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/},
- {type: 'WHITESPACE', className: '', regex: /^\s+/},
- {type: 'BRACKET', className: 'white', regex: /^[\[\]{}()]/},
- {type: 'PUNCTUATION', className: 'white', regex: /^[:;,.]/},
- {type: 'COMMENT', className: 'grey', regex: /^\/\/.*/},
- {type: 'OPERATOR', className: 'red', regex: /^(\+|-|\/|={1,3}|!={0,2}|&{1,2}|\|{1,2}|\*|~|\^)/},
- {type: 'BOOLEAN_LITERAL', className: 'purple', regex: /^(true|false)\b/},
- {type: 'NUMBER_LITERAL', className: 'blue', regex: /^-?\d+(?:\.\d+)?(?:e[+\-]?\d+)?/i},
- {type: 'STRING_LITERAL', className: 'green', regex: /^("(?:\\.|[^"])*"|'(?:\\.|[^'])*')/},
- {type: 'NULL', className: 'orange', regex: /^(null|undefined)\b/},
- {type: 'IDENTIFIER', className: 'white', regex: /^\w+/},
- {type: "UNKNOWN", className: 'white', regex: /^./}
-];
-
-function generateHtml(code) {
- let highlitedTokens = [];
-
- while (code && code.length) {
- for (const token of tokens) {
- if (token.regex.test(code)) {
- const match = token.regex.exec(code);
- highlitedTokens.push(highlightToken(match[0], token));
- code = code.substring(match[0].length);
- break;
- }
- }
- }
-
- return `${getHtmlHeader()}${highlitedTokens.join('')}${getHtmlFooter()}`
-}
-
-function highlightToken(token, tokenType) {
- return `<span class="${tokenType.className}">${token}</span>`
-}
-
-const getHtmlHeader = () => `<!doctype html>
-<html>
- <head>
- <style>
- .orange {
- color: orange;
- }
- .white {
- color: white;
- }
- .grey {
- color: grey;
- }
- .green {
- color: green;
- }
- .purple {
- color: purple;
- }
- .red {
- color: red;
- }
- .blue {
- color: cyan;
- }
- .gold {
- color: gold;
- }
- .background {
- background: #2d2d2d;
- }
- </style>
- </head>
- <body class="background">
- <pre>
-`;
-
-const getHtmlFooter = () => `
- </pre>
- </body>
-</html>
-`;
diff --git a/homework/81459/js2html/output.html b/homework/81459/js2html/output.html
deleted file mode 100644
index 52eeeb6..0000000
--- a/homework/81459/js2html/output.html
+++ /dev/null
@@ -1,74 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <style>
- .orange {
- color: orange;
- }
- .white {
- color: white;
- }
- .grey {
- color: grey;
- }
- .green {
- color: green;
- }
- .purple {
- color: purple;
- }
- .red {
- color: red;
- }
- .blue {
- color: cyan;
- }
- .gold {
- color: gold;
- }
- .background {
- background: #2d2d2d;
- }
- </style>
- </head>
- <body class="background">
- <pre>
-<span class="orange">class</span><span class=""> </span><span class="white">Nonsense</span><span class=""> </span><span class="white">{</span><span class="">
- </span><span class="white">constructor</span><span class="white">(</span><span class="white">)</span><span class=""> </span><span class="white">{</span><span class="">
- </span><span class="orange">this</span><span class="white">.</span><span class="white">arbitraryArray</span><span class=""> </span><span class="red">=</span><span class=""> </span><span class="white">[</span><span class="green">'string with no meaning'</span><span class="white">,</span><span class=""> </span><span class="blue">42</span><span class="white">]</span><span class="white">;</span><span class="">
- </span><span class="white">}</span><span class="">
-
- </span><span class="white">doesThisMakeSense</span><span class="white">(</span><span class="white">)</span><span class=""> </span><span class="white">{</span><span class="">
- </span><span class="orange">return</span><span class=""> </span><span class="purple">false</span><span class="white">;</span><span class="">
- </span><span class="white">}</span><span class="">
-
- </span><span class="white">answer</span><span class="white">(</span><span class="white">answer</span><span class="white">)</span><span class=""> </span><span class="white">{</span><span class="">
- </span><span class="white">console</span><span class="white">.</span><span class="white">log</span><span class="white">(</span><span class="white">answer</span><span class="white">)</span><span class="white">;</span><span class="">
- </span><span class="white">}</span><span class="">
-
- </span><span class="white">whatIsTheMeaning</span><span class="white">(</span><span class="white">)</span><span class=""> </span><span class="white">{</span><span class="">
- </span><span class="orange">return</span><span class=""> </span><span class="orange">this</span><span class="white">.</span><span class="white">arbitraryArray</span><span class="white">[</span><span class="orange">this</span><span class="white">.</span><span class="white">getRandomIndex</span><span class="white">(</span><span class="white">)</span><span class="white">]</span><span class="">
- </span><span class="white">}</span><span class="">
-
- </span><span class="white">getRandomIndex</span><span class="white">(</span><span class="white">)</span><span class=""> </span><span class="white">{</span><span class="">
- </span><span class="orange">return</span><span class=""> </span><span class="white">Math</span><span class="white">.</span><span class="white">floor</span><span class="white">(</span><span class="white">Math</span><span class="white">.</span><span class="white">random</span><span class="white">(</span><span class="white">)</span><span class=""> </span><span class="red">*</span><span class=""> </span><span class="blue">2</span><span class="white">)</span><span class="white">;</span><span class="">
- </span><span class="white">}</span><span class="">
-</span><span class="white">}</span><span class="">
-
-</span><span class="white">(</span><span class="orange">function</span><span class=""> </span><span class="white">(</span><span class="white">)</span><span class=""> </span><span class="white">{</span><span class="">
- </span><span class="white">console</span><span class="white">.</span><span class="white">log</span><span class="white">(</span><span class="white">(</span><span class="red">-</span><span class="red">~</span><span class="orange">function</span><span class="white">(</span><span class="white">)</span><span class="white">{</span><span class="white">}</span><span class="red">-</span><span class="red">~</span><span class="orange">function</span><span class="white">(</span><span class="white">)</span><span class="white">{</span><span class="white">}</span><span class="white">)</span><span class="white">)</span><span class="white">;</span><span class=""> </span><span class="grey">// 2, now that's weird</span><span class="">
- </span><span class="white">console</span><span class="white">.</span><span class="white">log</span><span class="white">(</span><span class="white">Array</span><span class="white">(</span><span class="blue">16</span><span class="white">)</span><span class="white">.</span><span class="white">join</span><span class="white">(</span><span class="green">"lol"</span><span class=""> </span><span class="red">-</span><span class=""> </span><span class="blue">2</span><span class="white">)</span><span class=""> </span><span class="red">+</span><span class=""> </span><span class="green">" Batman!"</span><span class="white">)</span><span class="white">;</span><span class=""> </span><span class="grey">// ;)</span><span class="">
-
-
- </span><span class="orange">const</span><span class=""> </span><span class="white">nonsense</span><span class=""> </span><span class="red">=</span><span class=""> </span><span class="orange">new</span><span class=""> </span><span class="white">Nonsense</span><span class="white">(</span><span class="white">)</span><span class="white">;</span><span class="">
-
- </span><span class="orange">while</span><span class="white">(</span><span class="white">nonsense</span><span class="white">.</span><span class="white">doesThisMakeSense</span><span class="white">(</span><span class="white">)</span><span class="white">)</span><span class=""> </span><span class="white">{</span><span class=""> </span><span class="grey">// No, it doesn't</span><span class="">
- </span><span class="white">nonsense</span><span class="white">.</span><span class="white">answer</span><span class="white">(</span><span class="white">nonsense</span><span class="white">.</span><span class="white">whatIsTheMeaning</span><span class="white">(</span><span class="white">)</span><span class="white">)</span><span class="white">;</span><span class="">
- </span><span class="white">}</span><span class="">
-</span><span class="white">}</span><span class="white">)</span><span class="white">(</span><span class="white">)</span><span class="white">;</span><span class="">
-
-
-</span>
- </pre>
- </body>
-</html>
diff --git a/homework/81459/js2html/testfile.js b/homework/81459/js2html/testfile.js
deleted file mode 100644
index 0097012..0000000
--- a/homework/81459/js2html/testfile.js
+++ /dev/null
@@ -1,35 +0,0 @@
-class Nonsense {
- constructor() {
- this.arbitraryArray = ['string with no meaning', 42];
- }
-
- doesThisMakeSense() {
- return false;
- }
-
- answer(answer) {
- console.log(answer);
- }
-
- whatIsTheMeaning() {
- return this.arbitraryArray[this.getRandomIndex()]
- }
-
- getRandomIndex() {
- return Math.floor(Math.random() * 2);
- }
-}
-
-(function () {
- console.log((-~function(){}-~function(){})); // 2, now that's weird
- console.log(Array(16).join("lol" - 2) + " Batman!"); // ;)
-
-
- const nonsense = new Nonsense();
-
- while(nonsense.doesThisMakeSense()) { // No, it doesn't
- nonsense.answer(nonsense.whatIsTheMeaning());
- }
-})();
-
-
diff --git a/homework/81489/bf_interpreter/main.cpp b/homework/81489/bf_interpreter/main.cpp
deleted file mode 100644
index fc065aa..0000000
--- a/homework/81489/bf_interpreter/main.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-#include <stdio.h>
-#include <stack>
-#include <unistd.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <string>
-
-using namespace std;
-
-class Brainfuck {
- private:
- static const int init_length = 1024;
- char *tape;
- stack<int> loop_stack;
- char *tape_pos;
-
- public:
- Brainfuck() : tape(new char[init_length]), tape_pos(tape + (init_length / 2)) {}
- Brainfuck(int _length): tape(new char [_length]), tape_pos(tape + (_length / 2)) {}
-
- void interpret(string& code) {
- for (int i = 0; code[i]; ++i) {
- switch (code[i]) {
- case '\n': break;
- case '<': --(this->tape_pos); break;
- case '>': ++(this->tape_pos); break;
- case '-': -- *(this->tape_pos); break;
- case '+': ++ *(this->tape_pos); break;
- case '[': this->loop_stack.push(i); break;
- case ']':
- if (*(this->tape_pos)) {
- i = this->loop_stack.top();
- } else {
- this->loop_stack.pop();
- }
- break;
- case '.': putchar(*this->tape_pos); break;
- case ',': *(this->tape_pos) = (char)getchar();
- default: break;
- }
- }
- }
-};
-
-int main(int argc, char *argv[])
-{
- Brainfuck bf;
- if (argc != 2) {
- printf("Usage: <executable> <text_file_name>\n");
- return 1;
- }
-
- int fd;
- if (!(fd = open(argv[1], O_RDONLY))) {
- printf("Error opening file \"%s\"\n", argv[1]);
- return 1;
- };
-
- char buff[128];
- string code;
- while (int lth = read(fd, buff, 128)) {
- buff[lth] = '\0';
- code += buff;
- }
-
- bf.interpret(code);
- return 0;
-} \ No newline at end of file
diff --git a/homework/81498/.gitignore.txt b/homework/81498/.gitignore.txt
deleted file mode 100644
index f00a0eb..0000000
--- a/homework/81498/.gitignore.txt
+++ /dev/null
@@ -1,334 +0,0 @@
-## Ignore Visual Studio temporary files, build results, and
-## files generated by popular Visual Studio add-ons.
-##
-## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
-
-# User-specific files
-*.rsuser
-*.suo
-*.user
-*.userosscache
-*.sln.docstates
-
-# User-specific files (MonoDevelop/Xamarin Studio)
-*.userprefs
-
-# Build results
-[Dd]ebug/
-[Dd]ebugPublic/
-[Rr]elease/
-[Rr]eleases/
-x64/
-x86/
-bld/
-[Bb]in/
-[Oo]bj/
-[Ll]og/
-
-# Visual Studio 2015/2017 cache/options directory
-.vs/
-# Uncomment if you have tasks that create the project's static files in wwwroot
-#wwwroot/
-
-# Visual Studio 2017 auto generated files
-Generated\ Files/
-
-# MSTest test Results
-[Tt]est[Rr]esult*/
-[Bb]uild[Ll]og.*
-
-# NUNIT
-*.VisualState.xml
-TestResult.xml
-
-# Build Results of an ATL Project
-[Dd]ebugPS/
-[Rr]eleasePS/
-dlldata.c
-
-# Benchmark Results
-BenchmarkDotNet.Artifacts/
-
-# .NET Core
-project.lock.json
-project.fragment.lock.json
-artifacts/
-
-# StyleCop
-StyleCopReport.xml
-
-# Files built by Visual Studio
-*_i.c
-*_p.c
-*_h.h
-*.ilk
-*.meta
-*.obj
-*.iobj
-*.pch
-*.pdb
-*.ipdb
-*.pgc
-*.pgd
-*.rsp
-*.sbr
-*.tlb
-*.tli
-*.tlh
-*.tmp
-*.tmp_proj
-*_wpftmp.csproj
-*.log
-*.vspscc
-*.vssscc
-.builds
-*.pidb
-*.svclog
-*.scc
-
-# Chutzpah Test files
-_Chutzpah*
-
-# Visual C++ cache files
-ipch/
-*.aps
-*.ncb
-*.opendb
-*.opensdf
-*.sdf
-*.cachefile
-*.VC.db
-*.VC.VC.opendb
-
-# Visual Studio profiler
-*.psess
-*.vsp
-*.vspx
-*.sap
-
-# Visual Studio Trace Files
-*.e2e
-
-# TFS 2012 Local Workspace
-$tf/
-
-# Guidance Automation Toolkit
-*.gpState
-
-# ReSharper is a .NET coding add-in
-_ReSharper*/
-*.[Rr]e[Ss]harper
-*.DotSettings.user
-
-# JustCode is a .NET coding add-in
-.JustCode
-
-# TeamCity is a build add-in
-_TeamCity*
-
-# DotCover is a Code Coverage Tool
-*.dotCover
-
-# AxoCover is a Code Coverage Tool
-.axoCover/*
-!.axoCover/settings.json
-
-# Visual Studio code coverage results
-*.coverage
-*.coveragexml
-
-# NCrunch
-_NCrunch_*
-.*crunch*.local.xml
-nCrunchTemp_*
-
-# MightyMoose
-*.mm.*
-AutoTest.Net/
-
-# Web workbench (sass)
-.sass-cache/
-
-# Installshield output folder
-[Ee]xpress/
-
-# DocProject is a documentation generator add-in
-DocProject/buildhelp/
-DocProject/Help/*.HxT
-DocProject/Help/*.HxC
-DocProject/Help/*.hhc
-DocProject/Help/*.hhk
-DocProject/Help/*.hhp
-DocProject/Help/Html2
-DocProject/Help/html
-
-# Click-Once directory
-publish/
-
-# Publish Web Output
-*.[Pp]ublish.xml
-*.azurePubxml
-# Note: Comment the next line if you want to checkin your web deploy settings,
-# but database connection strings (with potential passwords) will be unencrypted
-*.pubxml
-*.publishproj
-
-# Microsoft Azure Web App publish settings. Comment the next line if you want to
-# checkin your Azure Web App publish settings, but sensitive information contained
-# in these scripts will be unencrypted
-PublishScripts/
-
-# NuGet Packages
-*.nupkg
-# The packages folder can be ignored because of Package Restore
-**/[Pp]ackages/*
-# except build/, which is used as an MSBuild target.
-!**/[Pp]ackages/build/
-# Uncomment if necessary however generally it will be regenerated when needed
-#!**/[Pp]ackages/repositories.config
-# NuGet v3's project.json files produces more ignorable files
-*.nuget.props
-*.nuget.targets
-
-# Microsoft Azure Build Output
-csx/
-*.build.csdef
-
-# Microsoft Azure Emulator
-ecf/
-rcf/
-
-# Windows Store app package directories and files
-AppPackages/
-BundleArtifacts/
-Package.StoreAssociation.xml
-_pkginfo.txt
-*.appx
-
-# Visual Studio cache files
-# files ending in .cache can be ignored
-*.[Cc]ache
-# but keep track of directories ending in .cache
-!*.[Cc]ache/
-
-# Others
-ClientBin/
-~$*
-*~
-*.dbmdl
-*.dbproj.schemaview
-*.jfm
-*.pfx
-*.publishsettings
-orleans.codegen.cs
-
-# Including strong name files can present a security risk
-# (https://github.com/github/gitignore/pull/2483#issue-259490424)
-#*.snk
-
-# Since there are multiple workflows, uncomment next line to ignore bower_components
-# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
-#bower_components/
-
-# RIA/Silverlight projects
-Generated_Code/
-
-# Backup & report files from converting an old project file
-# to a newer Visual Studio version. Backup files are not needed,
-# because we have git ;-)
-_UpgradeReport_Files/
-Backup*/
-UpgradeLog*.XML
-UpgradeLog*.htm
-ServiceFabricBackup/
-*.rptproj.bak
-
-# SQL Server files
-*.mdf
-*.ldf
-*.ndf
-
-# Business Intelligence projects
-*.rdl.data
-*.bim.layout
-*.bim_*.settings
-*.rptproj.rsuser
-
-# Microsoft Fakes
-FakesAssemblies/
-
-# GhostDoc plugin setting file
-*.GhostDoc.xml
-
-# Node.js Tools for Visual Studio
-.ntvs_analysis.dat
-node_modules/
-
-# Visual Studio 6 build log
-*.plg
-
-# Visual Studio 6 workspace options file
-*.opt
-
-# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
-*.vbw
-
-# Visual Studio LightSwitch build output
-**/*.HTMLClient/GeneratedArtifacts
-**/*.DesktopClient/GeneratedArtifacts
-**/*.DesktopClient/ModelManifest.xml
-**/*.Server/GeneratedArtifacts
-**/*.Server/ModelManifest.xml
-_Pvt_Extensions
-
-# Paket dependency manager
-.paket/paket.exe
-paket-files/
-
-# FAKE - F# Make
-.fake/
-
-# JetBrains Rider
-.idea/
-*.sln.iml
-
-# CodeRush personal settings
-.cr/personal
-
-# Python Tools for Visual Studio (PTVS)
-__pycache__/
-*.pyc
-
-# Cake - Uncomment if you are using it
-# tools/**
-# !tools/packages.config
-
-# Tabs Studio
-*.tss
-
-# Telerik's JustMock configuration file
-*.jmconfig
-
-# BizTalk build output
-*.btp.cs
-*.btm.cs
-*.odx.cs
-*.xsd.cs
-
-# OpenCover UI analysis results
-OpenCover/
-
-# Azure Stream Analytics local run output
-ASALocalRun/
-
-# MSBuild Binary and Structured Log
-*.binlog
-
-# NVidia Nsight GPU debugger configuration file
-*.nvuser
-
-# MFractors (Xamarin productivity tool) working folder
-.mfractor/
-
-# Local History for Visual Studio
-.localhistory/ \ No newline at end of file
diff --git a/homework/81498/Project/Wizard/Homeworks/WeekOne/BooleanOperatorsTokenTypes.cs b/homework/81498/Project/Wizard/Homeworks/WeekOne/BooleanOperatorsTokenTypes.cs
deleted file mode 100644
index 34eda75..0000000
--- a/homework/81498/Project/Wizard/Homeworks/WeekOne/BooleanOperatorsTokenTypes.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Wizard.Homeworks.WeekOne
-{
- public static class BooleanOperatorsTokenTypes
- {
- public static List<TokenType> AsList()
- {
- return new List<TokenType>()
- {
- TokenType.Bang,
- TokenType.BangEqual,
- TokenType.LogicalOr,
- TokenType.LogicalAnd,
- TokenType.EqualEqual,
- TokenType.StrictEqual,
- TokenType.StrictNotEqual,
- TokenType.Greater,
- TokenType.GreaterEqual,
- TokenType.Less,
- TokenType.LessEqual
- };
- }
- }
-}
diff --git a/homework/81498/Project/Wizard/Homeworks/WeekOne/Colour.cs b/homework/81498/Project/Wizard/Homeworks/WeekOne/Colour.cs
deleted file mode 100644
index 06d4670..0000000
--- a/homework/81498/Project/Wizard/Homeworks/WeekOne/Colour.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Wizard.Homeworks.WeekOne
-{
- public static class Color
- {
- public const string ForBoolean = "#FF0000";
- public const string ForBooleanOperator = "000000";
- public const string ForKeyword = "#0B0AF6";
- public const string ForString = "#F609F5";
- public const string ForNumber = "#F66509";
- public const string ForIdentifier = "222222";
- public const string ForDefault = "000000";
- }
-}
diff --git a/homework/81498/Project/Wizard/Homeworks/WeekOne/TokenHandler.cs b/homework/81498/Project/Wizard/Homeworks/WeekOne/TokenHandler.cs
deleted file mode 100644
index 9e25c6c..0000000
--- a/homework/81498/Project/Wizard/Homeworks/WeekOne/TokenHandler.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Wizard.Homeworks.WeekOne;
-using Wizard.Misc;
-
-namespace Wizard.Homeworks
-{ // private or property?
- public class TokenHandler
- {
- private List<Token> _tokens;
- private List<TokenType> _operatorsAsTokenList;
- private List<TokenType> _keywordsAsTokenTypes;
-
- public string FileDestination { get; set; }
-
- public TokenHandler(List<Token> tokens, string fileDestionation)
- {
- _tokens = tokens;
- FileDestination = fileDestionation;
-
- _operatorsAsTokenList = OperatorsToTokens.AsTokenList();
- _keywordsAsTokenTypes = KeywordsToTokens.AsTokenList();
- }
-
- public void PrintTokens()
- {
- foreach (var token in _tokens)
- {
- Console.WriteLine(token.ToString());
- }
- }
-
- public void PrettyPrint(string fileDestination)
- {
- using (var writer = new StreamWriter(fileDestination))
- {
- foreach (var token in _tokens)
- {
- string coloredLexeme = "";
- if (token.Type is TokenType.True ||
- token.Type is TokenType.False)
- {
- coloredLexeme = "<span><font color=\"" + Color.ForBoolean + "\">" + token.Lexeme + "</font></span>";
- writer.Write(coloredLexeme);
- continue;
- }
-
- if (_operatorsAsTokenList.Contains(token.Type))
- {
- coloredLexeme = "<span><font color=\"" + Color.ForBooleanOperator + "\"><b>" + token.Lexeme + "</b></font></span>";
- writer.Write(coloredLexeme); // more
- continue;
- }
-
- if (_keywordsAsTokenTypes.Contains(token.Type))
- {
- coloredLexeme = "<span><font color=\"" + Color.ForKeyword + "\">" + token.Lexeme + "</font></span>";
- writer.Write(coloredLexeme); // more
- continue;
- }
-
- switch (token.Type)
- {
- case TokenType.Whitespace:
- writer.Write("&nbsp;");
- break;
- case TokenType.Newline: writer.Write("<br>"); break;
- case TokenType.String: // more
- coloredLexeme = "<span><font color=\"" + Color.ForString + "\">\"" + token.Lexeme + "\"</font></span>";
- writer.Write(coloredLexeme);
- break;
- case TokenType.Number:
- coloredLexeme = "<span><font color=\"" + Color.ForNumber + "\">" + token.Lexeme + "</font></span>";
- writer.Write(coloredLexeme);
- break;
- case TokenType.Identifier:
- coloredLexeme = "<span><font color=\"" + Color.ForIdentifier + "\">" + token.Lexeme + "</font></span>";
- writer.Write(coloredLexeme);
- break;
- default:
- coloredLexeme = "<span><font color=\"" + Color.ForDefault + "\">" + token.Lexeme + "</font></span>";
- writer.Write(coloredLexeme);
- break;
- }
- }
- }
- }
- }
-}
diff --git a/homework/81498/Project/Wizard/Misc/ExactMatchSymbolsToTokensMap.cs b/homework/81498/Project/Wizard/Misc/ExactMatchSymbolsToTokensMap.cs
deleted file mode 100644
index ecfeb92..0000000
--- a/homework/81498/Project/Wizard/Misc/ExactMatchSymbolsToTokensMap.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Wizard.Misc
-{ // is this a good idea?
- public static class ExactMatchSymbolsToTokens
- {
- public static Dictionary<char, TokenType> AsMap()
- {
- return new Dictionary<char, TokenType>()
- {
- {' ', TokenType.Whitespace },
- {'\t', TokenType.Tab },
- {':', TokenType.Colon },
- {',', TokenType.Comma },
- {'(', TokenType.LeftParenthesis },
- {'{', TokenType.LeftBrace },
- {'[', TokenType.LeftSquareBracket },
- {']', TokenType.RightSquareBracket },
- {'}', TokenType.RightBrace },
- {')', TokenType.RightParenthesis },
- {';', TokenType.Semicolon },
- {'\'', TokenType.SingleQuote },
- {'?', TokenType.SingleQuote },
- {'.', TokenType.SingleQuote },
- };
- }
- }
-}
diff --git a/homework/81498/Project/Wizard/Misc/KeywordsToTokensMap.cs b/homework/81498/Project/Wizard/Misc/KeywordsToTokensMap.cs
deleted file mode 100644
index 85783ab..0000000
--- a/homework/81498/Project/Wizard/Misc/KeywordsToTokensMap.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Wizard.Misc
-{
- public static class KeywordsToTokens
- {
- public static Dictionary<string, TokenType> AsMap()
- {
- return new Dictionary<string, TokenType>()
- {
- { "break", TokenType.Break },
- { "case",TokenType.Case},
- {"catch", TokenType.Catch },
- {"class", TokenType.Class },
- {"const", TokenType.Const },
- {"continue", TokenType.Continue },
- {"debugger", TokenType.Debugger },
- {"default", TokenType.Default },
- {"delete", TokenType.Delete },
- {"do", TokenType.Do },
- {"else", TokenType.Else },
- {"export", TokenType.Export },
- {"extends", TokenType.Extends },
- {"false", TokenType.False },
- {"finally", TokenType.Finally },
- {"for", TokenType.For },
- {"function", TokenType.Function },
- {"if", TokenType.If },
- {"import", TokenType.Import },
- {"in", TokenType.In },
- {"instanceof", TokenType.Instanceof },
- {"let", TokenType.Let },
- {"new", TokenType.New },
- {"return", TokenType.Return },
- {"super", TokenType.Super },
- {"switch", TokenType.Switch },
- {"this", TokenType.This },
- {"throw", TokenType.Throw },
- {"try", TokenType.Try },
- {"true", TokenType.True },
- {"typeof", TokenType.Typeof },
- {"var", TokenType.Var },
- {"void", TokenType.Void },
- {"while", TokenType.While },
- {"with", TokenType.With },
- {"yield", TokenType.Yield }
- };
- }
- public static List<TokenType> AsTokenList()
- {
- return AsMap().Values.ToList();
- }
- }
-}
diff --git a/homework/81498/Project/Wizard/Misc/OperatorsToTokensMap.cs b/homework/81498/Project/Wizard/Misc/OperatorsToTokensMap.cs
deleted file mode 100644
index 2468fec..0000000
--- a/homework/81498/Project/Wizard/Misc/OperatorsToTokensMap.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Wizard.Misc
-{
- public static class OperatorsToTokens
- {
- public static Dictionary<string, TokenType> AsMap()
- {
- return new Dictionary<string, TokenType>()
- {
- {"!" ,TokenType.Bang},
- {"=" ,TokenType.Equal},
- {"|" ,TokenType.BitwiseOr},
- {"&" ,TokenType.BitwiseAnd},
- {">" ,TokenType.Greater},
- {"<" ,TokenType.Less},
- {"+" ,TokenType.Plus},
- {"-" ,TokenType.Minus},
- {"*" ,TokenType.Star},
- {"/" ,TokenType.Division},
- {"%" ,TokenType.Modulo},
-
- {"!=" ,TokenType.BangEqual},
- {"/=" ,TokenType.DivideEqual},
- {"!!" ,TokenType.DoubleBang},
- {"**" ,TokenType.DoubleStar},
- {"==" ,TokenType.EqualEqual},
- {">=" ,TokenType.GreaterEqual},
- {"+=" ,TokenType.PlusEqual},
- {"++" ,TokenType.PlusPlus},
- {"&&" ,TokenType.LogicalAnd},
- {"||" ,TokenType.LogicalOr},
- {"<=" ,TokenType.LessEqual},
- {"*=" ,TokenType.StarEqual},
- {"-=" ,TokenType.MinusEqual},
- {"--" ,TokenType.MinusMinus},
- {"%=" ,TokenType.ModuloEqual},
-
- {"===" ,TokenType.StrictEqual},
- {"!==" ,TokenType.StrictNotEqual},
- {"**=" ,TokenType.DoubleStarEqual},
- };
- }
-
- public static List<TokenType> AsTokenList()
- {
- return AsMap().Values.ToList();
- }
- }
-}
diff --git a/homework/81498/Project/Wizard/Program.cs b/homework/81498/Project/Wizard/Program.cs
deleted file mode 100644
index a2722f5..0000000
--- a/homework/81498/Project/Wizard/Program.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.IO;
-using Wizard.Homeworks;
-
-namespace Wizard
-{
- class Program
- {
- static void Main(string[] args)
- {
- string programAsText = "";
- string fileName = "";
-
- Console.WriteLine("Please Enter absolute path for the text file(sorry): \n");
- fileName = Console.ReadLine();
-
- Console.WriteLine("The html will be generated with name semi_pretty.html");
-
- using (var reader = new StreamReader(fileName))
- {
- while (!reader.EndOfStream)
- {
- programAsText += reader.ReadLine();
- programAsText += "\n";
- }
- }
-
- var tokenizer = new Lexer(programAsText, fileName);
- var tokens = tokenizer.GenerateTokens();
-
- var printToPath = "semi_pretty.html";
- var tokenHandler = new TokenHandler(tokens, printToPath);
- //tokenHandler.PrintTokens();
- tokenHandler.PrettyPrint(printToPath);
-
- }
- }
-}
diff --git a/homework/81498/Project/Wizard/Text files/simpleFunction.html b/homework/81498/Project/Wizard/Text files/simpleFunction.html
deleted file mode 100644
index d5bf508..0000000
--- a/homework/81498/Project/Wizard/Text files/simpleFunction.html
+++ /dev/null
@@ -1 +0,0 @@
-<span><font color="#0B0AF6">function</font></span>&nbsp;<span><font color="222222">sumOfSomeNumbers</font></span>&nbsp;<span><font color="000000">(</font></span>&nbsp;<span><font color="222222">number</font></span><span><font color="000000">,</font></span>&nbsp;<span><font color="222222">secondNumber</font></span><span><font color="000000">)</font></span>&nbsp;<span><font color="000000">{</font></span><br>&nbsp;&nbsp;&nbsp;&nbsp;<span><font color="222222">magicalThingsWithNumbersAndStrings</font></span><span><font color="000000">(</font></span><span><font color="#F609F5">"hello there my friend"</font></span><span><font color="000000">,</font></span>&nbsp;<span><font color="222222">a</font></span><span><font color="000000">,</font></span>&nbsp;<span><font color="222222">b</font></span><span><font color="000000">,</font></span>&nbsp;<span><font color="222222">c</font></span><span><font color="000000">)</font></span><span><font color="000000">;</font></span><br>&nbsp;&nbsp;&nbsp;&nbsp;<span><font color="222222">number</font></span>&nbsp;<span><font color="000000"><b>=</b></font></span>&nbsp;<span><font color="#F66509">1</font></span>&nbsp;<span><font color="000000"><b>+</b></font></span>&nbsp;<span><font color="#F66509">2</font></span>&nbsp;<span><font color="000000"><b>+</b></font></span>&nbsp;<span><font color="#F66509">3</font></span>&nbsp;<span><font color="000000"><b>/</b></font></span>&nbsp;<span><font color="#F66509">14</font></span>&nbsp;<span><font color="000000"><b>*</b></font></span>&nbsp;<span><font color="000000">(</font></span><span><font color="#F66509">16</font></span>&nbsp;<span><font color="000000"><b>**</b></font></span>&nbsp;<span><font color="#F66509">16</font></span><span><font color="000000">)</font></span><span><font color="000000">;</font></span><br>&nbsp;&nbsp;&nbsp;&nbsp;<span><font color="#0B0AF6">return</font></span>&nbsp;<span><font color="#FF0000">true</font></span>&nbsp;<span><font color="000000"><b>||</b></font></span>&nbsp;<span><font color="222222">number</font></span>&nbsp;<span><font color="000000"><b>&&</b></font></span>&nbsp;<span><font color="#F66509">3</font></span>&nbsp;<span><font color="000000"><b>+</b></font></span>&nbsp;<span><font color="#F66509">13</font></span><span><font color="000000">;</font></span><br><br><span><font color="000000">}</font></span><br> \ No newline at end of file
diff --git a/homework/81498/Project/Wizard/Text files/simpleFunction.js b/homework/81498/Project/Wizard/Text files/simpleFunction.js
deleted file mode 100644
index ac8d903..0000000
--- a/homework/81498/Project/Wizard/Text files/simpleFunction.js
+++ /dev/null
@@ -1,6 +0,0 @@
-function sumOfSomeNumbers ( number, secondNumber) {
- magicalThingsWithNumbersAndStrings("hello there my friend", a, b, c);
- number = 1 + 2 + 3 / 14 * (16 ** 16);
- return true || number && 3 + 13;
-
-} \ No newline at end of file
diff --git a/homework/81498/Project/Wizard/Tokenizing/Lexer.cs b/homework/81498/Project/Wizard/Tokenizing/Lexer.cs
deleted file mode 100644
index 69f011e..0000000
--- a/homework/81498/Project/Wizard/Tokenizing/Lexer.cs
+++ /dev/null
@@ -1,428 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Wizard.Misc;
-
-namespace Wizard
-{
- public class Lexer
- {
- public Lexer(string code, string location)
- {
- _code = code;
- _location = location;
-
- _currentLine = 1;
- _indexInCode = 0;
- _indexInCurrentLine = 0;
-
- _keywordsToTokensMap = KeywordsToTokens.AsMap();
- _complexOperatorsToTokensMap = OperatorsToTokens.AsMap(); // you didn't use this shithead
- _exactMatchSymbolsToTokensMap = ExactMatchSymbolsToTokens.AsMap();
- }
-
- private const string _letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- private const string _digits = "0123456789";
- private const string _identifiers = _letters + _digits + "_";
- private const string _exactMatchSymbols = " \t:,({[]});'?.";
- private const string _singleLetterOperators = "!|&/=><-%+*";
-
- private string _code;
- private string _location;
- private int _currentLine;
- private int _indexInCode;
- private int _indexInCurrentLine;
-
- private Dictionary<string, TokenType> _keywordsToTokensMap;
- private Dictionary<string, TokenType> _complexOperatorsToTokensMap;
- private Dictionary<char, TokenType> _exactMatchSymbolsToTokensMap;
-
- public List<Token> GenerateTokens()
- {
- var tokens = new List<Token>();
- do
- {
- tokens.Add(NextToken());
- }
- while (_indexInCode != _code.Length);
-
- return tokens;
- }
-
- private Token NextToken()
- {
- char c = _code[_indexInCode];
-
- if (_exactMatchSymbols.Contains(c))
- {
- AdvanceIndex();
- return GenerateToken(_exactMatchSymbolsToTokensMap[c], c.ToString());
- }
-
- if (c is '\"')
- {
- return GenerateToken(TokenType.String, GetNextString());
- }
-
- if (c is '\n')
- {
- AdvanceIndexOnNewLine();
- return GenerateToken(TokenType.Newline, "\n");
- }
-
- // empty string parsed by Decimal.TryParse returns 0 but that's none of my business
- if (_digits.Contains(c))
- {
- string nextNumber = GetNextNumber();
- return GenerateToken(TokenType.Number, nextNumber);
- }
-
- if (_identifiers.Contains(c))
- {
- string nextWord = GetNextWord();
-
- if (_keywordsToTokensMap.ContainsKey(nextWord))
- {
- return GenerateToken(_keywordsToTokensMap[nextWord], nextWord);
- }
-
- return GenerateToken(TokenType.Identifier, nextWord);
- }
-
- if (_singleLetterOperators.Contains(c))
- {
- return GetOperatorToken();
- }
- return new Token(TokenType.Eof, _currentLine, "", _location, null);
- }
-
- private Token GenerateToken(TokenType type)
- {
- return new Token(type, _currentLine, "", _location, null);
- }
-
- private Token GenerateToken(TokenType type, string lexeme)
- {
- return new Token(type, _currentLine, lexeme, _location, null);
- }
-
- private void AdvanceIndex()
- {
- ++_indexInCode;
- ++_indexInCurrentLine;
- }
-
- private void AdvanceIndexOnNewLine()
- {
- _indexInCode++;
- _currentLine++;
- _indexInCurrentLine = 0;
- }
-
- private char AdvanceAndGetNext()
- {
- AdvanceIndex();
- return _code[_indexInCode];
- }
-
- private string GetNextString()
- { // advance once to ignore double quotes
- AdvanceIndex();
- try
- {
- char c = _code[_indexInCode];
- string quoteTerminatedString = "";
-
- while (c != '\"')
- {
- quoteTerminatedString += c;
-
- c = AdvanceAndGetNext();
- }
-
- // advance again to ignore ending quotes
- AdvanceIndex();
-
- return quoteTerminatedString;
- }
- catch (ArgumentOutOfRangeException)
- {
- return "";
- }
- }
-
- private string GetNextWord()
- {
- char c = _code[_indexInCode];
- string identifiersOnlyString = "";
-
- try
- {
- while (_identifiers.Contains(c))
- {
- identifiersOnlyString += c;
-
- c = AdvanceAndGetNext();
- }
-
- return identifiersOnlyString;
- }
- catch (ArgumentOutOfRangeException)
- {
- return "";
- }
- }
-
- private string GetNextNumber()
- {
- string nonDigitTerminatedString = "";
-
- try
- {
- char c = _code[_indexInCode];
-
- while (_digits.Contains(c))
- {
- nonDigitTerminatedString += c;
-
- c = AdvanceAndGetNext();
- }
-
- return nonDigitTerminatedString;
- }
- catch (ArgumentOutOfRangeException)
- {
- return "";
- }
- }
-
- // isn't there better way to do this? I mean structural way, like interface, another class or something?
- // Should I move handlers to another class?
- // helper functions in an interface?
- // what should be return in the catch of exceptions?
- private Token GetOperatorToken()
- {
- try
- {
- char c = _code[_indexInCode];
- switch (c)
- {
- case '>': return HandleOperatorGreater(); // > >=
- case '<': return HandleOperatorLess(); // < <=
- case '/': return HandleOperatorDivision(); // / /=
- case '%': return HandleOperatorModulo(); // % %=
- case '+': return HandleOperatorPlus(); // + += ++
- case '-': return HandleOperatorMinus(); // - -= --
- case '&': return HandleOperatorBitwiseAnd(); // & &= &&
- case '|': return HandleOperatorBitwiseOr(); // | |= ||
- case '=': return HandleOperatorEquals(); // = == ===
- case '!': return HandleOperatorBang(); // ! != !! !==
- case '*': return HandleOperatorStar(); // * *= ** **=
- default:
- break;
- }
-
- return GenerateToken(TokenType.None); // throw exception?
- }
- catch (ArgumentOutOfRangeException)
- {
- return GenerateToken(TokenType.None);
- }
- }
-
- private Token HandleOperatorStar()
- {
- char next = AdvanceAndGetNext();
- if (next is '=')
- {
- AdvanceIndex();
- return GenerateToken(TokenType.StarEqual, "*=");
- }
-
- if (next is '*')
- {
- next = AdvanceAndGetNext();
- if (next is '=')
- {
- AdvanceIndex();
- return GenerateToken(TokenType.DoubleStarEqual, "**=");
- }
-
- return GenerateToken(TokenType.DoubleStar, "**");
- }
-
- return GenerateToken(TokenType.Star, "*");
- }
-
- private Token HandleOperatorBang()
- {
- char next = AdvanceAndGetNext();
-
- if (next is '!')
- {
- AdvanceIndex();
- return GenerateToken(TokenType.DoubleBang, "!!");
- }
-
- if (next is '=')
- {
- next = AdvanceAndGetNext();
- if (next is '=')
- {
- AdvanceIndex();
- return GenerateToken(TokenType.StrictNotEqual, "!==");
- }
-
- return GenerateToken(TokenType.BangEqual, "!=");
- }
-
- return GenerateToken(TokenType.Bang, "!");
- }
-
- private Token HandleOperatorEquals()
- {
- char next = AdvanceAndGetNext();
- if (next is '=')
- {
- next = AdvanceAndGetNext();
- if (next is '=')
- {
- AdvanceIndex();
- GenerateToken(TokenType.StrictEqual, "===");
- }
-
- return GenerateToken(TokenType.EqualEqual, "==");
- }
-
- return GenerateToken(TokenType.Equal, "=");
- }
-
- private Token HandleOperatorBitwiseOr()
- {
- char next = AdvanceAndGetNext();
-
- if (next is '=')
- {
- AdvanceIndex();
- return GenerateToken(TokenType.BitwiseOrEqual, "|=");
- }
-
- if (next is '|')
- {
- AdvanceIndex();
- return GenerateToken(TokenType.LogicalOr, "||");
- }
-
- return GenerateToken(TokenType.BitwiseOr, "|");
- }
-
- private Token HandleOperatorBitwiseAnd()
- {
- char next = AdvanceAndGetNext();
-
- if (next is '=')
- {
- AdvanceIndex();
- return GenerateToken(TokenType.BitwiseAndEqual, "&=");
- }
-
- if (next is '&')
- {
- AdvanceIndex();
- return GenerateToken(TokenType.LogicalAnd, "&&");
- }
-
- return GenerateToken(TokenType.BitwiseAnd, "&");
- }
-
- private Token HandleOperatorMinus()
- {
- char next = AdvanceAndGetNext();
-
- if (next is '=')
- {
- AdvanceIndex();
- return GenerateToken(TokenType.MinusEqual, "-=");
- }
-
- if (next is '-')
- {
- AdvanceIndex();
- return GenerateToken(TokenType.MinusMinus, "--");
- }
-
- return GenerateToken(TokenType.Minus, "-");
- }
-
- private Token HandleOperatorPlus()
- {
- char next = AdvanceAndGetNext();
-
- if (next is '=')
- {
- AdvanceIndex();
- return GenerateToken(TokenType.PlusEqual, "+=");
- }
-
- if (next is '+')
- {
- AdvanceIndex();
- return GenerateToken(TokenType.PlusPlus, "++");
- }
-
- return GenerateToken(TokenType.Plus, "+");
- }
-
- private Token HandleOperatorModulo()
- {
- char next = AdvanceAndGetNext();
- if (next is '=')
- {
- AdvanceIndex();
- return GenerateToken(TokenType.ModuloEqual, "%=");
- }
-
- return GenerateToken(TokenType.Modulo, "%");
- }
-
- private Token HandleOperatorDivision()
- {
- char next = AdvanceAndGetNext();
-
- if (next is '=')
- {
- AdvanceIndex();
- GenerateToken(TokenType.DivideEqual, "/=");
- }
-
- return GenerateToken(TokenType.Division, "/");
-
- }
-
- private Token HandleOperatorLess()
- {
- char next = AdvanceAndGetNext();
-
- if (next == '=')
- {
- AdvanceIndex();
- return GenerateToken(TokenType.LessEqual, "<=");
- }
-
- return GenerateToken(TokenType.Less, "<");
- }
-
- private Token HandleOperatorGreater()
- {
- char next = AdvanceAndGetNext();
-
- if (next is '=')
- {
- AdvanceIndex();
- return GenerateToken(TokenType.GreaterEqual, ">=");
- }
-
- return GenerateToken(TokenType.Greater, ">");
- }
- }
-} \ No newline at end of file
diff --git a/homework/81498/Project/Wizard/Tokenizing/Token.cs b/homework/81498/Project/Wizard/Tokenizing/Token.cs
deleted file mode 100644
index 1d68e8e..0000000
--- a/homework/81498/Project/Wizard/Tokenizing/Token.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Wizard
-{
- public class Token
- {
- public Token(TokenType type, int line, string lexeme, string location, decimal? number)
- {
- Type = type;
- Line = line;
- Lexeme = lexeme;
- Location = location;
- Number = number;
-
- }
-
- public TokenType Type { get; private set; }
- public int Line { get; private set; }
- public string Lexeme { get; private set; }
- public decimal? Number { get; private set; }
- public string Location { get; private set; }
-
- public override string ToString()
- {
- return Type.ToString() + " " + Lexeme + " " + Number;
- }
-
- }
-}
diff --git a/homework/81498/Project/Wizard/Tokenizing/TokenTypeEnumerator.cs b/homework/81498/Project/Wizard/Tokenizing/TokenTypeEnumerator.cs
deleted file mode 100644
index 78f5c0e..0000000
--- a/homework/81498/Project/Wizard/Tokenizing/TokenTypeEnumerator.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Wizard
-{
- public enum TokenType
- {
- // Whitespaces
- Newline,
- Tab,
- Whitespace,
-
- // Symbols
- Colon,
- Comma,
- LeftBrace,
- LeftParenthesis,
- LeftSquareBracket,
- RightBrace,
- RightParenthesis,
- RightSquareBracket,
- Semicolon,
- SingleQuote,
-
- // One chararacter operators
- Bang,
- BitwiseAnd,
- BitwiseOr,
- Division,
- Dot,
- DoubleQuotes,
- Equal,
- Greater,
- Less,
- Minus,
- Modulo,
- Plus,
- QuestionMark,
- Star,
-
- // Two character tokens
- BangEqual,
- BitwiseAndEqual,
- BitwiseOrEqual,
- DivideEqual,
- DoubleBang,
- DoubleStar,
- EqualEqual,
- GreaterEqual,
- PlusEqual,
- PlusPlus,
- LogicalAnd,
- LogicalOr,
- LessEqual,
- StarEqual,
- MinusEqual,
- MinusMinus,
- ModuloEqual,
-
- // Three character tokens
- StrictEqual,
- StrictNotEqual,
- DoubleStarEqual,
-
- Identifier,
- Number,
- String,
-
- // Keywords. ECMAScript 2015
- Break,
- Case,
- Catch,
- Class,
- Const,
- Continue,
- Debugger,
- Default,
- Delete,
- Do,
- Else,
- Export,
- Extends,
- Finally,
- For,
- Function,
- If,
- Import,
- In,
- Instanceof,
- Let,
- New,
- Return,
- Super,
- Switch,
- This,
- Throw,
- Try,
- Typeof,
- Var,
- Void,
- While,
- With,
- Yield,
- Null,
- Undefined,
- True,
- False,
-
- Eof,
- None
- }
-
-}
diff --git a/homework/81568/BF_Interpreter/CLI11.hpp b/homework/81568/BF_Interpreter/CLI11.hpp
deleted file mode 100644
index bf3f813..0000000
--- a/homework/81568/BF_Interpreter/CLI11.hpp
+++ /dev/null
@@ -1,4043 +0,0 @@
-#pragma once
-
-// CLI11: Version 1.6.1
-// Originally designed by Henry Schreiner
-// https://github.com/CLIUtils/CLI11
-//
-// This is a standalone header file generated by MakeSingleHeader.py in CLI11/scripts
-// from: v1.6.1
-//
-// From LICENSE:
-//
-// CLI11 1.6 Copyright (c) 2017-2018 University of Cincinnati, developed by Henry
-// Schreiner under NSF AWARD 1414736. All rights reserved.
-//
-// Redistribution and use in source and binary forms of CLI11, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// 1. Redistributions of source code must retain the above copyright notice, this
-// list of conditions and the following disclaimer.
-// 2. Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-// 3. Neither the name of the copyright holder nor the names of its contributors
-// may be used to endorse or promote products derived from this software without
-// specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
-// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-// Standard combined includes:
-
-#include <algorithm>
-#include <deque>
-#include <exception>
-#include <fstream>
-#include <functional>
-#include <iomanip>
-#include <iostream>
-#include <istream>
-#include <iterator>
-#include <locale>
-#include <map>
-#include <memory>
-#include <numeric>
-#include <set>
-#include <sstream>
-#include <stdexcept>
-#include <string>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <tuple>
-#include <type_traits>
-#include <utility>
-#include <vector>
-
-
-// Verbatim copy from CLI/Version.hpp:
-
-
-#define CLI11_VERSION_MAJOR 1
-#define CLI11_VERSION_MINOR 6
-#define CLI11_VERSION_PATCH 1
-#define CLI11_VERSION "1.6.1"
-
-
-
-
-// Verbatim copy from CLI/Macros.hpp:
-
-
-// The following version macro is very similar to the one in PyBind11
-#if !(defined(_MSC_VER) && __cplusplus == 199711L) && !defined(__INTEL_COMPILER)
-#if __cplusplus >= 201402L
-#define CLI11_CPP14
-#if __cplusplus >= 201703L
-#define CLI11_CPP17
-#if __cplusplus > 201703L
-#define CLI11_CPP20
-#endif
-#endif
-#endif
-#elif defined(_MSC_VER) && __cplusplus == 199711L
-// MSVC sets _MSVC_LANG rather than __cplusplus (supposedly until the standard is fully implemented)
-// Unless you use the /Zc:__cplusplus flag on Visual Studio 2017 15.7 Preview 3 or newer
-#if _MSVC_LANG >= 201402L
-#define CLI11_CPP14
-#if _MSVC_LANG > 201402L && _MSC_VER >= 1910
-#define CLI11_CPP17
-#if __MSVC_LANG > 201703L && _MSC_VER >= 1910
-#define CLI11_CPP20
-#endif
-#endif
-#endif
-#endif
-
-#if defined(CLI11_CPP14)
-#define CLI11_DEPRECATED(reason) [[deprecated(reason)]]
-#elif defined(_MSC_VER)
-#define CLI11_DEPRECATED(reason) __declspec(deprecated(reason))
-#else
-#define CLI11_DEPRECATED(reason) __attribute__((deprecated(reason)))
-#endif
-
-
-
-
-// Verbatim copy from CLI/Optional.hpp:
-
-#ifdef __has_include
-
-#if defined(CLI11_CPP17) && __has_include(<optional>) && \
- !defined(CLI11_STD_OPTIONAL)
-#define CLI11_STD_OPTIONAL 1
-#endif
-
-#if defined(CLI11_CPP14) && __has_include(<experimental/optional>) && \
- !defined(CLI11_EXPERIMENTAL_OPTIONAL)
-#define CLI11_EXPERIMENTAL_OPTIONAL 1
-#endif
-
-#if __has_include(<boost/optional.hpp>) && !defined(CLI11_BOOST_OPTIONAL)
-#include <boost/version.hpp>
-#if BOOST_VERSION >= 105800
-#define CLI11_BOOST_OPTIONAL 1
-#endif
-#endif
-
-#endif
-
-#if CLI11_STD_OPTIONAL
-#include <optional>
-#endif
-#if CLI11_EXPERIMENTAL_OPTIONAL
-#include <experimental/optional>
-#endif
-#if CLI11_BOOST_OPTIONAL
-#include <boost/optional.hpp>
-#endif
-
-
-// From CLI/Version.hpp:
-
-
-
-// From CLI/Macros.hpp:
-
-
-
-// From CLI/Optional.hpp:
-
-namespace CLI {
-
-#if CLI11_STD_OPTIONAL
-template <typename T> std::istream &operator>>(std::istream &in, std::optional<T> &val) {
- T v;
- in >> v;
- val = v;
- return in;
-}
-#endif
-
-#if CLI11_EXPERIMENTAL_OPTIONAL
-template <typename T> std::istream &operator>>(std::istream &in, std::experimental::optional<T> &val) {
- T v;
- in >> v;
- val = v;
- return in;
-}
-#endif
-
-#if CLI11_BOOST_OPTIONAL
-template <typename T> std::istream &operator>>(std::istream &in, boost::optional<T> &val) {
- T v;
- in >> v;
- val = v;
- return in;
-}
-#endif
-
-// Export the best optional to the CLI namespace
-#if CLI11_STD_OPTIONAL
-using std::optional;
-#elif CLI11_EXPERIMENTAL_OPTIONAL
-using std::experimental::optional;
-#elif CLI11_BOOST_OPTIONAL
-using boost::optional;
-#endif
-
-// This is true if any optional is found
-#if CLI11_STD_OPTIONAL || CLI11_EXPERIMENTAL_OPTIONAL || CLI11_BOOST_OPTIONAL
-#define CLI11_OPTIONAL 1
-#endif
-
-} // namespace CLI
-
-// From CLI/StringTools.hpp:
-
-namespace CLI {
-namespace detail {
-
-// Based on http://stackoverflow.com/questions/236129/split-a-string-in-c
-/// Split a string by a delim
-inline std::vector<std::string> split(const std::string &s, char delim) {
- std::vector<std::string> elems;
- // Check to see if empty string, give consistent result
- if(s.empty())
- elems.emplace_back("");
- else {
- std::stringstream ss;
- ss.str(s);
- std::string item;
- while(std::getline(ss, item, delim)) {
- elems.push_back(item);
- }
- }
- return elems;
-}
-
-/// Simple function to join a string
-template <typename T> std::string join(const T &v, std::string delim = ",") {
- std::ostringstream s;
- size_t start = 0;
- for(const auto &i : v) {
- if(start++ > 0)
- s << delim;
- s << i;
- }
- return s.str();
-}
-
-/// Join a string in reverse order
-template <typename T> std::string rjoin(const T &v, std::string delim = ",") {
- std::ostringstream s;
- for(size_t start = 0; start < v.size(); start++) {
- if(start > 0)
- s << delim;
- s << v[v.size() - start - 1];
- }
- return s.str();
-}
-
-// Based roughly on http://stackoverflow.com/questions/25829143/c-trim-whitespace-from-a-string
-
-/// Trim whitespace from left of string
-inline std::string &ltrim(std::string &str) {
- auto it = std::find_if(str.begin(), str.end(), [](char ch) { return !std::isspace<char>(ch, std::locale()); });
- str.erase(str.begin(), it);
- return str;
-}
-
-/// Trim anything from left of string
-inline std::string &ltrim(std::string &str, const std::string &filter) {
- auto it = std::find_if(str.begin(), str.end(), [&filter](char ch) { return filter.find(ch) == std::string::npos; });
- str.erase(str.begin(), it);
- return str;
-}
-
-/// Trim whitespace from right of string
-inline std::string &rtrim(std::string &str) {
- auto it = std::find_if(str.rbegin(), str.rend(), [](char ch) { return !std::isspace<char>(ch, std::locale()); });
- str.erase(it.base(), str.end());
- return str;
-}
-
-/// Trim anything from right of string
-inline std::string &rtrim(std::string &str, const std::string &filter) {
- auto it =
- std::find_if(str.rbegin(), str.rend(), [&filter](char ch) { return filter.find(ch) == std::string::npos; });
- str.erase(it.base(), str.end());
- return str;
-}
-
-/// Trim whitespace from string
-inline std::string &trim(std::string &str) { return ltrim(rtrim(str)); }
-
-/// Trim anything from string
-inline std::string &trim(std::string &str, const std::string filter) { return ltrim(rtrim(str, filter), filter); }
-
-/// Make a copy of the string and then trim it
-inline std::string trim_copy(const std::string &str) {
- std::string s = str;
- return trim(s);
-}
-
-/// Make a copy of the string and then trim it, any filter string can be used (any char in string is filtered)
-inline std::string trim_copy(const std::string &str, const std::string &filter) {
- std::string s = str;
- return trim(s, filter);
-}
-/// Print a two part "help" string
-inline std::ostream &format_help(std::ostream &out, std::string name, std::string description, size_t wid) {
- name = " " + name;
- out << std::setw(static_cast<int>(wid)) << std::left << name;
- if(!description.empty()) {
- if(name.length() >= wid)
- out << "\n" << std::setw(static_cast<int>(wid)) << "";
- out << description;
- }
- out << "\n";
- return out;
-}
-
-/// Verify the first character of an option
-template <typename T> bool valid_first_char(T c) { return std::isalpha(c, std::locale()) || c == '_'; }
-
-/// Verify following characters of an option
-template <typename T> bool valid_later_char(T c) {
- return std::isalnum(c, std::locale()) || c == '_' || c == '.' || c == '-';
-}
-
-/// Verify an option name
-inline bool valid_name_string(const std::string &str) {
- if(str.empty() || !valid_first_char(str[0]))
- return false;
- for(auto c : str.substr(1))
- if(!valid_later_char(c))
- return false;
- return true;
-}
-
-/// Return a lower case version of a string
-inline std::string to_lower(std::string str) {
- std::transform(std::begin(str), std::end(str), std::begin(str), [](const std::string::value_type &x) {
- return std::tolower(x, std::locale());
- });
- return str;
-}
-
-/// Split a string '"one two" "three"' into 'one two', 'three'
-inline std::vector<std::string> split_up(std::string str) {
-
- std::vector<char> delims = {'\'', '\"'};
- auto find_ws = [](char ch) { return std::isspace<char>(ch, std::locale()); };
- trim(str);
-
- std::vector<std::string> output;
-
- while(!str.empty()) {
- if(str[0] == '\'') {
- auto end = str.find('\'', 1);
- if(end != std::string::npos) {
- output.push_back(str.substr(1, end - 1));
- str = str.substr(end + 1);
- } else {
- output.push_back(str.substr(1));
- str = "";
- }
- } else if(str[0] == '\"') {
- auto end = str.find('\"', 1);
- if(end != std::string::npos) {
- output.push_back(str.substr(1, end - 1));
- str = str.substr(end + 1);
- } else {
- output.push_back(str.substr(1));
- str = "";
- }
-
- } else {
- auto it = std::find_if(std::begin(str), std::end(str), find_ws);
- if(it != std::end(str)) {
- std::string value = std::string(str.begin(), it);
- output.push_back(value);
- str = std::string(it, str.end());
- } else {
- output.push_back(str);
- str = "";
- }
- }
- trim(str);
- }
-
- return output;
-}
-
-/// Add a leader to the beginning of all new lines (nothing is added
-/// at the start of the first line). `"; "` would be for ini files
-///
-/// Can't use Regex, or this would be a subs.
-inline std::string fix_newlines(std::string leader, std::string input) {
- std::string::size_type n = 0;
- while(n != std::string::npos && n < input.size()) {
- n = input.find('\n', n);
- if(n != std::string::npos) {
- input = input.substr(0, n + 1) + leader + input.substr(n + 1);
- n += leader.size();
- }
- }
- return input;
-}
-
-} // namespace detail
-} // namespace CLI
-
-// From CLI/Error.hpp:
-
-namespace CLI {
-
-// Use one of these on all error classes.
-// These are temporary and are undef'd at the end of this file.
-#define CLI11_ERROR_DEF(parent, name) \
- protected: \
- name(std::string name, std::string msg, int exit_code) : parent(std::move(name), std::move(msg), exit_code) {} \
- name(std::string name, std::string msg, ExitCodes exit_code) \
- : parent(std::move(name), std::move(msg), exit_code) {} \
- \
- public: \
- name(std::string msg, ExitCodes exit_code) : parent(#name, std::move(msg), exit_code) {} \
- name(std::string msg, int exit_code) : parent(#name, std::move(msg), exit_code) {}
-
-// This is added after the one above if a class is used directly and builds its own message
-#define CLI11_ERROR_SIMPLE(name) \
- explicit name(std::string msg) : name(#name, msg, ExitCodes::name) {}
-
-/// These codes are part of every error in CLI. They can be obtained from e using e.exit_code or as a quick shortcut,
-/// int values from e.get_error_code().
-enum class ExitCodes {
- Success = 0,
- IncorrectConstruction = 100,
- BadNameString,
- OptionAlreadyAdded,
- FileError,
- ConversionError,
- ValidationError,
- RequiredError,
- RequiresError,
- ExcludesError,
- ExtrasError,
- ConfigError,
- InvalidError,
- HorribleError,
- OptionNotFound,
- ArgumentMismatch,
- BaseClass = 127
-};
-
-// Error definitions
-
-/// @defgroup error_group Errors
-/// @brief Errors thrown by CLI11
-///
-/// These are the errors that can be thrown. Some of them, like CLI::Success, are not really errors.
-/// @{
-
-/// All errors derive from this one
-class Error : public std::runtime_error {
- int exit_code;
- std::string name{"Error"};
-
- public:
- int get_exit_code() const { return exit_code; }
-
- std::string get_name() const { return name; }
-
- Error(std::string name, std::string msg, int exit_code = static_cast<int>(ExitCodes::BaseClass))
- : runtime_error(msg), exit_code(exit_code), name(std::move(name)) {}
-
- Error(std::string name, std::string msg, ExitCodes exit_code) : Error(name, msg, static_cast<int>(exit_code)) {}
-};
-
-// Note: Using Error::Error constructors does not work on GCC 4.7
-
-/// Construction errors (not in parsing)
-class ConstructionError : public Error {
- CLI11_ERROR_DEF(Error, ConstructionError)
-};
-
-/// Thrown when an option is set to conflicting values (non-vector and multi args, for example)
-class IncorrectConstruction : public ConstructionError {
- CLI11_ERROR_DEF(ConstructionError, IncorrectConstruction)
- CLI11_ERROR_SIMPLE(IncorrectConstruction)
- static IncorrectConstruction PositionalFlag(std::string name) {
- return IncorrectConstruction(name + ": Flags cannot be positional");
- }
- static IncorrectConstruction Set0Opt(std::string name) {
- return IncorrectConstruction(name + ": Cannot set 0 expected, use a flag instead");
- }
- static IncorrectConstruction SetFlag(std::string name) {
- return IncorrectConstruction(name + ": Cannot set an expected number for flags");
- }
- static IncorrectConstruction ChangeNotVector(std::string name) {
- return IncorrectConstruction(name + ": You can only change the expected arguments for vectors");
- }
- static IncorrectConstruction AfterMultiOpt(std::string name) {
- return IncorrectConstruction(
- name + ": You can't change expected arguments after you've changed the multi option policy!");
- }
- static IncorrectConstruction MissingOption(std::string name) {
- return IncorrectConstruction("Option " + name + " is not defined");
- }
- static IncorrectConstruction MultiOptionPolicy(std::string name) {
- return IncorrectConstruction(name + ": multi_option_policy only works for flags and exact value options");
- }
-};
-
-/// Thrown on construction of a bad name
-class BadNameString : public ConstructionError {
- CLI11_ERROR_DEF(ConstructionError, BadNameString)
- CLI11_ERROR_SIMPLE(BadNameString)
- static BadNameString OneCharName(std::string name) { return BadNameString("Invalid one char name: " + name); }
- static BadNameString BadLongName(std::string name) { return BadNameString("Bad long name: " + name); }
- static BadNameString DashesOnly(std::string name) {
- return BadNameString("Must have a name, not just dashes: " + name);
- }
- static BadNameString MultiPositionalNames(std::string name) {
- return BadNameString("Only one positional name allowed, remove: " + name);
- }
-};
-
-/// Thrown when an option already exists
-class OptionAlreadyAdded : public ConstructionError {
- CLI11_ERROR_DEF(ConstructionError, OptionAlreadyAdded)
- explicit OptionAlreadyAdded(std::string name)
- : OptionAlreadyAdded(name + " is already added", ExitCodes::OptionAlreadyAdded) {}
- static OptionAlreadyAdded Requires(std::string name, std::string other) {
- return OptionAlreadyAdded(name + " requires " + other, ExitCodes::OptionAlreadyAdded);
- }
- static OptionAlreadyAdded Excludes(std::string name, std::string other) {
- return OptionAlreadyAdded(name + " excludes " + other, ExitCodes::OptionAlreadyAdded);
- }
-};
-
-// Parsing errors
-
-/// Anything that can error in Parse
-class ParseError : public Error {
- CLI11_ERROR_DEF(Error, ParseError)
-};
-
-// Not really "errors"
-
-/// This is a successful completion on parsing, supposed to exit
-class Success : public ParseError {
- CLI11_ERROR_DEF(ParseError, Success)
- Success() : Success("Successfully completed, should be caught and quit", ExitCodes::Success) {}
-};
-
-/// -h or --help on command line
-class CallForHelp : public ParseError {
- CLI11_ERROR_DEF(ParseError, CallForHelp)
- CallForHelp() : CallForHelp("This should be caught in your main function, see examples", ExitCodes::Success) {}
-};
-
-/// Usually somethign like --help-all on command line
-class CallForAllHelp : public ParseError {
- CLI11_ERROR_DEF(ParseError, CallForAllHelp)
- CallForAllHelp()
- : CallForAllHelp("This should be caught in your main function, see examples", ExitCodes::Success) {}
-};
-
-/// Does not output a diagnostic in CLI11_PARSE, but allows to return from main() with a specific error code.
-class RuntimeError : public ParseError {
- CLI11_ERROR_DEF(ParseError, RuntimeError)
- explicit RuntimeError(int exit_code = 1) : RuntimeError("Runtime error", exit_code) {}
-};
-
-/// Thrown when parsing an INI file and it is missing
-class FileError : public ParseError {
- CLI11_ERROR_DEF(ParseError, FileError)
- CLI11_ERROR_SIMPLE(FileError)
- static FileError Missing(std::string name) { return FileError(name + " was not readable (missing?)"); }
-};
-
-/// Thrown when conversion call back fails, such as when an int fails to coerce to a string
-class ConversionError : public ParseError {
- CLI11_ERROR_DEF(ParseError, ConversionError)
- CLI11_ERROR_SIMPLE(ConversionError)
- ConversionError(std::string member, std::string name)
- : ConversionError("The value " + member + " is not an allowed value for " + name) {}
- ConversionError(std::string name, std::vector<std::string> results)
- : ConversionError("Could not convert: " + name + " = " + detail::join(results)) {}
- static ConversionError TooManyInputsFlag(std::string name) {
- return ConversionError(name + ": too many inputs for a flag");
- }
- static ConversionError TrueFalse(std::string name) {
- return ConversionError(name + ": Should be true/false or a number");
- }
-};
-
-/// Thrown when validation of results fails
-class ValidationError : public ParseError {
- CLI11_ERROR_DEF(ParseError, ValidationError)
- CLI11_ERROR_SIMPLE(ValidationError)
- explicit ValidationError(std::string name, std::string msg) : ValidationError(name + ": " + msg) {}
-};
-
-/// Thrown when a required option is missing
-class RequiredError : public ParseError {
- CLI11_ERROR_DEF(ParseError, RequiredError)
- explicit RequiredError(std::string name) : RequiredError(name + " is required", ExitCodes::RequiredError) {}
- static RequiredError Subcommand(size_t min_subcom) {
- if(min_subcom == 1)
- return RequiredError("A subcommand");
- else
- return RequiredError("Requires at least " + std::to_string(min_subcom) + " subcommands",
- ExitCodes::RequiredError);
- }
-};
-
-/// Thrown when the wrong number of arguments has been received
-class ArgumentMismatch : public ParseError {
- CLI11_ERROR_DEF(ParseError, ArgumentMismatch)
- CLI11_ERROR_SIMPLE(ArgumentMismatch)
- ArgumentMismatch(std::string name, int expected, size_t recieved)
- : ArgumentMismatch(expected > 0 ? ("Expected exactly " + std::to_string(expected) + " arguments to " + name +
- ", got " + std::to_string(recieved))
- : ("Expected at least " + std::to_string(-expected) + " arguments to " + name +
- ", got " + std::to_string(recieved)),
- ExitCodes::ArgumentMismatch) {}
-
- static ArgumentMismatch AtLeast(std::string name, int num) {
- return ArgumentMismatch(name + ": At least " + std::to_string(num) + " required");
- }
- static ArgumentMismatch TypedAtLeast(std::string name, int num, std::string type) {
- return ArgumentMismatch(name + ": " + std::to_string(num) + " required " + type + " missing");
- }
-};
-
-/// Thrown when a requires option is missing
-class RequiresError : public ParseError {
- CLI11_ERROR_DEF(ParseError, RequiresError)
- RequiresError(std::string curname, std::string subname)
- : RequiresError(curname + " requires " + subname, ExitCodes::RequiresError) {}
-};
-
-/// Thrown when an excludes option is present
-class ExcludesError : public ParseError {
- CLI11_ERROR_DEF(ParseError, ExcludesError)
- ExcludesError(std::string curname, std::string subname)
- : ExcludesError(curname + " excludes " + subname, ExitCodes::ExcludesError) {}
-};
-
-/// Thrown when too many positionals or options are found
-class ExtrasError : public ParseError {
- CLI11_ERROR_DEF(ParseError, ExtrasError)
- explicit ExtrasError(std::vector<std::string> args)
- : ExtrasError((args.size() > 1 ? "The following arguments were not expected: "
- : "The following argument was not expected: ") +
- detail::rjoin(args, " "),
- ExitCodes::ExtrasError) {}
-};
-
-/// Thrown when extra values are found in an INI file
-class ConfigError : public ParseError {
- CLI11_ERROR_DEF(ParseError, ConfigError)
- CLI11_ERROR_SIMPLE(ConfigError)
- static ConfigError Extras(std::string item) { return ConfigError("INI was not able to parse " + item); }
- static ConfigError NotConfigurable(std::string item) {
- return ConfigError(item + ": This option is not allowed in a configuration file");
- }
-};
-
-/// Thrown when validation fails before parsing
-class InvalidError : public ParseError {
- CLI11_ERROR_DEF(ParseError, InvalidError)
- explicit InvalidError(std::string name)
- : InvalidError(name + ": Too many positional arguments with unlimited expected args", ExitCodes::InvalidError) {
- }
-};
-
-/// This is just a safety check to verify selection and parsing match - you should not ever see it
-/// Strings are directly added to this error, but again, it should never be seen.
-class HorribleError : public ParseError {
- CLI11_ERROR_DEF(ParseError, HorribleError)
- CLI11_ERROR_SIMPLE(HorribleError)
-};
-
-// After parsing
-
-/// Thrown when counting a non-existent option
-class OptionNotFound : public Error {
- CLI11_ERROR_DEF(Error, OptionNotFound)
- explicit OptionNotFound(std::string name) : OptionNotFound(name + " not found", ExitCodes::OptionNotFound) {}
-};
-
-#undef CLI11_ERROR_DEF
-#undef CLI11_ERROR_SIMPLE
-
-/// @}
-
-} // namespace CLI
-
-// From CLI/TypeTools.hpp:
-
-namespace CLI {
-
-// Type tools
-
-/// A copy of enable_if_t from C++14, compatible with C++11.
-///
-/// We could check to see if C++14 is being used, but it does not hurt to redefine this
-/// (even Google does this: https://github.com/google/skia/blob/master/include/private/SkTLogic.h)
-/// It is not in the std namespace anyway, so no harm done.
-
-template <bool B, class T = void> using enable_if_t = typename std::enable_if<B, T>::type;
-
-/// Check to see if something is a vector (fail check by default)
-template <typename T> struct is_vector { static const bool value = false; };
-
-/// Check to see if something is a vector (true if actually a vector)
-template <class T, class A> struct is_vector<std::vector<T, A>> { static bool const value = true; };
-
-/// Check to see if something is bool (fail check by default)
-template <typename T> struct is_bool { static const bool value = false; };
-
-/// Check to see if something is bool (true if actually a bool)
-template <> struct is_bool<bool> { static bool const value = true; };
-
-namespace detail {
-// Based generally on https://rmf.io/cxx11/almost-static-if
-/// Simple empty scoped class
-enum class enabler {};
-
-/// An instance to use in EnableIf
-constexpr enabler dummy = {};
-
-// Type name print
-
-/// Was going to be based on
-/// http://stackoverflow.com/questions/1055452/c-get-name-of-type-in-template
-/// But this is cleaner and works better in this case
-
-template <typename T,
- enable_if_t<std::is_integral<T>::value && std::is_signed<T>::value, detail::enabler> = detail::dummy>
-constexpr const char *type_name() {
- return "INT";
-}
-
-template <typename T,
- enable_if_t<std::is_integral<T>::value && std::is_unsigned<T>::value, detail::enabler> = detail::dummy>
-constexpr const char *type_name() {
- return "UINT";
-}
-
-template <typename T, enable_if_t<std::is_floating_point<T>::value, detail::enabler> = detail::dummy>
-constexpr const char *type_name() {
- return "FLOAT";
-}
-
-/// This one should not be used, since vector types print the internal type
-template <typename T, enable_if_t<is_vector<T>::value, detail::enabler> = detail::dummy>
-constexpr const char *type_name() {
- return "VECTOR";
-}
-
-template <typename T,
- enable_if_t<!std::is_floating_point<T>::value && !std::is_integral<T>::value && !is_vector<T>::value,
- detail::enabler> = detail::dummy>
-constexpr const char *type_name() {
- return "TEXT";
-}
-
-// Lexical cast
-
-/// Signed integers / enums
-template <typename T,
- enable_if_t<(std::is_integral<T>::value && std::is_signed<T>::value), detail::enabler> = detail::dummy>
-bool lexical_cast(std::string input, T &output) {
- try {
- size_t n = 0;
- long long output_ll = std::stoll(input, &n, 0);
- output = static_cast<T>(output_ll);
- return n == input.size() && static_cast<long long>(output) == output_ll;
- } catch(const std::invalid_argument &) {
- return false;
- } catch(const std::out_of_range &) {
- return false;
- }
-}
-
-/// Unsigned integers
-template <typename T,
- enable_if_t<std::is_integral<T>::value && std::is_unsigned<T>::value, detail::enabler> = detail::dummy>
-bool lexical_cast(std::string input, T &output) {
- if(!input.empty() && input.front() == '-')
- return false; // std::stoull happily converts negative values to junk without any errors.
-
- try {
- size_t n = 0;
- unsigned long long output_ll = std::stoull(input, &n, 0);
- output = static_cast<T>(output_ll);
- return n == input.size() && static_cast<unsigned long long>(output) == output_ll;
- } catch(const std::invalid_argument &) {
- return false;
- } catch(const std::out_of_range &) {
- return false;
- }
-}
-
-/// Floats
-template <typename T, enable_if_t<std::is_floating_point<T>::value, detail::enabler> = detail::dummy>
-bool lexical_cast(std::string input, T &output) {
- try {
- size_t n = 0;
- output = static_cast<T>(std::stold(input, &n));
- return n == input.size();
- } catch(const std::invalid_argument &) {
- return false;
- } catch(const std::out_of_range &) {
- return false;
- }
-}
-
-/// String and similar
-template <typename T,
- enable_if_t<!std::is_floating_point<T>::value && !std::is_integral<T>::value &&
- std::is_assignable<T &, std::string>::value,
- detail::enabler> = detail::dummy>
-bool lexical_cast(std::string input, T &output) {
- output = input;
- return true;
-}
-
-/// Non-string parsable
-template <typename T,
- enable_if_t<!std::is_floating_point<T>::value && !std::is_integral<T>::value &&
- !std::is_assignable<T &, std::string>::value,
- detail::enabler> = detail::dummy>
-bool lexical_cast(std::string input, T &output) {
- std::istringstream is;
-
- is.str(input);
- is >> output;
- return !is.fail() && !is.rdbuf()->in_avail();
-}
-
-} // namespace detail
-} // namespace CLI
-
-// From CLI/Split.hpp:
-
-namespace CLI {
-namespace detail {
-
-// Returns false if not a short option. Otherwise, sets opt name and rest and returns true
-inline bool split_short(const std::string &current, std::string &name, std::string &rest) {
- if(current.size() > 1 && current[0] == '-' && valid_first_char(current[1])) {
- name = current.substr(1, 1);
- rest = current.substr(2);
- return true;
- } else
- return false;
-}
-
-// Returns false if not a long option. Otherwise, sets opt name and other side of = and returns true
-inline bool split_long(const std::string &current, std::string &name, std::string &value) {
- if(current.size() > 2 && current.substr(0, 2) == "--" && valid_first_char(current[2])) {
- auto loc = current.find("=");
- if(loc != std::string::npos) {
- name = current.substr(2, loc - 2);
- value = current.substr(loc + 1);
- } else {
- name = current.substr(2);
- value = "";
- }
- return true;
- } else
- return false;
-}
-
-// Splits a string into multiple long and short names
-inline std::vector<std::string> split_names(std::string current) {
- std::vector<std::string> output;
- size_t val;
- while((val = current.find(",")) != std::string::npos) {
- output.push_back(trim_copy(current.substr(0, val)));
- current = current.substr(val + 1);
- }
- output.push_back(trim_copy(current));
- return output;
-}
-
-/// Get a vector of short names, one of long names, and a single name
-inline std::tuple<std::vector<std::string>, std::vector<std::string>, std::string>
-get_names(const std::vector<std::string> &input) {
-
- std::vector<std::string> short_names;
- std::vector<std::string> long_names;
- std::string pos_name;
-
- for(std::string name : input) {
- if(name.length() == 0)
- continue;
- else if(name.length() > 1 && name[0] == '-' && name[1] != '-') {
- if(name.length() == 2 && valid_first_char(name[1]))
- short_names.emplace_back(1, name[1]);
- else
- throw BadNameString::OneCharName(name);
- } else if(name.length() > 2 && name.substr(0, 2) == "--") {
- name = name.substr(2);
- if(valid_name_string(name))
- long_names.push_back(name);
- else
- throw BadNameString::BadLongName(name);
- } else if(name == "-" || name == "--") {
- throw BadNameString::DashesOnly(name);
- } else {
- if(pos_name.length() > 0)
- throw BadNameString::MultiPositionalNames(name);
- pos_name = name;
- }
- }
-
- return std::tuple<std::vector<std::string>, std::vector<std::string>, std::string>(
- short_names, long_names, pos_name);
-}
-
-} // namespace detail
-} // namespace CLI
-
-// From CLI/ConfigFwd.hpp:
-
-namespace CLI {
-
-class App;
-
-namespace detail {
-
-/// Comma separated join, adds quotes if needed
-inline std::string ini_join(std::vector<std::string> args) {
- std::ostringstream s;
- size_t start = 0;
- for(const auto &arg : args) {
- if(start++ > 0)
- s << " ";
-
- auto it = std::find_if(arg.begin(), arg.end(), [](char ch) { return std::isspace<char>(ch, std::locale()); });
- if(it == arg.end())
- s << arg;
- else if(arg.find(R"(")") == std::string::npos)
- s << R"(")" << arg << R"(")";
- else
- s << R"(')" << arg << R"(')";
- }
-
- return s.str();
-}
-
-} // namespace detail
-
-/// Holds values to load into Options
-struct ConfigItem {
- /// This is the list of parents
- std::vector<std::string> parents;
-
- /// This is the name
- std::string name;
-
- /// Listing of inputs
- std::vector<std::string> inputs;
-
- /// The list of parents and name joined by "."
- std::string fullname() const {
- std::vector<std::string> tmp = parents;
- tmp.emplace_back(name);
- return detail::join(tmp, ".");
- }
-};
-
-/// This class provides a converter for configuration files.
-class Config {
- protected:
- std::vector<ConfigItem> items;
-
- public:
- /// Convert an app into a configuration
- virtual std::string to_config(const App *, bool, bool, std::string) const = 0;
-
- /// Convert a configuration into an app
- virtual std::vector<ConfigItem> from_config(std::istream &) const = 0;
-
- /// Convert a flag to a bool
- virtual std::vector<std::string> to_flag(const ConfigItem &item) const {
- if(item.inputs.size() == 1) {
- std::string val = item.inputs.at(0);
- val = detail::to_lower(val);
-
- if(val == "true" || val == "on" || val == "yes") {
- return std::vector<std::string>(1);
- } else if(val == "false" || val == "off" || val == "no") {
- return std::vector<std::string>();
- } else {
- try {
- size_t ui = std::stoul(val);
- return std::vector<std::string>(ui);
- } catch(const std::invalid_argument &) {
- throw ConversionError::TrueFalse(item.fullname());
- }
- }
- } else {
- throw ConversionError::TooManyInputsFlag(item.fullname());
- }
- }
-
- /// Parse a config file, throw an error (ParseError:ConfigParseError or FileError) on failure
- std::vector<ConfigItem> from_file(const std::string &name) {
- std::ifstream input{name};
- if(!input.good())
- throw FileError::Missing(name);
-
- return from_config(input);
- }
-
- /// virtual destructor
- virtual ~Config() = default;
-};
-
-/// This converter works with INI files
-class ConfigINI : public Config {
- public:
- std::string to_config(const App *, bool default_also, bool write_description, std::string prefix) const override;
-
- std::vector<ConfigItem> from_config(std::istream &input) const override {
- std::string line;
- std::string section = "default";
-
- std::vector<ConfigItem> output;
-
- while(getline(input, line)) {
- std::vector<std::string> items;
-
- detail::trim(line);
- size_t len = line.length();
- if(len > 1 && line[0] == '[' && line[len - 1] == ']') {
- section = line.substr(1, len - 2);
- } else if(len > 0 && line[0] != ';') {
- output.emplace_back();
- ConfigItem &out = output.back();
-
- // Find = in string, split and recombine
- auto pos = line.find('=');
- if(pos != std::string::npos) {
- out.name = detail::trim_copy(line.substr(0, pos));
- std::string item = detail::trim_copy(line.substr(pos + 1));
- items = detail::split_up(item);
- } else {
- out.name = detail::trim_copy(line);
- items = {"ON"};
- }
-
- if(detail::to_lower(section) != "default") {
- out.parents = {section};
- }
-
- if(out.name.find('.') != std::string::npos) {
- std::vector<std::string> plist = detail::split(out.name, '.');
- out.name = plist.back();
- plist.pop_back();
- out.parents.insert(out.parents.end(), plist.begin(), plist.end());
- }
-
- out.inputs.insert(std::end(out.inputs), std::begin(items), std::end(items));
- }
- }
- return output;
- }
-};
-
-} // namespace CLI
-
-// From CLI/Validators.hpp:
-
-namespace CLI {
-
-/// @defgroup validator_group Validators
-
-/// @brief Some validators that are provided
-///
-/// These are simple `std::string(const std::string&)` validators that are useful. They return
-/// a string if the validation fails. A custom struct is provided, as well, with the same user
-/// semantics, but with the ability to provide a new type name.
-/// @{
-
-///
-struct Validator {
- /// This is the type name, if empty the type name will not be changed
- std::string tname;
-
- /// This it the base function that is to be called.
- /// Returns a string error message if validation fails.
- std::function<std::string(const std::string &)> func;
-
- /// This is the required operator for a validator - provided to help
- /// users (CLI11 uses the member `func` directly)
- std::string operator()(const std::string &str) const { return func(str); };
-
- /// Combining validators is a new validator
- Validator operator&(const Validator &other) const {
- Validator newval;
- newval.tname = (tname == other.tname ? tname : "");
-
- // Give references (will make a copy in lambda function)
- const std::function<std::string(const std::string &filename)> &f1 = func;
- const std::function<std::string(const std::string &filename)> &f2 = other.func;
-
- newval.func = [f1, f2](const std::string &filename) {
- std::string s1 = f1(filename);
- std::string s2 = f2(filename);
- if(!s1.empty() && !s2.empty())
- return s1 + " & " + s2;
- else
- return s1 + s2;
- };
- return newval;
- }
-
- /// Combining validators is a new validator
- Validator operator|(const Validator &other) const {
- Validator newval;
- newval.tname = (tname == other.tname ? tname : "");
-
- // Give references (will make a copy in lambda function)
- const std::function<std::string(const std::string &filename)> &f1 = func;
- const std::function<std::string(const std::string &filename)> &f2 = other.func;
-
- newval.func = [f1, f2](const std::string &filename) {
- std::string s1 = f1(filename);
- std::string s2 = f2(filename);
- if(s1.empty() || s2.empty())
- return std::string();
- else
- return s1 + " & " + s2;
- };
- return newval;
- }
-};
-
-// The implementation of the built in validators is using the Validator class;
-// the user is only expected to use the const (static) versions (since there's no setup).
-// Therefore, this is in detail.
-namespace detail {
-
-/// Check for an existing file (returns error message if check fails)
-struct ExistingFileValidator : public Validator {
- ExistingFileValidator() {
- tname = "FILE";
- func = [](const std::string &filename) {
- struct stat buffer;
- bool exist = stat(filename.c_str(), &buffer) == 0;
- bool is_dir = (buffer.st_mode & S_IFDIR) != 0;
- if(!exist) {
- return "File does not exist: " + filename;
- } else if(is_dir) {
- return "File is actually a directory: " + filename;
- }
- return std::string();
- };
- }
-};
-
-/// Check for an existing directory (returns error message if check fails)
-struct ExistingDirectoryValidator : public Validator {
- ExistingDirectoryValidator() {
- tname = "DIR";
- func = [](const std::string &filename) {
- struct stat buffer;
- bool exist = stat(filename.c_str(), &buffer) == 0;
- bool is_dir = (buffer.st_mode & S_IFDIR) != 0;
- if(!exist) {
- return "Directory does not exist: " + filename;
- } else if(!is_dir) {
- return "Directory is actually a file: " + filename;
- }
- return std::string();
- };
- }
-};
-
-/// Check for an existing path
-struct ExistingPathValidator : public Validator {
- ExistingPathValidator() {
- tname = "PATH";
- func = [](const std::string &filename) {
- struct stat buffer;
- bool const exist = stat(filename.c_str(), &buffer) == 0;
- if(!exist) {
- return "Path does not exist: " + filename;
- }
- return std::string();
- };
- }
-};
-
-/// Check for an non-existing path
-struct NonexistentPathValidator : public Validator {
- NonexistentPathValidator() {
- tname = "PATH";
- func = [](const std::string &filename) {
- struct stat buffer;
- bool exist = stat(filename.c_str(), &buffer) == 0;
- if(exist) {
- return "Path already exists: " + filename;
- }
- return std::string();
- };
- }
-};
-} // namespace detail
-
-// Static is not needed here, because global const implies static.
-
-/// Check for existing file (returns error message if check fails)
-const detail::ExistingFileValidator ExistingFile;
-
-/// Check for an existing directory (returns error message if check fails)
-const detail::ExistingDirectoryValidator ExistingDirectory;
-
-/// Check for an existing path
-const detail::ExistingPathValidator ExistingPath;
-
-/// Check for an non-existing path
-const detail::NonexistentPathValidator NonexistentPath;
-
-/// Produce a range (factory). Min and max are inclusive.
-struct Range : public Validator {
- /// This produces a range with min and max inclusive.
- ///
- /// Note that the constructor is templated, but the struct is not, so C++17 is not
- /// needed to provide nice syntax for Range(a,b).
- template <typename T> Range(T min, T max) {
- std::stringstream out;
- out << detail::type_name<T>() << " in [" << min << " - " << max << "]";
-
- tname = out.str();
- func = [min, max](std::string input) {
- T val;
- detail::lexical_cast(input, val);
- if(val < min || val > max)
- return "Value " + input + " not in range " + std::to_string(min) + " to " + std::to_string(max);
-
- return std::string();
- };
- }
-
- /// Range of one value is 0 to value
- template <typename T> explicit Range(T max) : Range(static_cast<T>(0), max) {}
-};
-
-/// @}
-
-} // namespace CLI
-
-// From CLI/FormatterFwd.hpp:
-
-namespace CLI {
-
-class Option;
-class App;
-
-/// This enum signifies the type of help requested
-///
-/// This is passed in by App; all user classes must accept this as
-/// the second argument.
-
-enum class AppFormatMode {
- Normal, //< The normal, detailed help
- All, //< A fully expanded help
- Sub, //< Used when printed as part of expanded subcommand
-};
-
-/// This is the minimum requirements to run a formatter.
-///
-/// A user can subclass this is if they do not care at all
-/// about the structure in CLI::Formatter.
-class FormatterBase {
- protected:
- /// @name Options
- ///@{
-
- /// The width of the first column
- size_t column_width_{30};
-
- /// @brief The required help printout labels (user changeable)
- /// Values are Needs, Excludes, etc.
- std::map<std::string, std::string> labels_;
-
- ///@}
- /// @name Basic
- ///@{
-
- public:
- FormatterBase() = default;
- FormatterBase(const FormatterBase &) = default;
- FormatterBase(FormatterBase &&) = default;
- virtual ~FormatterBase() = default;
-
- /// This is the key method that puts together help
- virtual std::string make_help(const App *, std::string, AppFormatMode) const = 0;
-
- ///@}
- /// @name Setters
- ///@{
-
- /// Set the "REQUIRED" label
- void label(std::string key, std::string val) { labels_[key] = val; }
-
- /// Set the column width
- void column_width(size_t val) { column_width_ = val; }
-
- ///@}
- /// @name Getters
- ///@{
-
- /// Get the current value of a name (REQUIRED, etc.)
- std::string get_label(std::string key) const {
- if(labels_.find(key) == labels_.end())
- return key;
- else
- return labels_.at(key);
- }
-
- /// Get the current column width
- size_t get_column_width() const { return column_width_; }
-
- ///@}
-};
-
-/// This is a specialty override for lambda functions
-class FormatterLambda final : public FormatterBase {
- using funct_t = std::function<std::string(const App *, std::string, AppFormatMode)>;
-
- /// The lambda to hold and run
- funct_t lambda_;
-
- public:
- /// Create a FormatterLambda with a lambda function
- explicit FormatterLambda(funct_t funct) : lambda_(std::move(funct)) {}
-
- /// This will simply call the lambda function
- std::string make_help(const App *app, std::string name, AppFormatMode mode) const override {
- return lambda_(app, name, mode);
- }
-};
-
-/// This is the default Formatter for CLI11. It pretty prints help output, and is broken into quite a few
-/// overridable methods, to be highly customizable with minimal effort.
-class Formatter : public FormatterBase {
- public:
- Formatter() = default;
- Formatter(const Formatter &) = default;
- Formatter(Formatter &&) = default;
-
- /// @name Overridables
- ///@{
-
- /// This prints out a group of options with title
- ///
- virtual std::string make_group(std::string group, bool is_positional, std::vector<const Option *> opts) const;
-
- /// This prints out just the positionals "group"
- virtual std::string make_positionals(const App *app) const;
-
- /// This prints out all the groups of options
- std::string make_groups(const App *app, AppFormatMode mode) const;
-
- /// This prints out all the subcommands
- virtual std::string make_subcommands(const App *app, AppFormatMode mode) const;
-
- /// This prints out a subcommand
- virtual std::string make_subcommand(const App *sub) const;
-
- /// This prints out a subcommand in help-all
- virtual std::string make_expanded(const App *sub) const;
-
- /// This prints out all the groups of options
- virtual std::string make_footer(const App *app) const;
-
- /// This displays the description line
- virtual std::string make_description(const App *app) const;
-
- /// This displays the usage line
- virtual std::string make_usage(const App *app, std::string name) const;
-
- /// This puts everything together
- std::string make_help(const App *, std::string, AppFormatMode) const override;
-
- ///@}
- /// @name Options
- ///@{
-
- /// This prints out an option help line, either positional or optional form
- virtual std::string make_option(const Option *opt, bool is_positional) const {
- std::stringstream out;
- detail::format_help(
- out, make_option_name(opt, is_positional) + make_option_opts(opt), make_option_desc(opt), column_width_);
- return out.str();
- }
-
- /// @brief This is the name part of an option, Default: left column
- virtual std::string make_option_name(const Option *, bool) const;
-
- /// @brief This is the options part of the name, Default: combined into left column
- virtual std::string make_option_opts(const Option *) const;
-
- /// @brief This is the description. Default: Right column, on new line if left column too large
- virtual std::string make_option_desc(const Option *) const;
-
- /// @brief This is used to print the name on the USAGE line
- virtual std::string make_option_usage(const Option *opt) const;
-
- ///@}
-};
-
-} // namespace CLI
-
-// From CLI/Option.hpp:
-
-namespace CLI {
-
-using results_t = std::vector<std::string>;
-using callback_t = std::function<bool(results_t)>;
-
-class Option;
-class App;
-
-using Option_p = std::unique_ptr<Option>;
-
-enum class MultiOptionPolicy { Throw, TakeLast, TakeFirst, Join };
-
-/// This is the CRTP base class for Option and OptionDefaults. It was designed this way
-/// to share parts of the class; an OptionDefaults can copy to an Option.
-template <typename CRTP> class OptionBase {
- friend App;
-
- protected:
- /// The group membership
- std::string group_ = std::string("Options");
-
- /// True if this is a required option
- bool required_{false};
-
- /// Ignore the case when matching (option, not value)
- bool ignore_case_{false};
-
- /// Allow this option to be given in a configuration file
- bool configurable_{true};
-
- /// Policy for multiple arguments when `expected_ == 1` (can be set on bool flags, too)
- MultiOptionPolicy multi_option_policy_{MultiOptionPolicy::Throw};
-
- /// Copy the contents to another similar class (one based on OptionBase)
- template <typename T> void copy_to(T *other) const {
- other->group(group_);
- other->required(required_);
- other->ignore_case(ignore_case_);
- other->configurable(configurable_);
- other->multi_option_policy(multi_option_policy_);
- }
-
- public:
- // setters
-
- /// Changes the group membership
- CRTP *group(std::string name) {
- group_ = name;
- return static_cast<CRTP *>(this);
- ;
- }
-
- /// Set the option as required
- CRTP *required(bool value = true) {
- required_ = value;
- return static_cast<CRTP *>(this);
- }
-
- /// Support Plumbum term
- CRTP *mandatory(bool value = true) { return required(value); }
-
- // Getters
-
- /// Get the group of this option
- const std::string &get_group() const { return group_; }
-
- /// True if this is a required option
- bool get_required() const { return required_; }
-
- /// The status of ignore case
- bool get_ignore_case() const { return ignore_case_; }
-
- /// The status of configurable
- bool get_configurable() const { return configurable_; }
-
- /// The status of the multi option policy
- MultiOptionPolicy get_multi_option_policy() const { return multi_option_policy_; }
-
- // Shortcuts for multi option policy
-
- /// Set the multi option policy to take last
- CRTP *take_last() {
- auto self = static_cast<CRTP *>(this);
- self->multi_option_policy(MultiOptionPolicy::TakeLast);
- return self;
- }
-
- /// Set the multi option policy to take last
- CRTP *take_first() {
- auto self = static_cast<CRTP *>(this);
- self->multi_option_policy(MultiOptionPolicy::TakeFirst);
- return self;
- }
-
- /// Set the multi option policy to take last
- CRTP *join() {
- auto self = static_cast<CRTP *>(this);
- self->multi_option_policy(MultiOptionPolicy::Join);
- return self;
- }
-
- /// Allow in a configuration file
- CRTP *configurable(bool value = true) {
- configurable_ = value;
- return static_cast<CRTP *>(this);
- }
-};
-
-/// This is a version of OptionBase that only supports setting values,
-/// for defaults. It is stored as the default option in an App.
-class OptionDefaults : public OptionBase<OptionDefaults> {
- public:
- OptionDefaults() = default;
-
- // Methods here need a different implementation if they are Option vs. OptionDefault
-
- /// Take the last argument if given multiple times
- OptionDefaults *multi_option_policy(MultiOptionPolicy value = MultiOptionPolicy::Throw) {
- multi_option_policy_ = value;
- return this;
- }
-
- /// Ignore the case of the option name
- OptionDefaults *ignore_case(bool value = true) {
- ignore_case_ = value;
- return this;
- }
-};
-
-class Option : public OptionBase<Option> {
- friend App;
-
- protected:
- /// @name Names
- ///@{
-
- /// A list of the short names (`-a`) without the leading dashes
- std::vector<std::string> snames_;
-
- /// A list of the long names (`--a`) without the leading dashes
- std::vector<std::string> lnames_;
-
- /// A positional name
- std::string pname_;
-
- /// If given, check the environment for this option
- std::string envname_;
-
- ///@}
- /// @name Help
- ///@{
-
- /// The description for help strings
- std::string description_;
-
- /// A human readable default value, usually only set if default is true in creation
- std::string defaultval_;
-
- /// A human readable type value, set when App creates this
- ///
- /// This is a lambda function so "types" can be dynamic, such as when a set prints its contents.
- std::function<std::string()> type_name_{[]() { return std::string(); }};
-
- /// True if this option has a default
- bool default_{false};
-
- ///@}
- /// @name Configuration
- ///@{
-
- /// The number of arguments that make up one option. -1=unlimited (vector-like), 0=flag, 1=normal option,
- /// 2=complex/pair, etc. Set only when the option is created; this is intrinsic to the type. Eventually, -2 may mean
- /// vector of pairs.
- int type_size_{1};
-
- /// The number of expected values, type_size_ must be < 0. Ignored for flag. N < 0 means at least -N values.
- int expected_{1};
-
- /// A list of validators to run on each value parsed
- std::vector<std::function<std::string(std::string &)>> validators_;
-
- /// A list of options that are required with this option
- std::set<Option *> requires_;
-
- /// A list of options that are excluded with this option
- std::set<Option *> excludes_;
-
- ///@}
- /// @name Other
- ///@{
-
- /// Remember the parent app
- App *parent_;
-
- /// Options store a callback to do all the work
- callback_t callback_;
-
- /// Options can short-circuit for help options or similar (called before parsing is validated)
- bool short_circuit_{false};
-
- ///@}
- /// @name Parsing results
- ///@{
-
- /// Results of parsing
- results_t results_;
-
- /// Whether the callback has run (needed for INI parsing)
- bool callback_run_{false};
-
- ///@}
-
- /// Making an option by hand is not defined, it must be made by the App class
- Option(
- std::string name, std::string description, std::function<bool(results_t)> callback, bool defaulted, App *parent)
- : description_(std::move(description)), default_(defaulted), parent_(parent),
- callback_(callback ? std::move(callback) : [](results_t) { return true; }) {
- std::tie(snames_, lnames_, pname_) = detail::get_names(detail::split_names(name));
- }
-
- public:
- /// @name Basic
- ///@{
-
- /// Count the total number of times an option was passed
- size_t count() const { return results_.size(); }
-
- /// True if the option was not passed
- size_t empty() const { return results_.empty(); }
-
- /// This class is true if option is passed.
- operator bool() const { return !empty(); }
-
- /// Clear the parsed results (mostly for testing)
- void clear() { results_.clear(); }
-
- ///@}
- /// @name Setting options
- ///@{
-
- /// Set the number of expected arguments (Flags don't use this)
- Option *expected(int value) {
- // Break if this is a flag
- if(type_size_ == 0)
- throw IncorrectConstruction::SetFlag(get_name(true, true));
-
- // Setting 0 is not allowed
- else if(value == 0)
- throw IncorrectConstruction::Set0Opt(get_name());
-
- // No change is okay, quit now
- else if(expected_ == value)
- return this;
-
- // Type must be a vector
- else if(type_size_ >= 0)
- throw IncorrectConstruction::ChangeNotVector(get_name());
-
- // TODO: Can support multioption for non-1 values (except for join)
- else if(value != 1 && multi_option_policy_ != MultiOptionPolicy::Throw)
- throw IncorrectConstruction::AfterMultiOpt(get_name());
-
- expected_ = value;
- return this;
- }
-
- /// Adds a validator with a built in type name
- Option *check(const Validator &validator) {
- validators_.emplace_back(validator.func);
- if(!validator.tname.empty())
- type_name(validator.tname);
- return this;
- }
-
- /// Adds a validator. Takes a const string& and returns an error message (empty if conversion/check is okay).
- Option *check(std::function<std::string(const std::string &)> validator) {
- validators_.emplace_back(validator);
- return this;
- }
-
- /// Adds a validator-like function that can change result
- Option *transform(std::function<std::string(std::string)> func) {
- validators_.emplace_back([func](std::string &inout) {
- try {
- inout = func(inout);
- } catch(const ValidationError &e) {
- return std::string(e.what());
- }
- return std::string();
- });
- return this;
- }
-
- /// Adds a user supplied function to run on each item passed in (communicate though lambda capture)
- Option *each(std::function<void(std::string)> func) {
- validators_.emplace_back([func](std::string &inout) {
- func(inout);
- return std::string();
- });
- return this;
- }
-
- /// Sets required options
- Option *needs(Option *opt) {
- auto tup = requires_.insert(opt);
- if(!tup.second)
- throw OptionAlreadyAdded::Requires(get_name(), opt->get_name());
- return this;
- }
-
- /// Can find a string if needed
- template <typename T = App> Option *needs(std::string opt_name) {
- for(const Option_p &opt : dynamic_cast<T *>(parent_)->options_)
- if(opt.get() != this && opt->check_name(opt_name))
- return needs(opt.get());
- throw IncorrectConstruction::MissingOption(opt_name);
- }
-
- /// Any number supported, any mix of string and Opt
- template <typename A, typename B, typename... ARG> Option *needs(A opt, B opt1, ARG... args) {
- needs(opt);
- return needs(opt1, args...);
- }
-
- /// Sets excluded options
- Option *excludes(Option *opt) {
- excludes_.insert(opt);
-
- // Help text should be symmetric - excluding a should exclude b
- opt->excludes_.insert(this);
-
- // Ignoring the insert return value, excluding twice is now allowed.
- // (Mostly to allow both directions to be excluded by user, even though the library does it for you.)
-
- return this;
- }
-
- /// Can find a string if needed
- template <typename T = App> Option *excludes(std::string opt_name) {
- for(const Option_p &opt : dynamic_cast<T *>(parent_)->options_)
- if(opt.get() != this && opt->check_name(opt_name))
- return excludes(opt.get());
- throw IncorrectConstruction::MissingOption(opt_name);
- }
-
- /// Any number supported, any mix of string and Opt
- template <typename A, typename B, typename... ARG> Option *excludes(A opt, B opt1, ARG... args) {
- excludes(opt);
- return excludes(opt1, args...);
- }
-
- /// Sets environment variable to read if no option given
- Option *envname(std::string name) {
- envname_ = name;
- return this;
- }
-
- /// Ignore case
- ///
- /// The template hides the fact that we don't have the definition of App yet.
- /// You are never expected to add an argument to the template here.
- template <typename T = App> Option *ignore_case(bool value = true) {
- ignore_case_ = value;
- auto *parent = dynamic_cast<T *>(parent_);
-
- for(const Option_p &opt : parent->options_)
- if(opt.get() != this && *opt == *this)
- throw OptionAlreadyAdded(opt->get_name(true, true));
-
- return this;
- }
-
- /// Take the last argument if given multiple times (or another policy)
- Option *multi_option_policy(MultiOptionPolicy value = MultiOptionPolicy::Throw) {
-
- if(get_items_expected() < 0)
- throw IncorrectConstruction::MultiOptionPolicy(get_name());
- multi_option_policy_ = value;
- return this;
- }
-
- /// Options with a short circuit set will run this function before parsing is finished.
- ///
- /// This is set on help functions, for example, to escape the normal validation.
- Option *short_circuit(bool value = true) {
- short_circuit_ = value;
- return this;
- }
-
- ///@}
- /// @name Accessors
- ///@{
-
- /// The number of arguments the option expects
- int get_type_size() const { return type_size_; }
-
- /// The environment variable associated to this value
- std::string get_envname() const { return envname_; }
-
- /// The set of options needed
- std::set<Option *> get_needs() const { return requires_; }
-
- /// The set of options excluded
- std::set<Option *> get_excludes() const { return excludes_; }
-
- /// The default value (for help printing)
- std::string get_defaultval() const { return defaultval_; }
-
- /// See if this is supposed to short circuit (skip validation, INI, etc) (Used for help flags)
- bool get_short_circuit() const { return short_circuit_; }
-
- /// Get the callback function
- callback_t get_callback() const { return callback_; }
-
- /// Get the long names
- const std::vector<std::string> get_lnames() const { return lnames_; }
-
- /// Get the short names
- const std::vector<std::string> get_snames() const { return snames_; }
-
- /// The number of times the option expects to be included
- int get_expected() const { return expected_; }
-
- /// \brief The total number of expected values (including the type)
- /// This is positive if exactly this number is expected, and negitive for at least N values
- ///
- /// v = fabs(size_type*expected)
- /// !MultiOptionPolicy::Throw
- /// | Expected < 0 | Expected == 0 | Expected > 0
- /// Size < 0 | -v | 0 | -v
- /// Size == 0 | 0 | 0 | 0
- /// Size > 0 | -v | 0 | -v // Expected must be 1
- ///
- /// MultiOptionPolicy::Throw
- /// | Expected < 0 | Expected == 0 | Expected > 0
- /// Size < 0 | -v | 0 | v
- /// Size == 0 | 0 | 0 | 0
- /// Size > 0 | v | 0 | v // Expected must be 1
- ///
- int get_items_expected() const {
- return std::abs(type_size_ * expected_) *
- ((multi_option_policy_ != MultiOptionPolicy::Throw || (expected_ < 0 && type_size_ < 0) ? -1 : 1));
- }
-
- /// True if this has a default value
- int get_default() const { return default_; }
-
- /// True if the argument can be given directly
- bool get_positional() const { return pname_.length() > 0; }
-
- /// True if option has at least one non-positional name
- bool nonpositional() const { return (snames_.size() + lnames_.size()) > 0; }
-
- /// True if option has description
- bool has_description() const { return description_.length() > 0; }
-
- /// Get the description
- const std::string &get_description() const { return description_; }
-
- ///@}
- /// @name Help tools
- ///@{
-
- /// \brief Gets a comma seperated list of names.
- /// Will include / prefer the positional name if positional is true.
- /// If all_options is false, pick just the most descriptive name to show.
- /// Use `get_name(true)` to get the positional name (replaces `get_pname`)
- std::string get_name(bool positional = false, //<[input] Show the positional name
- bool all_options = false //<[input] Show every option
- ) const {
-
- if(all_options) {
-
- std::vector<std::string> name_list;
-
- /// The all list wil never include a positional unless asked or that's the only name.
- if((positional && pname_.length()) || (snames_.empty() && lnames_.empty()))
- name_list.push_back(pname_);
-
- for(const std::string &sname : snames_)
- name_list.push_back("-" + sname);
-
- for(const std::string &lname : lnames_)
- name_list.push_back("--" + lname);
-
- return detail::join(name_list);
-
- } else {
-
- // This returns the positional name no matter what
- if(positional)
- return pname_;
-
- // Prefer long name
- else if(!lnames_.empty())
- return std::string("--") + lnames_[0];
-
- // Or short name if no long name
- else if(!snames_.empty())
- return std::string("-") + snames_[0];
-
- // If positional is the only name, it's okay to use that
- else
- return pname_;
- }
- }
-
- ///@}
- /// @name Parser tools
- ///@{
-
- /// Process the callback
- void run_callback() {
-
- // Run the validators (can change the string)
- if(!validators_.empty()) {
- for(std::string &result : results_)
- for(const std::function<std::string(std::string &)> &vali : validators_) {
- std::string err_msg = vali(result);
- if(!err_msg.empty())
- throw ValidationError(get_name(), err_msg);
- }
- }
-
- bool local_result;
-
- // Num items expected or length of vector, always at least 1
- // Only valid for a trimming policy
- int trim_size =
- std::min<int>(std::max<int>(std::abs(get_items_expected()), 1), static_cast<int>(results_.size()));
-
- // Operation depends on the policy setting
- if(multi_option_policy_ == MultiOptionPolicy::TakeLast) {
- // Allow multi-option sizes (including 0)
- results_t partial_result{results_.end() - trim_size, results_.end()};
- local_result = !callback_(partial_result);
-
- } else if(multi_option_policy_ == MultiOptionPolicy::TakeFirst) {
- results_t partial_result{results_.begin(), results_.begin() + trim_size};
- local_result = !callback_(partial_result);
-
- } else if(multi_option_policy_ == MultiOptionPolicy::Join) {
- results_t partial_result = {detail::join(results_, "\n")};
- local_result = !callback_(partial_result);
-
- } else {
- // Exact number required
- if(get_items_expected() > 0) {
- if(results_.size() != static_cast<size_t>(get_items_expected()))
- throw ArgumentMismatch(get_name(), get_items_expected(), results_.size());
- // Variable length list
- } else if(get_items_expected() < 0) {
- // Require that this be a multiple of expected size and at least as many as expected
- if(results_.size() < static_cast<size_t>(-get_items_expected()) ||
- results_.size() % static_cast<size_t>(std::abs(get_type_size())) != 0)
- throw ArgumentMismatch(get_name(), get_items_expected(), results_.size());
- }
- local_result = !callback_(results_);
- }
-
- if(local_result)
- throw ConversionError(get_name(), results_);
- }
-
- /// If options share any of the same names, they are equal (not counting positional)
- bool operator==(const Option &other) const {
- for(const std::string &sname : snames_)
- if(other.check_sname(sname))
- return true;
- for(const std::string &lname : lnames_)
- if(other.check_lname(lname))
- return true;
- // We need to do the inverse, just in case we are ignore_case
- for(const std::string &sname : other.snames_)
- if(check_sname(sname))
- return true;
- for(const std::string &lname : other.lnames_)
- if(check_lname(lname))
- return true;
- return false;
- }
-
- /// Check a name. Requires "-" or "--" for short / long, supports positional name
- bool check_name(std::string name) const {
-
- if(name.length() > 2 && name.substr(0, 2) == "--")
- return check_lname(name.substr(2));
- else if(name.length() > 1 && name.substr(0, 1) == "-")
- return check_sname(name.substr(1));
- else {
- std::string local_pname = pname_;
- if(ignore_case_) {
- local_pname = detail::to_lower(local_pname);
- name = detail::to_lower(name);
- }
- return name == local_pname;
- }
- }
-
- /// Requires "-" to be removed from string
- bool check_sname(std::string name) const {
- if(ignore_case_) {
- name = detail::to_lower(name);
- return std::find_if(std::begin(snames_), std::end(snames_), [&name](std::string local_sname) {
- return detail::to_lower(local_sname) == name;
- }) != std::end(snames_);
- } else
- return std::find(std::begin(snames_), std::end(snames_), name) != std::end(snames_);
- }
-
- /// Requires "--" to be removed from string
- bool check_lname(std::string name) const {
- if(ignore_case_) {
- name = detail::to_lower(name);
- return std::find_if(std::begin(lnames_), std::end(lnames_), [&name](std::string local_sname) {
- return detail::to_lower(local_sname) == name;
- }) != std::end(lnames_);
- } else
- return std::find(std::begin(lnames_), std::end(lnames_), name) != std::end(lnames_);
- }
-
- /// Puts a result at the end
- Option *add_result(std::string s) {
- results_.push_back(s);
- callback_run_ = false;
- return this;
- }
-
- /// Set the results vector all at once
- Option *set_results(std::vector<std::string> results) {
- results_ = results;
- callback_run_ = false;
- return this;
- }
-
- /// Get a copy of the results
- std::vector<std::string> results() const { return results_; }
-
- /// See if the callback has been run already
- bool get_callback_run() const { return callback_run_; }
-
- ///@}
- /// @name Custom options
- ///@{
-
- /// Set the type function to run when displayed on this option
- Option *type_name_fn(std::function<std::string()> typefun) {
- type_name_ = typefun;
- return this;
- }
-
- /// Set a custom option typestring
- Option *type_name(std::string typeval) {
- type_name_fn([typeval]() { return typeval; });
- return this;
- }
-
- /// Provided for backward compatibility \deprecated
- CLI11_DEPRECATED("Please use type_name instead")
- Option *set_type_name(std::string typeval) { return type_name(typeval); }
-
- /// Set a custom option size
- Option *type_size(int type_size) {
- type_size_ = type_size;
- if(type_size_ == 0)
- required_ = false;
- if(type_size < 0)
- expected_ = -1;
- return this;
- }
-
- /// Set the default value string representation
- Option *default_str(std::string val) {
- defaultval_ = val;
- return this;
- }
-
- /// Set the default value string representation and evaluate
- Option *default_val(std::string val) {
- default_str(val);
- auto old_results = results_;
- results_ = {val};
- run_callback();
- results_ = std::move(old_results);
- return this;
- }
-
- /// Get the typename for this option
- std::string get_type_name() const { return type_name_(); }
-};
-
-} // namespace CLI
-
-// From CLI/App.hpp:
-
-namespace CLI {
-
-#ifndef CLI11_PARSE
-#define CLI11_PARSE(app, argc, argv) \
- try { \
- (app).parse((argc), (argv)); \
- } catch(const CLI::ParseError &e) { \
- return (app).exit(e); \
- }
-#endif
-
-namespace detail {
-enum class Classifer { NONE, POSITIONAL_MARK, SHORT, LONG, SUBCOMMAND };
-struct AppFriend;
-} // namespace detail
-
-namespace FailureMessage {
-std::string simple(const App *app, const Error &e);
-std::string help(const App *app, const Error &e);
-} // namespace FailureMessage
-
-class App;
-
-using App_p = std::unique_ptr<App>;
-
-/// Creates a command line program, with very few defaults.
-/** To use, create a new `Program()` instance with `argc`, `argv`, and a help description. The templated
- * add_option methods make it easy to prepare options. Remember to call `.start` before starting your
- * program, so that the options can be evaluated and the help option doesn't accidentally run your program. */
-class App {
- friend Option;
- friend detail::AppFriend;
-
- protected:
- // This library follows the Google style guide for member names ending in underscores
-
- /// @name Basics
- ///@{
-
- /// Subcommand name or program name (from parser if name is empty)
- std::string name_;
-
- /// Description of the current program/subcommand
- std::string description_;
-
- /// If true, allow extra arguments (ie, don't throw an error). INHERITABLE
- bool allow_extras_{false};
-
- /// If true, allow extra arguments in the ini file (ie, don't throw an error). INHERITABLE
- bool allow_config_extras_{false};
-
- /// If true, return immediately on an unrecognised option (implies allow_extras) INHERITABLE
- bool prefix_command_{false};
-
- /// This is a function that runs when complete. Great for subcommands. Can throw.
- std::function<void()> callback_;
-
- ///@}
- /// @name Options
- ///@{
-
- /// The default values for options, customizable and changeable INHERITABLE
- OptionDefaults option_defaults_;
-
- /// The list of options, stored locally
- std::vector<Option_p> options_;
-
- ///@}
- /// @name Help
- ///@{
-
- /// Footer to put after all options in the help output INHERITABLE
- std::string footer_;
-
- /// A pointer to the help flag if there is one INHERITABLE
- Option *help_ptr_{nullptr};
-
- /// A pointer to the help all flag if there is one INHERITABLE
- Option *help_all_ptr_{nullptr};
-
- /// This is the formatter for help printing. Default provided. INHERITABLE (same pointer)
- std::shared_ptr<FormatterBase> formatter_{new Formatter()};
-
- /// The error message printing function INHERITABLE
- std::function<std::string(const App *, const Error &e)> failure_message_ = FailureMessage::simple;
-
- ///@}
- /// @name Parsing
- ///@{
-
- using missing_t = std::vector<std::pair<detail::Classifer, std::string>>;
-
- /// Pair of classifier, string for missing options. (extra detail is removed on returning from parse)
- ///
- /// This is faster and cleaner than storing just a list of strings and reparsing. This may contain the -- separator.
- missing_t missing_;
-
- /// This is a list of pointers to options with the original parse order
- std::vector<Option *> parse_order_;
-
- /// This is a list of the subcommands collected, in order
- std::vector<App *> parsed_subcommands_;
-
- ///@}
- /// @name Subcommands
- ///@{
-
- /// Storage for subcommand list
- std::vector<App_p> subcommands_;
-
- /// If true, the program name is not case sensitive INHERITABLE
- bool ignore_case_{false};
-
- /// Allow subcommand fallthrough, so that parent commands can collect commands after subcommand. INHERITABLE
- bool fallthrough_{false};
-
- /// A pointer to the parent if this is a subcommand
- App *parent_{nullptr};
-
- /// True if this command/subcommand was parsed
- bool parsed_{false};
-
- /// Minimum required subcommands (not inheritable!)
- size_t require_subcommand_min_ = 0;
-
- /// Max number of subcommands allowed (parsing stops after this number). 0 is unlimited INHERITABLE
- size_t require_subcommand_max_ = 0;
-
- /// The group membership INHERITABLE
- std::string group_{"Subcommands"};
-
- ///@}
- /// @name Config
- ///@{
-
- /// The name of the connected config file
- std::string config_name_;
-
- /// True if ini is required (throws if not present), if false simply keep going.
- bool config_required_{false};
-
- /// Pointer to the config option
- Option *config_ptr_{nullptr};
-
- /// This is the formatter for help printing. Default provided. INHERITABLE (same pointer)
- std::shared_ptr<Config> config_formatter_{new ConfigINI()};
-
- ///@}
-
- /// Special private constructor for subcommand
- App(std::string description_, std::string name, App *parent)
- : name_(std::move(name)), description_(std::move(description_)), parent_(parent) {
- // Inherit if not from a nullptr
- if(parent_ != nullptr) {
- if(parent_->help_ptr_ != nullptr)
- set_help_flag(parent_->help_ptr_->get_name(false, true), parent_->help_ptr_->get_description());
- if(parent_->help_all_ptr_ != nullptr)
- set_help_all_flag(parent_->help_all_ptr_->get_name(false, true),
- parent_->help_all_ptr_->get_description());
-
- /// OptionDefaults
- option_defaults_ = parent_->option_defaults_;
-
- // INHERITABLE
- failure_message_ = parent_->failure_message_;
- allow_extras_ = parent_->allow_extras_;
- allow_config_extras_ = parent_->allow_config_extras_;
- prefix_command_ = parent_->prefix_command_;
- ignore_case_ = parent_->ignore_case_;
- fallthrough_ = parent_->fallthrough_;
- group_ = parent_->group_;
- footer_ = parent_->footer_;
- formatter_ = parent_->formatter_;
- config_formatter_ = parent_->config_formatter_;
- require_subcommand_max_ = parent_->require_subcommand_max_;
- }
- }
-
- public:
- /// @name Basic
- ///@{
-
- /// Create a new program. Pass in the same arguments as main(), along with a help string.
- explicit App(std::string description_ = "", std::string name = "") : App(description_, name, nullptr) {
- set_help_flag("-h,--help", "Print this help message and exit");
- }
-
- /// virtual destructor
- virtual ~App() = default;
-
- /// Set a callback for the end of parsing.
- ///
- /// Due to a bug in c++11,
- /// it is not possible to overload on std::function (fixed in c++14
- /// and backported to c++11 on newer compilers). Use capture by reference
- /// to get a pointer to App if needed.
- App *callback(std::function<void()> callback) {
- callback_ = callback;
- return this;
- }
-
- /// Set a name for the app (empty will use parser to set the name)
- App *name(std::string name = "") {
- name_ = name;
- return this;
- }
-
- /// Remove the error when extras are left over on the command line.
- App *allow_extras(bool allow = true) {
- allow_extras_ = allow;
- return this;
- }
-
- /// Remove the error when extras are left over on the command line.
- /// Will also call App::allow_extras().
- App *allow_config_extras(bool allow = true) {
- allow_extras(allow);
- allow_config_extras_ = allow;
- return this;
- }
-
- /// Do not parse anything after the first unrecognised option and return
- App *prefix_command(bool allow = true) {
- prefix_command_ = allow;
- return this;
- }
-
- /// Ignore case. Subcommand inherit value.
- App *ignore_case(bool value = true) {
- ignore_case_ = value;
- if(parent_ != nullptr) {
- for(const auto &subc : parent_->subcommands_) {
- if(subc.get() != this && (this->check_name(subc->name_) || subc->check_name(this->name_)))
- throw OptionAlreadyAdded(subc->name_);
- }
- }
- return this;
- }
-
- /// Set the help formatter
- App *formatter(std::shared_ptr<FormatterBase> fmt) {
- formatter_ = fmt;
- return this;
- }
-
- /// Set the help formatter
- App *formatter_fn(std::function<std::string(const App *, std::string, AppFormatMode)> fmt) {
- formatter_ = std::make_shared<FormatterLambda>(fmt);
- return this;
- }
-
- /// Set the config formatter
- App *config_formatter(std::shared_ptr<Config> fmt) {
- config_formatter_ = fmt;
- return this;
- }
-
- /// Check to see if this subcommand was parsed, true only if received on command line.
- bool parsed() const { return parsed_; }
-
- /// Get the OptionDefault object, to set option defaults
- OptionDefaults *option_defaults() { return &option_defaults_; }
-
- ///@}
- /// @name Adding options
- ///@{
-
- /// Add an option, will automatically understand the type for common types.
- ///
- /// To use, create a variable with the expected type, and pass it in after the name.
- /// After start is called, you can use count to see if the value was passed, and
- /// the value will be initialized properly. Numbers, vectors, and strings are supported.
- ///
- /// ->required(), ->default, and the validators are options,
- /// The positional options take an optional number of arguments.
- ///
- /// For example,
- ///
- /// std::string filename;
- /// program.add_option("filename", filename, "description of filename");
- ///
- Option *add_option(std::string name, callback_t callback, std::string description = "", bool defaulted = false) {
- Option myopt{name, description, callback, defaulted, this};
-
- if(std::find_if(std::begin(options_), std::end(options_), [&myopt](const Option_p &v) {
- return *v == myopt;
- }) == std::end(options_)) {
- options_.emplace_back();
- Option_p &option = options_.back();
- option.reset(new Option(name, description, callback, defaulted, this));
- option_defaults_.copy_to(option.get());
- return option.get();
- } else
- throw OptionAlreadyAdded(myopt.get_name());
- }
-
- /// Add option for non-vectors (duplicate copy needed without defaulted to avoid `iostream << value`)
- template <typename T, enable_if_t<!is_vector<T>::value, detail::enabler> = detail::dummy>
- Option *add_option(std::string name,
- T &variable, ///< The variable to set
- std::string description = "") {
-
- CLI::callback_t fun = [&variable](CLI::results_t res) { return detail::lexical_cast(res[0], variable); };
-
- Option *opt = add_option(name, fun, description, false);
- opt->type_name(detail::type_name<T>());
- return opt;
- }
-
- /// Add option for non-vectors with a default print
- template <typename T, enable_if_t<!is_vector<T>::value, detail::enabler> = detail::dummy>
- Option *add_option(std::string name,
- T &variable, ///< The variable to set
- std::string description,
- bool defaulted) {
-
- CLI::callback_t fun = [&variable](CLI::results_t res) { return detail::lexical_cast(res[0], variable); };
-
- Option *opt = add_option(name, fun, description, defaulted);
- opt->type_name(detail::type_name<T>());
- if(defaulted) {
- std::stringstream out;
- out << variable;
- opt->default_str(out.str());
- }
- return opt;
- }
-
- /// Add option for vectors (no default)
- template <typename T>
- Option *add_option(std::string name,
- std::vector<T> &variable, ///< The variable vector to set
- std::string description = "") {
-
- CLI::callback_t fun = [&variable](CLI::results_t res) {
- bool retval = true;
- variable.clear();
- for(const auto &a : res) {
- variable.emplace_back();
- retval &= detail::lexical_cast(a, variable.back());
- }
- return (!variable.empty()) && retval;
- };
-
- Option *opt = add_option(name, fun, description, false);
- opt->type_name(detail::type_name<T>())->type_size(-1);
- return opt;
- }
-
- /// Add option for vectors
- template <typename T>
- Option *add_option(std::string name,
- std::vector<T> &variable, ///< The variable vector to set
- std::string description,
- bool defaulted) {
-
- CLI::callback_t fun = [&variable](CLI::results_t res) {
- bool retval = true;
- variable.clear();
- for(const auto &a : res) {
- variable.emplace_back();
- retval &= detail::lexical_cast(a, variable.back());
- }
- return (!variable.empty()) && retval;
- };
-
- Option *opt = add_option(name, fun, description, defaulted);
- opt->type_name(detail::type_name<T>())->type_size(-1);
- if(defaulted)
- opt->default_str("[" + detail::join(variable) + "]");
- return opt;
- }
-
- /// Set a help flag, replace the existing one if present
- Option *set_help_flag(std::string name = "", std::string description = "") {
- if(help_ptr_ != nullptr) {
- remove_option(help_ptr_);
- help_ptr_ = nullptr;
- }
-
- // Empty name will simply remove the help flag
- if(!name.empty()) {
- help_ptr_ = add_flag_function(name, [](size_t) -> void { throw CallForHelp(); }, description);
- help_ptr_->short_circuit(true);
- help_ptr_->configurable(false);
- }
-
- return help_ptr_;
- }
-
- /// Set a help all flag, replaced the existing one if present
- Option *set_help_all_flag(std::string name = "", std::string description = "") {
- if(help_all_ptr_ != nullptr) {
- remove_option(help_all_ptr_);
- help_all_ptr_ = nullptr;
- }
-
- // Empty name will simply remove the help all flag
- if(!name.empty()) {
- help_all_ptr_ = add_flag_function(name, [](size_t) -> void { throw CallForAllHelp(); }, description);
- help_all_ptr_->short_circuit(true);
- help_all_ptr_->configurable(false);
- }
-
- return help_all_ptr_;
- }
-
- /// Add option for flag
- Option *add_flag(std::string name, std::string description = "") {
- CLI::callback_t fun = [](CLI::results_t) { return true; };
-
- Option *opt = add_option(name, fun, description, false);
- if(opt->get_positional())
- throw IncorrectConstruction::PositionalFlag(name);
- opt->type_size(0);
- return opt;
- }
-
- /// Add option for flag integer
- template <typename T,
- enable_if_t<std::is_integral<T>::value && !is_bool<T>::value, detail::enabler> = detail::dummy>
- Option *add_flag(std::string name,
- T &count, ///< A variable holding the count
- std::string description = "") {
-
- count = 0;
- CLI::callback_t fun = [&count](CLI::results_t res) {
- count = static_cast<T>(res.size());
- return true;
- };
-
- Option *opt = add_option(name, fun, description, false);
- if(opt->get_positional())
- throw IncorrectConstruction::PositionalFlag(name);
- opt->type_size(0);
- return opt;
- }
-
- /// Bool version - defaults to allowing multiple passings, but can be forced to one if
- /// `multi_option_policy(CLI::MultiOptionPolicy::Throw)` is used.
- template <typename T, enable_if_t<is_bool<T>::value, detail::enabler> = detail::dummy>
- Option *add_flag(std::string name,
- T &count, ///< A variable holding true if passed
- std::string description = "") {
-
- count = false;
- CLI::callback_t fun = [&count](CLI::results_t res) {
- count = true;
- return res.size() == 1;
- };
-
- Option *opt = add_option(name, fun, description, false);
- if(opt->get_positional())
- throw IncorrectConstruction::PositionalFlag(name);
- opt->type_size(0);
- opt->multi_option_policy(CLI::MultiOptionPolicy::TakeLast);
- return opt;
- }
-
- /// Add option for callback
- Option *add_flag_function(std::string name,
- std::function<void(size_t)> function, ///< A function to call, void(size_t)
- std::string description = "") {
-
- CLI::callback_t fun = [function](CLI::results_t res) {
- auto count = static_cast<size_t>(res.size());
- function(count);
- return true;
- };
-
- Option *opt = add_option(name, fun, description, false);
- if(opt->get_positional())
- throw IncorrectConstruction::PositionalFlag(name);
- opt->type_size(0);
- return opt;
- }
-
-#ifdef CLI11_CPP14
- /// Add option for callback (C++14 or better only)
- Option *add_flag(std::string name,
- std::function<void(size_t)> function, ///< A function to call, void(size_t)
- std::string description = "") {
- return add_flag_function(name, function, description);
- }
-#endif
-
- /// Add set of options (No default, temp refernce, such as an inline set)
- template <typename T>
- Option *add_set(std::string name,
- T &member, ///< The selected member of the set
- const std::set<T> &&options, ///< The set of possibilities
- std::string description = "") {
-
- std::string simple_name = CLI::detail::split(name, ',').at(0);
- CLI::callback_t fun = [&member, options, simple_name](CLI::results_t res) {
- bool retval = detail::lexical_cast(res[0], member);
- if(!retval)
- throw ConversionError(res[0], simple_name);
- return std::find(std::begin(options), std::end(options), member) != std::end(options);
- };
-
- Option *opt = add_option(name, fun, description, false);
- std::string typeval = detail::type_name<T>();
- typeval += " in {" + detail::join(options) + "}";
- opt->type_name(typeval);
- return opt;
- }
-
- /// Add set of options (No default, non-temp refernce, such as an existing set)
- template <typename T>
- Option *add_set(std::string name,
- T &member, ///< The selected member of the set
- const std::set<T> &options, ///< The set of possibilities
- std::string description = "") {
-
- std::string simple_name = CLI::detail::split(name, ',').at(0);
- CLI::callback_t fun = [&member, &options, simple_name](CLI::results_t res) {
- bool retval = detail::lexical_cast(res[0], member);
- if(!retval)
- throw ConversionError(res[0], simple_name);
- return std::find(std::begin(options), std::end(options), member) != std::end(options);
- };
-
- Option *opt = add_option(name, fun, description, false);
- opt->type_name_fn(
- [&options]() { return std::string(detail::type_name<T>()) + " in {" + detail::join(options) + "}"; });
-
- return opt;
- }
-
- /// Add set of options (with default, R value, such as an inline set)
- template <typename T>
- Option *add_set(std::string name,
- T &member, ///< The selected member of the set
- const std::set<T> &&options, ///< The set of posibilities
- std::string description,
- bool defaulted) {
-
- std::string simple_name = CLI::detail::split(name, ',').at(0);
- CLI::callback_t fun = [&member, options, simple_name](CLI::results_t res) {
- bool retval = detail::lexical_cast(res[0], member);
- if(!retval)
- throw ConversionError(res[0], simple_name);
- return std::find(std::begin(options), std::end(options), member) != std::end(options);
- };
-
- Option *opt = add_option(name, fun, description, defaulted);
- std::string typeval = detail::type_name<T>();
- typeval += " in {" + detail::join(options) + "}";
- opt->type_name(typeval);
- if(defaulted) {
- std::stringstream out;
- out << member;
- opt->default_str(out.str());
- }
- return opt;
- }
-
- /// Add set of options (with default, L value refernce, such as an existing set)
- template <typename T>
- Option *add_set(std::string name,
- T &member, ///< The selected member of the set
- const std::set<T> &options, ///< The set of posibilities
- std::string description,
- bool defaulted) {
-
- std::string simple_name = CLI::detail::split(name, ',').at(0);
- CLI::callback_t fun = [&member, &options, simple_name](CLI::results_t res) {
- bool retval = detail::lexical_cast(res[0], member);
- if(!retval)
- throw ConversionError(res[0], simple_name);
- return std::find(std::begin(options), std::end(options), member) != std::end(options);
- };
-
- Option *opt = add_option(name, fun, description, defaulted);
- opt->type_name_fn(
- [&options]() { return std::string(detail::type_name<T>()) + " in {" + detail::join(options) + "}"; });
- if(defaulted) {
- std::stringstream out;
- out << member;
- opt->default_str(out.str());
- }
- return opt;
- }
-
- /// Add set of options, string only, ignore case (no default, R value)
- Option *add_set_ignore_case(std::string name,
- std::string &member, ///< The selected member of the set
- const std::set<std::string> &&options, ///< The set of possibilities
- std::string description = "") {
-
- std::string simple_name = CLI::detail::split(name, ',').at(0);
- CLI::callback_t fun = [&member, options, simple_name](CLI::results_t res) {
- member = detail::to_lower(res[0]);
- auto iter = std::find_if(std::begin(options), std::end(options), [&member](std::string val) {
- return detail::to_lower(val) == member;
- });
- if(iter == std::end(options))
- throw ConversionError(member, simple_name);
- else {
- member = *iter;
- return true;
- }
- };
-
- Option *opt = add_option(name, fun, description, false);
- std::string typeval = detail::type_name<std::string>();
- typeval += " in {" + detail::join(options) + "}";
- opt->type_name(typeval);
-
- return opt;
- }
-
- /// Add set of options, string only, ignore case (no default, L value)
- Option *add_set_ignore_case(std::string name,
- std::string &member, ///< The selected member of the set
- const std::set<std::string> &options, ///< The set of possibilities
- std::string description = "") {
-
- std::string simple_name = CLI::detail::split(name, ',').at(0);
- CLI::callback_t fun = [&member, &options, simple_name](CLI::results_t res) {
- member = detail::to_lower(res[0]);
- auto iter = std::find_if(std::begin(options), std::end(options), [&member](std::string val) {
- return detail::to_lower(val) == member;
- });
- if(iter == std::end(options))
- throw ConversionError(member, simple_name);
- else {
- member = *iter;
- return true;
- }
- };
-
- Option *opt = add_option(name, fun, description, false);
- opt->type_name_fn([&options]() {
- return std::string(detail::type_name<std::string>()) + " in {" + detail::join(options) + "}";
- });
-
- return opt;
- }
-
- /// Add set of options, string only, ignore case (default, R value)
- Option *add_set_ignore_case(std::string name,
- std::string &member, ///< The selected member of the set
- const std::set<std::string> &&options, ///< The set of posibilities
- std::string description,
- bool defaulted) {
-
- std::string simple_name = CLI::detail::split(name, ',').at(0);
- CLI::callback_t fun = [&member, options, simple_name](CLI::results_t res) {
- member = detail::to_lower(res[0]);
- auto iter = std::find_if(std::begin(options), std::end(options), [&member](std::string val) {
- return detail::to_lower(val) == member;
- });
- if(iter == std::end(options))
- throw ConversionError(member, simple_name);
- else {
- member = *iter;
- return true;
- }
- };
-
- Option *opt = add_option(name, fun, description, defaulted);
- std::string typeval = detail::type_name<std::string>();
- typeval += " in {" + detail::join(options) + "}";
- opt->type_name(typeval);
- if(defaulted) {
- opt->default_str(member);
- }
- return opt;
- }
-
- /// Add set of options, string only, ignore case (default, L value)
- Option *add_set_ignore_case(std::string name,
- std::string &member, ///< The selected member of the set
- const std::set<std::string> &options, ///< The set of posibilities
- std::string description,
- bool defaulted) {
-
- std::string simple_name = CLI::detail::split(name, ',').at(0);
- CLI::callback_t fun = [&member, &options, simple_name](CLI::results_t res) {
- member = detail::to_lower(res[0]);
- auto iter = std::find_if(std::begin(options), std::end(options), [&member](std::string val) {
- return detail::to_lower(val) == member;
- });
- if(iter == std::end(options))
- throw ConversionError(member, simple_name);
- else {
- member = *iter;
- return true;
- }
- };
-
- Option *opt = add_option(name, fun, description, defaulted);
- opt->type_name_fn([&options]() {
- return std::string(detail::type_name<std::string>()) + " in {" + detail::join(options) + "}";
- });
- if(defaulted) {
- opt->default_str(member);
- }
- return opt;
- }
-
- /// Add a complex number
- template <typename T>
- Option *add_complex(std::string name,
- T &variable,
- std::string description = "",
- bool defaulted = false,
- std::string label = "COMPLEX") {
-
- std::string simple_name = CLI::detail::split(name, ',').at(0);
- CLI::callback_t fun = [&variable, simple_name, label](results_t res) {
- if(res[1].back() == 'i')
- res[1].pop_back();
- double x, y;
- bool worked = detail::lexical_cast(res[0], x) && detail::lexical_cast(res[1], y);
- if(worked)
- variable = T(x, y);
- return worked;
- };
-
- CLI::Option *opt = add_option(name, fun, description, defaulted);
- opt->type_name(label)->type_size(2);
- if(defaulted) {
- std::stringstream out;
- out << variable;
- opt->default_str(out.str());
- }
- return opt;
- }
-
- /// Set a configuration ini file option, or clear it if no name passed
- Option *set_config(std::string name = "",
- std::string default_filename = "",
- std::string help = "Read an ini file",
- bool required = false) {
-
- // Remove existing config if present
- if(config_ptr_ != nullptr)
- remove_option(config_ptr_);
-
- // Only add config if option passed
- if(!name.empty()) {
- config_name_ = default_filename;
- config_required_ = required;
- config_ptr_ = add_option(name, config_name_, help, !default_filename.empty());
- config_ptr_->configurable(false);
- }
-
- return config_ptr_;
- }
-
- /// Removes an option from the App. Takes an option pointer. Returns true if found and removed.
- bool remove_option(Option *opt) {
- auto iterator =
- std::find_if(std::begin(options_), std::end(options_), [opt](const Option_p &v) { return v.get() == opt; });
- if(iterator != std::end(options_)) {
- options_.erase(iterator);
- return true;
- }
- return false;
- }
-
- ///@}
- /// @name Subcommmands
- ///@{
-
- /// Add a subcommand. Inherits INHERITABLE and OptionDefaults, and help flag
- App *add_subcommand(std::string name, std::string description = "") {
- subcommands_.emplace_back(new App(description, name, this));
- for(const auto &subc : subcommands_)
- if(subc.get() != subcommands_.back().get())
- if(subc->check_name(subcommands_.back()->name_) || subcommands_.back()->check_name(subc->name_))
- throw OptionAlreadyAdded(subc->name_);
- return subcommands_.back().get();
- }
-
- /// Check to see if a subcommand is part of this command (doesn't have to be in command line)
- App *get_subcommand(App *subcom) const {
- for(const App_p &subcomptr : subcommands_)
- if(subcomptr.get() == subcom)
- return subcom;
- throw OptionNotFound(subcom->get_name());
- }
-
- /// Check to see if a subcommand is part of this command (text version)
- App *get_subcommand(std::string subcom) const {
- for(const App_p &subcomptr : subcommands_)
- if(subcomptr->check_name(subcom))
- return subcomptr.get();
- throw OptionNotFound(subcom);
- }
-
- /// Changes the group membership
- App *group(std::string name) {
- group_ = name;
- return this;
- }
-
- /// The argumentless form of require subcommand requires 1 or more subcommands
- App *require_subcommand() {
- require_subcommand_min_ = 1;
- require_subcommand_max_ = 0;
- return this;
- }
-
- /// Require a subcommand to be given (does not affect help call)
- /// The number required can be given. Negative values indicate maximum
- /// number allowed (0 for any number). Max number inheritable.
- App *require_subcommand(int value) {
- if(value < 0) {
- require_subcommand_min_ = 0;
- require_subcommand_max_ = static_cast<size_t>(-value);
- } else {
- require_subcommand_min_ = static_cast<size_t>(value);
- require_subcommand_max_ = static_cast<size_t>(value);
- }
- return this;
- }
-
- /// Explicitly control the number of subcommands required. Setting 0
- /// for the max means unlimited number allowed. Max number inheritable.
- App *require_subcommand(size_t min, size_t max) {
- require_subcommand_min_ = min;
- require_subcommand_max_ = max;
- return this;
- }
-
- /// Stop subcommand fallthrough, so that parent commands cannot collect commands after subcommand.
- /// Default from parent, usually set on parent.
- App *fallthrough(bool value = true) {
- fallthrough_ = value;
- return this;
- }
-
- /// Check to see if this subcommand was parsed, true only if received on command line.
- /// This allows the subcommand to be directly checked.
- operator bool() const { return parsed_; }
-
- ///@}
- /// @name Extras for subclassing
- ///@{
-
- /// This allows subclasses to inject code before callbacks but after parse.
- ///
- /// This does not run if any errors or help is thrown.
- virtual void pre_callback() {}
-
- ///@}
- /// @name Parsing
- ///@{
- //
- /// Reset the parsed data
- void clear() {
-
- parsed_ = false;
- missing_.clear();
- parsed_subcommands_.clear();
-
- for(const Option_p &opt : options_) {
- opt->clear();
- }
- for(const App_p &app : subcommands_) {
- app->clear();
- }
- }
-
- /// Parses the command line - throws errors
- /// This must be called after the options are in but before the rest of the program.
- void parse(int argc, const char *const *argv) {
- // If the name is not set, read from command line
- if(name_.empty())
- name_ = argv[0];
-
- std::vector<std::string> args;
- for(int i = argc - 1; i > 0; i--)
- args.emplace_back(argv[i]);
- parse(args);
- }
-
- /// The real work is done here. Expects a reversed vector.
- /// Changes the vector to the remaining options.
- void parse(std::vector<std::string> &args) {
- // Clear if parsed
- if(parsed_)
- clear();
-
- // Redundant (set by _parse on commands/subcommands)
- // but placed here to make sure this is cleared when
- // running parse after an error is thrown, even by _validate.
- parsed_ = true;
-
- _validate();
- _parse(args);
- run_callback();
- }
-
- /// Provide a function to print a help message. The function gets access to the App pointer and error.
- void failure_message(std::function<std::string(const App *, const Error &e)> function) {
- failure_message_ = function;
- }
-
- /// Print a nice error message and return the exit code
- int exit(const Error &e, std::ostream &out = std::cout, std::ostream &err = std::cerr) const {
-
- /// Avoid printing anything if this is a CLI::RuntimeError
- if(dynamic_cast<const CLI::RuntimeError *>(&e) != nullptr)
- return e.get_exit_code();
-
- if(dynamic_cast<const CLI::CallForHelp *>(&e) != nullptr) {
- out << help();
- return e.get_exit_code();
- }
-
- if(dynamic_cast<const CLI::CallForAllHelp *>(&e) != nullptr) {
- out << help("", AppFormatMode::All);
- return e.get_exit_code();
- }
-
- if(e.get_exit_code() != static_cast<int>(ExitCodes::Success)) {
- if(failure_message_)
- err << failure_message_(this, e) << std::flush;
- }
-
- return e.get_exit_code();
- }
-
- ///@}
- /// @name Post parsing
- ///@{
-
- /// Counts the number of times the given option was passed.
- size_t count(std::string name) const {
- for(const Option_p &opt : options_) {
- if(opt->check_name(name)) {
- return opt->count();
- }
- }
- throw OptionNotFound(name);
- }
-
- /// Get a subcommand pointer list to the currently selected subcommands (after parsing by by default, in command
- /// line order; use parsed = false to get the original definition list.)
- std::vector<App *> get_subcommands() const { return parsed_subcommands_; }
-
- /// Get a filtered subcommand pointer list from the original definition list. An empty function will provide all
- /// subcommands (const)
- std::vector<const App *> get_subcommands(const std::function<bool(const App *)> &filter) const {
- std::vector<const App *> subcomms(subcommands_.size());
- std::transform(std::begin(subcommands_), std::end(subcommands_), std::begin(subcomms), [](const App_p &v) {
- return v.get();
- });
-
- if(filter) {
- subcomms.erase(std::remove_if(std::begin(subcomms),
- std::end(subcomms),
- [&filter](const App *app) { return !filter(app); }),
- std::end(subcomms));
- }
-
- return subcomms;
- }
-
- /// Get a filtered subcommand pointer list from the original definition list. An empty function will provide all
- /// subcommands
- std::vector<App *> get_subcommands(const std::function<bool(App *)> &filter) {
- std::vector<App *> subcomms(subcommands_.size());
- std::transform(std::begin(subcommands_), std::end(subcommands_), std::begin(subcomms), [](const App_p &v) {
- return v.get();
- });
-
- if(filter) {
- subcomms.erase(
- std::remove_if(std::begin(subcomms), std::end(subcomms), [&filter](App *app) { return !filter(app); }),
- std::end(subcomms));
- }
-
- return subcomms;
- }
-
- /// Check to see if given subcommand was selected
- bool got_subcommand(App *subcom) const {
- // get subcom needed to verify that this was a real subcommand
- return get_subcommand(subcom)->parsed_;
- }
-
- /// Check with name instead of pointer to see if subcommand was selected
- bool got_subcommand(std::string name) const { return get_subcommand(name)->parsed_; }
-
- ///@}
- /// @name Help
- ///@{
-
- /// Set footer.
- App *footer(std::string footer) {
- footer_ = footer;
- return this;
- }
-
- /// Produce a string that could be read in as a config of the current values of the App. Set default_also to include
- /// default arguments. Prefix will add a string to the beginning of each option.
- std::string config_to_str(bool default_also = false, bool write_description = false) const {
- return config_formatter_->to_config(this, default_also, write_description, "");
- }
-
- /// Makes a help message, using the currently configured formatter
- /// Will only do one subcommand at a time
- std::string help(std::string prev = "", AppFormatMode mode = AppFormatMode::Normal) const {
- if(prev.empty())
- prev = get_name();
- else
- prev += " " + get_name();
-
- // Delegate to subcommand if needed
- auto selected_subcommands = get_subcommands();
- if(!selected_subcommands.empty())
- return selected_subcommands.at(0)->help(prev);
- else
- return formatter_->make_help(this, prev, mode);
- }
-
- /// Provided for backwards compatibility \deprecated
- CLI11_DEPRECATED("Please use footer instead")
- App *set_footer(std::string msg) { return footer(msg); }
-
- /// Provided for backwards compatibility \deprecated
- CLI11_DEPRECATED("Please use name instead")
- App *set_name(std::string msg) { return name(msg); }
-
- /// Provided for backwards compatibility \deprecated
- CLI11_DEPRECATED("Please use callback instead")
- App *set_callback(std::function<void()> fn) { return callback(fn); }
-
- ///@}
- /// @name Getters
- ///@{
-
- /// Access the formatter
- std::shared_ptr<FormatterBase> get_formatter() const { return formatter_; }
-
- /// Access the config formatter
- std::shared_ptr<Config> get_config_formatter() const { return config_formatter_; }
-
- /// Get the app or subcommand description
- std::string get_description() const { return description_; }
-
- /// Get the list of options (user facing function, so returns raw pointers), has optional filter function
- std::vector<const Option *> get_options(const std::function<bool(const Option *)> filter = {}) const {
- std::vector<const Option *> options(options_.size());
- std::transform(std::begin(options_), std::end(options_), std::begin(options), [](const Option_p &val) {
- return val.get();
- });
-
- if(filter) {
- options.erase(std::remove_if(std::begin(options),
- std::end(options),
- [&filter](const Option *opt) { return !filter(opt); }),
- std::end(options));
- }
-
- return options;
- }
-
- /// Get an option by name
- const Option *get_option(std::string name) const {
- for(const Option_p &opt : options_) {
- if(opt->check_name(name)) {
- return opt.get();
- }
- }
- throw OptionNotFound(name);
- }
-
- /// Get an option by name (non-const version)
- Option *get_option(std::string name) {
- for(Option_p &opt : options_) {
- if(opt->check_name(name)) {
- return opt.get();
- }
- }
- throw OptionNotFound(name);
- }
-
- /// Check the status of ignore_case
- bool get_ignore_case() const { return ignore_case_; }
-
- /// Check the status of fallthrough
- bool get_fallthrough() const { return fallthrough_; }
-
- /// Get the group of this subcommand
- const std::string &get_group() const { return group_; }
-
- /// Get footer.
- std::string get_footer() const { return footer_; }
-
- /// Get the required min subcommand value
- size_t get_require_subcommand_min() const { return require_subcommand_min_; }
-
- /// Get the required max subcommand value
- size_t get_require_subcommand_max() const { return require_subcommand_max_; }
-
- /// Get the prefix command status
- bool get_prefix_command() const { return prefix_command_; }
-
- /// Get the status of allow extras
- bool get_allow_extras() const { return allow_extras_; }
-
- /// Get the status of allow extras
- bool get_allow_config_extras() const { return allow_config_extras_; }
-
- /// Get a pointer to the help flag.
- Option *get_help_ptr() { return help_ptr_; }
-
- /// Get a pointer to the help flag. (const)
- const Option *get_help_ptr() const { return help_ptr_; }
-
- /// Get a pointer to the help all flag. (const)
- const Option *get_help_all_ptr() const { return help_all_ptr_; }
-
- /// Get a pointer to the config option.
- Option *get_config_ptr() { return config_ptr_; }
-
- /// Get a pointer to the config option. (const)
- const Option *get_config_ptr() const { return config_ptr_; }
-
- /// Get the parent of this subcommand (or nullptr if master app)
- App *get_parent() { return parent_; }
-
- /// Get the parent of this subcommand (or nullptr if master app) (const version)
- const App *get_parent() const { return parent_; }
-
- /// Get the name of the current app
- std::string get_name() const { return name_; }
-
- /// Check the name, case insensitive if set
- bool check_name(std::string name_to_check) const {
- std::string local_name = name_;
- if(ignore_case_) {
- local_name = detail::to_lower(name_);
- name_to_check = detail::to_lower(name_to_check);
- }
-
- return local_name == name_to_check;
- }
-
- /// Get the groups available directly from this option (in order)
- std::vector<std::string> get_groups() const {
- std::vector<std::string> groups;
-
- for(const Option_p &opt : options_) {
- // Add group if it is not already in there
- if(std::find(groups.begin(), groups.end(), opt->get_group()) == groups.end()) {
- groups.push_back(opt->get_group());
- }
- }
-
- return groups;
- }
-
- /// This gets a vector of pointers with the original parse order
- const std::vector<Option *> &parse_order() const { return parse_order_; }
-
- /// This returns the missing options from the current subcommand
- std::vector<std::string> remaining(bool recurse = false) const {
- std::vector<std::string> miss_list;
- for(const std::pair<detail::Classifer, std::string> &miss : missing_) {
- miss_list.push_back(std::get<1>(miss));
- }
-
- // Recurse into subcommands
- if(recurse) {
- for(const App *sub : parsed_subcommands_) {
- std::vector<std::string> output = sub->remaining(recurse);
- std::copy(std::begin(output), std::end(output), std::back_inserter(miss_list));
- }
- }
- return miss_list;
- }
-
- /// This returns the number of remaining options, minus the -- seperator
- size_t remaining_size(bool recurse = false) const {
- auto count = static_cast<size_t>(std::count_if(
- std::begin(missing_), std::end(missing_), [](const std::pair<detail::Classifer, std::string> &val) {
- return val.first != detail::Classifer::POSITIONAL_MARK;
- }));
- if(recurse) {
- for(const App_p &sub : subcommands_) {
- count += sub->remaining_size(recurse);
- }
- }
- return count;
- }
-
- ///@}
-
- protected:
- /// Check the options to make sure there are no conflicts.
- ///
- /// Currently checks to see if multiple positionals exist with -1 args
- void _validate() const {
- auto count = std::count_if(std::begin(options_), std::end(options_), [](const Option_p &opt) {
- return opt->get_items_expected() < 0 && opt->get_positional();
- });
- if(count > 1)
- throw InvalidError(name_);
- for(const App_p &app : subcommands_)
- app->_validate();
- }
-
- /// Internal function to run (App) callback, top down
- void run_callback() {
- pre_callback();
- if(callback_)
- callback_();
- for(App *subc : get_subcommands()) {
- subc->run_callback();
- }
- }
-
- /// Check to see if a subcommand is valid. Give up immediately if subcommand max has been reached.
- bool _valid_subcommand(const std::string &current) const {
- // Don't match if max has been reached - but still check parents
- if(require_subcommand_max_ != 0 && parsed_subcommands_.size() >= require_subcommand_max_) {
- return parent_ != nullptr && parent_->_valid_subcommand(current);
- }
-
- for(const App_p &com : subcommands_)
- if(com->check_name(current) && !*com)
- return true;
-
- // Check parent if exists, else return false
- return parent_ != nullptr && parent_->_valid_subcommand(current);
- }
-
- /// Selects a Classifier enum based on the type of the current argument
- detail::Classifer _recognize(const std::string &current) const {
- std::string dummy1, dummy2;
-
- if(current == "--")
- return detail::Classifer::POSITIONAL_MARK;
- if(_valid_subcommand(current))
- return detail::Classifer::SUBCOMMAND;
- if(detail::split_long(current, dummy1, dummy2))
- return detail::Classifer::LONG;
- if(detail::split_short(current, dummy1, dummy2))
- return detail::Classifer::SHORT;
- return detail::Classifer::NONE;
- }
-
- /// Internal parse function
- void _parse(std::vector<std::string> &args) {
- parsed_ = true;
- bool positional_only = false;
-
- while(!args.empty()) {
- _parse_single(args, positional_only);
- }
-
- for(const Option_p &opt : options_)
- if(opt->get_short_circuit() && opt->count() > 0)
- opt->run_callback();
-
- // Process an INI file
- if(config_ptr_ != nullptr) {
- if(*config_ptr_) {
- config_ptr_->run_callback();
- config_required_ = true;
- }
- if(!config_name_.empty()) {
- try {
- std::vector<ConfigItem> values = config_formatter_->from_file(config_name_);
- _parse_config(values);
- } catch(const FileError &) {
- if(config_required_)
- throw;
- }
- }
- }
-
- // Get envname options if not yet passed
- for(const Option_p &opt : options_) {
- if(opt->count() == 0 && !opt->envname_.empty()) {
- char *buffer = nullptr;
- std::string ename_string;
-
-#ifdef _MSC_VER
- // Windows version
- size_t sz = 0;
- if(_dupenv_s(&buffer, &sz, opt->envname_.c_str()) == 0 && buffer != nullptr) {
- ename_string = std::string(buffer);
- free(buffer);
- }
-#else
- // This also works on Windows, but gives a warning
- buffer = std::getenv(opt->envname_.c_str());
- if(buffer != nullptr)
- ename_string = std::string(buffer);
-#endif
-
- if(!ename_string.empty()) {
- opt->add_result(ename_string);
- }
- }
- }
-
- // Process callbacks
- for(const Option_p &opt : options_) {
- if(opt->count() > 0 && !opt->get_callback_run()) {
- opt->run_callback();
- }
- }
-
- // Verify required options
- for(const Option_p &opt : options_) {
- // Required or partially filled
- if(opt->get_required() || opt->count() != 0) {
- // Make sure enough -N arguments parsed (+N is already handled in parsing function)
- if(opt->get_items_expected() < 0 && opt->count() < static_cast<size_t>(-opt->get_items_expected()))
- throw ArgumentMismatch::AtLeast(opt->get_name(), -opt->get_items_expected());
-
- // Required but empty
- if(opt->get_required() && opt->count() == 0)
- throw RequiredError(opt->get_name());
- }
- // Requires
- for(const Option *opt_req : opt->requires_)
- if(opt->count() > 0 && opt_req->count() == 0)
- throw RequiresError(opt->get_name(), opt_req->get_name());
- // Excludes
- for(const Option *opt_ex : opt->excludes_)
- if(opt->count() > 0 && opt_ex->count() != 0)
- throw ExcludesError(opt->get_name(), opt_ex->get_name());
- }
-
- auto selected_subcommands = get_subcommands();
- if(require_subcommand_min_ > selected_subcommands.size())
- throw RequiredError::Subcommand(require_subcommand_min_);
-
- // Convert missing (pairs) to extras (string only)
- if(!(allow_extras_ || prefix_command_)) {
- size_t num_left_over = remaining_size();
- if(num_left_over > 0) {
- args = remaining(false);
- throw ExtrasError(args);
- }
- }
-
- if(parent_ == nullptr) {
- args = remaining(false);
- }
- }
-
- /// Parse one config param, return false if not found in any subcommand, remove if it is
- ///
- /// If this has more than one dot.separated.name, go into the subcommand matching it
- /// Returns true if it managed to find the option, if false you'll need to remove the arg manually.
- void _parse_config(std::vector<ConfigItem> &args) {
- for(ConfigItem item : args) {
- if(!_parse_single_config(item) && !allow_config_extras_)
- throw ConfigError::Extras(item.fullname());
- }
- }
-
- /// Fill in a single config option
- bool _parse_single_config(const ConfigItem &item, size_t level = 0) {
- if(level < item.parents.size()) {
- App *subcom;
- try {
- std::cout << item.parents.at(level) << std::endl;
- subcom = get_subcommand(item.parents.at(level));
- } catch(const OptionNotFound &) {
- return false;
- }
- return subcom->_parse_single_config(item, level + 1);
- }
-
- Option *op;
- try {
- op = get_option("--" + item.name);
- } catch(const OptionNotFound &) {
- // If the option was not present
- if(get_allow_config_extras())
- // Should we worry about classifying the extras properly?
- missing_.emplace_back(detail::Classifer::NONE, item.fullname());
- return false;
- }
-
- if(!op->get_configurable())
- throw ConfigError::NotConfigurable(item.fullname());
-
- if(op->empty()) {
- // Flag parsing
- if(op->get_type_size() == 0) {
- op->set_results(config_formatter_->to_flag(item));
- } else {
- op->set_results(item.inputs);
- op->run_callback();
- }
- }
-
- return true;
- }
-
- /// Parse "one" argument (some may eat more than one), delegate to parent if fails, add to missing if missing from
- /// master
- void _parse_single(std::vector<std::string> &args, bool &positional_only) {
-
- detail::Classifer classifer = positional_only ? detail::Classifer::NONE : _recognize(args.back());
- switch(classifer) {
- case detail::Classifer::POSITIONAL_MARK:
- missing_.emplace_back(classifer, args.back());
- args.pop_back();
- positional_only = true;
- break;
- case detail::Classifer::SUBCOMMAND:
- _parse_subcommand(args);
- break;
- case detail::Classifer::LONG:
- // If already parsed a subcommand, don't accept options_
- _parse_arg(args, true);
- break;
- case detail::Classifer::SHORT:
- // If already parsed a subcommand, don't accept options_
- _parse_arg(args, false);
- break;
- case detail::Classifer::NONE:
- // Probably a positional or something for a parent (sub)command
- _parse_positional(args);
- }
- }
-
- /// Count the required remaining positional arguments
- size_t _count_remaining_positionals(bool required = false) const {
- size_t retval = 0;
- for(const Option_p &opt : options_)
- if(opt->get_positional() && (!required || opt->get_required()) && opt->get_items_expected() > 0 &&
- static_cast<int>(opt->count()) < opt->get_items_expected())
- retval = static_cast<size_t>(opt->get_items_expected()) - opt->count();
-
- return retval;
- }
-
- /// Parse a positional, go up the tree to check
- void _parse_positional(std::vector<std::string> &args) {
-
- std::string positional = args.back();
- for(const Option_p &opt : options_) {
- // Eat options, one by one, until done
- if(opt->get_positional() &&
- (static_cast<int>(opt->count()) < opt->get_items_expected() || opt->get_items_expected() < 0)) {
-
- opt->add_result(positional);
- parse_order_.push_back(opt.get());
- args.pop_back();
- return;
- }
- }
-
- if(parent_ != nullptr && fallthrough_)
- return parent_->_parse_positional(args);
- else {
- args.pop_back();
- missing_.emplace_back(detail::Classifer::NONE, positional);
-
- if(prefix_command_) {
- while(!args.empty()) {
- missing_.emplace_back(detail::Classifer::NONE, args.back());
- args.pop_back();
- }
- }
- }
- }
-
- /// Parse a subcommand, modify args and continue
- ///
- /// Unlike the others, this one will always allow fallthrough
- void _parse_subcommand(std::vector<std::string> &args) {
- if(_count_remaining_positionals(/* required */ true) > 0)
- return _parse_positional(args);
- for(const App_p &com : subcommands_) {
- if(com->check_name(args.back())) {
- args.pop_back();
- if(std::find(std::begin(parsed_subcommands_), std::end(parsed_subcommands_), com.get()) ==
- std::end(parsed_subcommands_))
- parsed_subcommands_.push_back(com.get());
- com->_parse(args);
- return;
- }
- }
- if(parent_ != nullptr)
- return parent_->_parse_subcommand(args);
- else
- throw HorribleError("Subcommand " + args.back() + " missing");
- }
-
- /// Parse a short (false) or long (true) argument, must be at the top of the list
- void _parse_arg(std::vector<std::string> &args, bool second_dash) {
-
- detail::Classifer current_type = second_dash ? detail::Classifer::LONG : detail::Classifer::SHORT;
-
- std::string current = args.back();
-
- std::string name;
- std::string value;
- std::string rest;
-
- if(second_dash) {
- if(!detail::split_long(current, name, value))
- throw HorribleError("Long parsed but missing (you should not see this):" + args.back());
- } else {
- if(!detail::split_short(current, name, rest))
- throw HorribleError("Short parsed but missing! You should not see this");
- }
-
- auto op_ptr = std::find_if(std::begin(options_), std::end(options_), [name, second_dash](const Option_p &opt) {
- return second_dash ? opt->check_lname(name) : opt->check_sname(name);
- });
-
- // Option not found
- if(op_ptr == std::end(options_)) {
- // If a subcommand, try the master command
- if(parent_ != nullptr && fallthrough_)
- return parent_->_parse_arg(args, second_dash);
- // Otherwise, add to missing
- else {
- args.pop_back();
- missing_.emplace_back(current_type, current);
- return;
- }
- }
-
- args.pop_back();
-
- // Get a reference to the pointer to make syntax bearable
- Option_p &op = *op_ptr;
-
- int num = op->get_items_expected();
-
- // Make sure we always eat the minimum for unlimited vectors
- int collected = 0;
-
- // --this=value
- if(!value.empty()) {
- // If exact number expected
- if(num > 0)
- num--;
- op->add_result(value);
- parse_order_.push_back(op.get());
- collected += 1;
- } else if(num == 0) {
- op->add_result("");
- parse_order_.push_back(op.get());
- // -Trest
- } else if(!rest.empty()) {
- if(num > 0)
- num--;
- op->add_result(rest);
- parse_order_.push_back(op.get());
- rest = "";
- collected += 1;
- }
-
- // Unlimited vector parser
- if(num < 0) {
- while(!args.empty() && _recognize(args.back()) == detail::Classifer::NONE) {
- if(collected >= -num) {
- // We could break here for allow extras, but we don't
-
- // If any positionals remain, don't keep eating
- if(_count_remaining_positionals() > 0)
- break;
- }
- op->add_result(args.back());
- parse_order_.push_back(op.get());
- args.pop_back();
- collected++;
- }
-
- // Allow -- to end an unlimited list and "eat" it
- if(!args.empty() && _recognize(args.back()) == detail::Classifer::POSITIONAL_MARK)
- args.pop_back();
-
- } else {
- while(num > 0 && !args.empty()) {
- num--;
- std::string current_ = args.back();
- args.pop_back();
- op->add_result(current_);
- parse_order_.push_back(op.get());
- }
-
- if(num > 0) {
- throw ArgumentMismatch::TypedAtLeast(op->get_name(), num, op->get_type_name());
- }
- }
-
- if(!rest.empty()) {
- rest = "-" + rest;
- args.push_back(rest);
- }
- }
-};
-
-namespace FailureMessage {
-
-/// Printout a clean, simple message on error (the default in CLI11 1.5+)
-inline std::string simple(const App *app, const Error &e) {
- std::string header = std::string(e.what()) + "\n";
- if(app->get_help_ptr() != nullptr)
- header += "Run with " + app->get_help_ptr()->get_name() + " for more information.\n";
- return header;
-}
-
-/// Printout the full help string on error (if this fn is set, the old default for CLI11)
-inline std::string help(const App *app, const Error &e) {
- std::string header = std::string("ERROR: ") + e.get_name() + ": " + e.what() + "\n";
- header += app->help();
- return header;
-}
-
-} // namespace FailureMessage
-
-namespace detail {
-/// This class is simply to allow tests access to App's protected functions
-struct AppFriend {
-
- /// Wrap _parse_short, perfectly forward arguments and return
- template <typename... Args>
- static auto parse_arg(App *app, Args &&... args) ->
- typename std::result_of<decltype (&App::_parse_arg)(App, Args...)>::type {
- return app->_parse_arg(std::forward<Args>(args)...);
- }
-
- /// Wrap _parse_subcommand, perfectly forward arguments and return
- template <typename... Args>
- static auto parse_subcommand(App *app, Args &&... args) ->
- typename std::result_of<decltype (&App::_parse_subcommand)(App, Args...)>::type {
- return app->_parse_subcommand(std::forward<Args>(args)...);
- }
-};
-} // namespace detail
-
-} // namespace CLI
-
-// From CLI/Config.hpp:
-
-namespace CLI {
-
-inline std::string
-ConfigINI::to_config(const App *app, bool default_also, bool write_description, std::string prefix) const {
- std::stringstream out;
- for(const Option *opt : app->get_options({})) {
-
- // Only process option with a long-name and configurable
- if(!opt->get_lnames().empty() && opt->get_configurable()) {
- std::string name = prefix + opt->get_lnames()[0];
- std::string value;
-
- // Non-flags
- if(opt->get_type_size() != 0) {
-
- // If the option was found on command line
- if(opt->count() > 0)
- value = detail::ini_join(opt->results());
-
- // If the option has a default and is requested by optional argument
- else if(default_also && !opt->get_defaultval().empty())
- value = opt->get_defaultval();
- // Flag, one passed
- } else if(opt->count() == 1) {
- value = "true";
-
- // Flag, multiple passed
- } else if(opt->count() > 1) {
- value = std::to_string(opt->count());
-
- // Flag, not present
- } else if(opt->count() == 0 && default_also) {
- value = "false";
- }
-
- if(!value.empty()) {
- if(write_description && opt->has_description()) {
- if(static_cast<int>(out.tellp()) != 0) {
- out << std::endl;
- }
- out << "; " << detail::fix_newlines("; ", opt->get_description()) << std::endl;
- }
- out << name << "=" << value << std::endl;
- }
- }
- }
-
- for(const App *subcom : app->get_subcommands({}))
- out << to_config(subcom, default_also, write_description, prefix + subcom->get_name() + ".");
-
- return out.str();
-}
-
-} // namespace CLI
-
-// From CLI/Formatter.hpp:
-
-namespace CLI {
-
-inline std::string
-Formatter::make_group(std::string group, bool is_positional, std::vector<const Option *> opts) const {
- std::stringstream out;
-
- out << "\n" << group << ":\n";
- for(const Option *opt : opts) {
- out << make_option(opt, is_positional);
- }
-
- return out.str();
-}
-
-inline std::string Formatter::make_positionals(const App *app) const {
- std::vector<const Option *> opts =
- app->get_options([](const Option *opt) { return !opt->get_group().empty() && opt->get_positional(); });
-
- if(opts.empty())
- return std::string();
- else
- return make_group(get_label("Positionals"), true, opts);
-}
-
-inline std::string Formatter::make_groups(const App *app, AppFormatMode mode) const {
- std::stringstream out;
- std::vector<std::string> groups = app->get_groups();
-
- // Options
- for(const std::string &group : groups) {
- std::vector<const Option *> opts = app->get_options([app, mode, &group](const Option *opt) {
- return opt->get_group() == group // Must be in the right group
- && opt->nonpositional() // Must not be a positional
- && (mode != AppFormatMode::Sub // If mode is Sub, then
- || (app->get_help_ptr() != opt // Ignore help pointer
- && app->get_help_all_ptr() != opt)); // Ignore help all pointer
- });
- if(!group.empty() && !opts.empty()) {
- out << make_group(group, false, opts);
-
- if(group != groups.back())
- out << "\n";
- }
- }
-
- return out.str();
-}
-
-inline std::string Formatter::make_description(const App *app) const {
- std::string desc = app->get_description();
-
- if(!desc.empty())
- return desc + "\n";
- else
- return "";
-}
-
-inline std::string Formatter::make_usage(const App *app, std::string name) const {
- std::stringstream out;
-
- out << get_label("Usage") << ":" << (name.empty() ? "" : " ") << name;
-
- std::vector<std::string> groups = app->get_groups();
-
- // Print an Options badge if any options exist
- std::vector<const Option *> non_pos_options =
- app->get_options([](const Option *opt) { return opt->nonpositional(); });
- if(!non_pos_options.empty())
- out << " [" << get_label("OPTIONS") << "]";
-
- // Positionals need to be listed here
- std::vector<const Option *> positionals = app->get_options([](const Option *opt) { return opt->get_positional(); });
-
- // Print out positionals if any are left
- if(!positionals.empty()) {
- // Convert to help names
- std::vector<std::string> positional_names(positionals.size());
- std::transform(positionals.begin(), positionals.end(), positional_names.begin(), [this](const Option *opt) {
- return make_option_usage(opt);
- });
-
- out << " " << detail::join(positional_names, " ");
- }
-
- // Add a marker if subcommands are expected or optional
- if(!app->get_subcommands({}).empty()) {
- out << " " << (app->get_require_subcommand_min() == 0 ? "[" : "")
- << get_label(app->get_require_subcommand_max() < 2 || app->get_require_subcommand_min() > 1 ? "SUBCOMMAND"
- : "SUBCOMMANDS")
- << (app->get_require_subcommand_min() == 0 ? "]" : "");
- }
-
- out << std::endl;
-
- return out.str();
-}
-
-inline std::string Formatter::make_footer(const App *app) const {
- std::string footer = app->get_footer();
- if(!footer.empty())
- return footer + "\n";
- else
- return "";
-}
-
-inline std::string Formatter::make_help(const App *app, std::string name, AppFormatMode mode) const {
-
- // This immediatly forwards to the make_expanded method. This is done this way so that subcommands can
- // have overridden formatters
- if(mode == AppFormatMode::Sub)
- return make_expanded(app);
-
- std::stringstream out;
-
- out << make_description(app);
- out << make_usage(app, name);
- out << make_positionals(app);
- out << make_groups(app, mode);
- out << make_subcommands(app, mode);
- out << make_footer(app);
-
- return out.str();
-}
-
-inline std::string Formatter::make_subcommands(const App *app, AppFormatMode mode) const {
- std::stringstream out;
-
- std::vector<const App *> subcommands = app->get_subcommands({});
-
- // Make a list in definition order of the groups seen
- std::vector<std::string> subcmd_groups_seen;
- for(const App *com : subcommands) {
- std::string group_key = com->get_group();
- if(!group_key.empty() &&
- std::find_if(subcmd_groups_seen.begin(), subcmd_groups_seen.end(), [&group_key](std::string a) {
- return detail::to_lower(a) == detail::to_lower(group_key);
- }) == subcmd_groups_seen.end())
- subcmd_groups_seen.push_back(group_key);
- }
-
- // For each group, filter out and print subcommands
- for(const std::string &group : subcmd_groups_seen) {
- out << "\n" << group << ":\n";
- std::vector<const App *> subcommands_group = app->get_subcommands(
- [&group](const App *app) { return detail::to_lower(app->get_group()) == detail::to_lower(group); });
- for(const App *new_com : subcommands_group) {
- if(mode != AppFormatMode::All) {
- out << make_subcommand(new_com);
- } else {
- out << new_com->help(new_com->get_name(), AppFormatMode::Sub);
- if(new_com != subcommands_group.back())
- out << "\n";
- }
- }
- }
-
- return out.str();
-}
-
-inline std::string Formatter::make_subcommand(const App *sub) const {
- std::stringstream out;
- detail::format_help(out, sub->get_name(), sub->get_description(), column_width_);
- return out.str();
-}
-
-inline std::string Formatter::make_expanded(const App *sub) const {
- std::stringstream out;
- if(sub->get_description().empty())
- out << sub->get_name();
- else
- out << sub->get_name() << " -> " << sub->get_description();
- out << make_groups(sub, AppFormatMode::Sub);
- return out.str();
-}
-
-inline std::string Formatter::make_option_name(const Option *opt, bool is_positional) const {
- if(is_positional)
- return opt->get_name(true, false);
- else
- return opt->get_name(false, true);
-}
-
-inline std::string Formatter::make_option_opts(const Option *opt) const {
- std::stringstream out;
-
- if(opt->get_type_size() != 0) {
- if(!opt->get_type_name().empty())
- out << " " << get_label(opt->get_type_name());
- if(!opt->get_defaultval().empty())
- out << "=" << opt->get_defaultval();
- if(opt->get_expected() > 1)
- out << " x " << opt->get_expected();
- if(opt->get_expected() == -1)
- out << " ...";
- if(opt->get_required())
- out << " " << get_label("REQUIRED");
- }
- if(!opt->get_envname().empty())
- out << " (" << get_label("Env") << ":" << opt->get_envname() << ")";
- if(!opt->get_needs().empty()) {
- out << " " << get_label("Needs") << ":";
- for(const Option *op : opt->get_needs())
- out << " " << op->get_name();
- }
- if(!opt->get_excludes().empty()) {
- out << " " << get_label("Excludes") << ":";
- for(const Option *op : opt->get_excludes())
- out << " " << op->get_name();
- }
- return out.str();
-}
-
-inline std::string Formatter::make_option_desc(const Option *opt) const { return opt->get_description(); }
-
-inline std::string Formatter::make_option_usage(const Option *opt) const {
- // Note that these are positionals usages
- std::stringstream out;
- out << make_option_name(opt, true);
-
- if(opt->get_expected() > 1)
- out << "(" << std::to_string(opt->get_expected()) << "x)";
- else if(opt->get_expected() < 0)
- out << "...";
-
- return opt->get_required() ? out.str() : "[" + out.str() + "]";
-}
-
-} // namespace CLI
-
diff --git a/homework/81568/BF_Interpreter/Makefile b/homework/81568/BF_Interpreter/Makefile
deleted file mode 100644
index b430742..0000000
--- a/homework/81568/BF_Interpreter/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-bfi: main.cpp bf_interpreter.cpp
- g++ -o bfi main.cpp bf_interpreter.cpp
diff --git a/homework/81568/BF_Interpreter/README.md b/homework/81568/BF_Interpreter/README.md
deleted file mode 100644
index b8cde8b..0000000
--- a/homework/81568/BF_Interpreter/README.md
+++ /dev/null
@@ -1,40 +0,0 @@
-# Brainfuck-Interpreter
-Simple Brainfuck interpreter written for IPL course homework from FMI, SU, 2018.
-
-Uses default memory size of 30000 cells but if you define `#MEMSIZE` with your compiler to something else you can get different size.
-
-When either > or < instructions overflow the cell pointer, the latter just wraps
-around.
-
-# Installation
-BFI uses _make_ for make for simplicity.
-
-To install simply run:
-```
-make
-```
-
-# Usage
-```
-Usage: bfi [OPTIONS]
-
-Options:
- -h,--help Print this help message and exit
- -f,--file FILE Excludes: --code
- Brainfuck source file
- -c,--code TEXT Excludes: --file
- Brainfuck source code
- -o,--output TEXT File to write the Brainfuck output to. Optional.
- -i,--input FILE File to take the Brainfuck input from. Optional.
-```
-
-# Future
-BFI is planned to be made child-friendly by introducing new instructions like:
-
-* ! - make the current cell value equal to 0.
-* ^ - go to cell No. (current cell No. + current cell value).
-* & - go to cell No. (current cell No. - current cell value).
-* \# - if statement that depends on next value (for comparison) and previous (to use like ^)
-* $ - same as above, but go back, instead of forward.
-
-To be completely child-friendly change the name of the language to Brainmeddler.
diff --git a/homework/81568/BF_Interpreter/bf_interpreter.cpp b/homework/81568/BF_Interpreter/bf_interpreter.cpp
deleted file mode 100644
index 28d4c18..0000000
--- a/homework/81568/BF_Interpreter/bf_interpreter.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-#include "bf_interpreter.h"
-
-#include <cmath>
-#include <cstring>
-#include <iostream>
-#include <stack>
-
-#ifndef MEMSIZE
-#define MEMSIZE 30000
-#endif
-
-BFInterpreter::BFInterpreter(const char *program, std::istream &input, std::ostream &output) :
- memory_blocks(nullptr), p(nullptr),
- program(nullptr), input(input), output(output),
- memory_size(MEMSIZE) {
-
- this->program = new char[strlen(program) + 1];
- strncpy(this->program, program, strlen(program) + 1);
- pp = this->program;
-
- memory_blocks = new uchar[memory_size];
- for (int i = 0; i < memory_size; ++i) {
- memory_blocks[i] = 0;
- }
- p = memory_blocks;
-}
-
-BFInterpreter::~BFInterpreter() {
- delete [] memory_blocks;
- delete [] program;
-}
-
-void BFInterpreter::addMemory() {
- uchar *new_memory = new uchar[memory_size + ((size_t) log2(memory_size))];
- for (int i = 0; i < memory_size; ++i) {
- new_memory[i] = memory_blocks[i];
- }
- delete [] memory_blocks;
- memory_blocks = new_memory;
- memory_size += log2(memory_size);
-}
-
-void BFInterpreter::compile() {
- while (*pp) {
- switch (*pp) {
- case '[':
- ++pp;
- loop();
- break;
- case ']': // that will only happen if code is wrong
- printf("Syntax error!\n");
- return;
- default:
- proccessNonLoopCmd(*pp);
- }
- ++pp;
- }
- output.put('\n');
-}
-
-void BFInterpreter::loop() {
- std::stack<char*> loops;
- loops.push(pp);
-
- char *body = loops.top();
- while (!loops.empty()) {
- while (*body != ']' && *body != '[') {
- proccessNonLoopCmd(*body);
- ++body;
- }
- if (*body == ']') {
- if (!*p) { /* End of a loop */
- loops.pop();
- ++body;
- } else { /* Loop has not ended. Return to the beginning of the current loop */
- body = loops.top();
- }
- } else { /* Start of a new loop */
- loops.push(body + 1);
- ++body;
- }
- }
- pp = --body;
- return;
-}
-
-void BFInterpreter::proccessNonLoopCmd(char c) {
- switch (c) {
- case '+':
- ++*p;
- break;
- case '-':
- --*p;
- break;
- case '.':
- output.put(*p);
- break;
- case ',':
- *p = input.get();
- break;
- case '<':
- if (p == memory_blocks)
- p = memory_blocks + (memory_size - 1);
- else
- --p;
- break;
- case '>':
- if (p == memory_blocks + (memory_size - 1))
- p = memory_blocks;
- else
- ++p;
- break;
- }
-}
diff --git a/homework/81568/BF_Interpreter/bf_interpreter.h b/homework/81568/BF_Interpreter/bf_interpreter.h
deleted file mode 100644
index 9e355ff..0000000
--- a/homework/81568/BF_Interpreter/bf_interpreter.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef BRAINFUCK_INTERPRETER_H
-#define BRAINFUCK_INTERPRETER_H
-
-#include <cstddef>
-#include <iostream>
-
-
-class BFInterpreter {
-public:
- using uchar = unsigned char;
-
- BFInterpreter(const char *program, std::istream &input = std::cin, std::ostream &output = std::cout);
- ~BFInterpreter();
-
- void compile();
-
-private:
- void addMemory();
- void loop();
- void proccessNonLoopCmd(char c);
-
-private:
- std::istream &input;
- std::ostream &output;
- size_t memory_size;
-
- uchar *memory_blocks;
- uchar *p;
- char *program;
- char *pp;
-};
-
-#endif /* BRAINFUCK_INTERPRETER_H */
diff --git a/homework/81568/BF_Interpreter/main.cpp b/homework/81568/BF_Interpreter/main.cpp
deleted file mode 100644
index ccde7a5..0000000
--- a/homework/81568/BF_Interpreter/main.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-#include "bf_interpreter.h"
-#include "CLI11.hpp"
-
-#include <fstream>
-#include <iostream>
-#include <iterator>
-#include <sstream>
-#include <string>
-
-#define USAGE_MSG \
- "Usage %s [-f <code file> | -c <code>] (-i <input file>) (-o <output file>)\n" \
- "If no input/output file is provided standart input/output is used instead.\n"
-
-
-// TODO: implement proper CLI parsing
-// TODO: https://github.com/CLIUtils/CLI11
-int main(int argc, char **argv) {
- CLI::App app {"Simple Brainfuck interpreter written for "
- "IPL course homework from FMI, SU, 2018." };
-
- std::string srcFile;
- CLI::Option *srcFileOpt = app.add_option("-f,--file", srcFile, "Brainfuck source file");
-
- srcFileOpt->check(CLI::ExistingFile);
-
- std::string srcCode;
- CLI::Option *srcCodeOpt = app.add_option("-c,--code", srcCode, "Brainfuck source code");
-
- srcFileOpt->excludes(srcCodeOpt);
- srcCodeOpt->excludes(srcFileOpt);
-
- std::string output;
- CLI::Option *outputOpt = app.add_option("-o,--output", output, "File to write the Brainfuck output to. Optional.");
-
- std::string input;
- CLI::Option *inputOpt = app.add_option("-i,--input", input, "File to take the Brainfuck input from. Optional.");
-
- inputOpt->check(CLI::ExistingFile);
-
- CLI11_PARSE(app, argc, argv);
-
- std::string source;
- if (*srcFileOpt) {
- std::ifstream file {srcFile};
- if (file.is_open()) {
- source.assign((std::istreambuf_iterator<char>(file)),
- std::istreambuf_iterator<char>());
- }
- } else {
- source = srcCode;
- }
-
- std::ifstream inputFile;
- if (*inputOpt)
- inputFile.open(input);
-
- std::ofstream outputFile;
- if (*outputOpt)
- outputFile.open(output);
-
- std::istream &is = *inputOpt ? inputFile : std::cin;
- std::ostream &os = *outputOpt ? outputFile : std::cout;
-
- BFInterpreter bfi{source.c_str(), is, os};
- bfi.compile();
-
- return 0;
-}
diff --git a/homework/81568/c2html/.gitignore b/homework/81568/c2html/.gitignore
deleted file mode 100644
index c5a122e..0000000
--- a/homework/81568/c2html/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-lexcer
-TAGS
diff --git a/homework/81568/c2html/Makefile b/homework/81568/c2html/Makefile
deleted file mode 100644
index 2856500..0000000
--- a/homework/81568/c2html/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-lexcer: main.cpp lexcer.cpp cyclomatic.cpp html_utils.cpp
- g++ -o lexcer main.cpp lexcer.cpp cyclomatic.cpp html_utils.cpp
diff --git a/homework/81568/c2html/README.md b/homework/81568/c2html/README.md
deleted file mode 100644
index 8c31e72..0000000
--- a/homework/81568/c2html/README.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# c2HTML
- Kind of tokenizer for the 'C' Programming Language.
-
-# Install
- Pretty simple.
- ```bash
- make
- ```
diff --git a/homework/81568/c2html/cyclomatic.cpp b/homework/81568/c2html/cyclomatic.cpp
deleted file mode 100644
index b7b0c17..0000000
--- a/homework/81568/c2html/cyclomatic.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-#include "cyclomatic.h"
-#include "html_utils.h"
-#include "lexcer.h"
-#include "lexconst.h"
-#include <stack>
-
-using HTMLUtils::writeToOutput;
-using LexCer::TokenClass;
-using LexCer::Tokenizer;
-
-// Writing a full parser would give us the change of
-// making the cyclomatic graph of the function.
-// #courseproject
-unsigned ParCer::outputWithCyclomaticComplexity(FILE *in, FILE *out) {
- Tokenizer tokenizer (in, out);
-
- std::string lexeme;
- double number;
- TokenClass type;
- Token currentToken;
- std::stack<short> history;
- bool inFunction = false;
-
- #define PAREN false
- std::stack<bool> openedBlocks;
- std::string className = "a";
- unsigned counter = 1;
- unsigned complexity = 1;
-
- do {
- currentToken = tokenizer.nextToken(&lexeme, &number);
- type = currentToken.type;
-
- if (!inFunction) {
- history.push(type);
- } else {
- if (type == TokenClass::RightCurly) {
- if (openedBlocks.empty()) { // end of a function. What one does to avoid parsing 'C'
- inFunction = false;
- fputs("<!-- ", out);
- char closingDiv[100];
- sprintf(closingDiv, "%d --></div>", complexity);
- fputs(closingDiv, out);
- complexity = 1;
- } else {
- openedBlocks.pop();
- }
- }
- else if (type == TokenClass::LeftCurly) {
- openedBlocks.push(PAREN);
- }
- else if (type == TokenClass::Keyword) {
- if (!lexeme.compare("if") ||
- !lexeme.compare("while") ||
- !lexeme.compare("for") ||
- !lexeme.compare("case") ||
- !lexeme.compare("default"))
- {
- ++complexity;
- }
- }
- }
-
- if (!inFunction && type == TokenClass::LeftCurly) {
- history.pop();
- while (!history.empty() && history.top() == TokenClass::Skip) {
- history.pop();
- }
-
- if (history.top() == TokenClass::RightParen) {
- while (!history.empty() && history.top() != TokenClass::LeftParen)
- history.pop();
- if (!history.empty())
- history.pop();
- while (!history.empty() && history.top() == TokenClass::Skip)
- history.pop();
-
- if (!history.empty() && history.top() == TokenClass::Identifier) { // We are in a function
- char openingDiv[100];
- sprintf(openingDiv, "<div class=\"func\">", className.c_str());
- fputs(openingDiv, out);
- inFunction = true;
- history = std::stack<short>{};
- }
- }
- }
-
- if (!writeToOutput(out, currentToken))
- break;
- lexeme = "";
- number = 0.0;
- } while (type != TokenClass::Eof ||
- type != TokenClass::Invalid);
- return counter - 1;
-}
diff --git a/homework/81568/c2html/cyclomatic.h b/homework/81568/c2html/cyclomatic.h
deleted file mode 100644
index 29fdc1c..0000000
--- a/homework/81568/c2html/cyclomatic.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef CYCLOMATIC_H
-#define CYCLOMATIC_H
-
-#include <cstdio>
-
-// Given this
-// is 20,000 LOC, I'll probably leave parsing
-// 'C' as a course project
-// #courseproject
-
-// class Parser;
-
-namespace ParCer {
-
-unsigned outputWithCyclomaticComplexity(FILE *fpIn, FILE *fpOut);
-
-} /* Namespace ParCer */
-
-#endif /* CYCLOMATIC_H */
diff --git a/homework/81568/c2html/html_utils.cpp b/homework/81568/c2html/html_utils.cpp
deleted file mode 100644
index 6ca91c6..0000000
--- a/homework/81568/c2html/html_utils.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-#include "html_utils.h"
-#include "lexconst.h"
-
-namespace HTMLUtils {
-
-std::string escapeHTML(const std::string &lexeme) {
- std::string result;
- for (auto c : lexeme) {
- switch(c) {
- case '<':
- result.append("&lt");
- break;
- case '>':
- result.append("&gt");
- break;
- case '&':
- result.append("&amp");
- break;
- default:
- result.push_back(c);
- break;
- }
- }
- return result;
-}
-
-bool writeToOutput(FILE *out, Token token) {
- if (token.type == TokenClass::Eof) {
- printf("End of file!\n");
- fputc('\n', out);
- return false;
- }
-
- if (token.type == TokenClass::Skip) {
- if (fputs(token.lexeme.c_str(), out) == EOF) {
- printf("Error while writing to output");
- return false;
- }
- return true;
- }
-
- printf("Token of type %s at line %d: ", LexCer::tokenToClass.at(token.type).c_str(), token.line);
- if (token.type == TokenClass::Number)
- printf("%f\n", token.number);
- else
- printf("%s\n", token.lexeme.c_str());
-
- auto lexeme = escapeHTML(token.lexeme);
-
- std::string output;
- output.append(LexCer::spanBegin).append(LexCer::tokenToClass.at(token.type)).append("\">").append(lexeme).append(LexCer::spanEnd);
-
- if (fputs(output.c_str(), out) == EOF) {
- printf("Error while writing to output");
- return false;
- }
- return true;
-}
-
-std::string getOutputFileName(const std::string &name) {
- auto pos = name.find_last_of('.');
- if (pos == std::string::npos) {
- return name + ".html";
- }
-
- return name.substr(0, pos) + ".html";
-}
-
-void lexCit(FILE *in, FILE *out) {
- Tokenizer hl {in, out};
-
- std::string lexeme;
- double number;
- TokenClass type;
- Token token;
- do {
- token = hl.nextToken(&lexeme, &number);
- type = token.type;
-
- if (!writeToOutput(out, token))
- break;
- lexeme = "";
- number = 0.0;
- } while(type != TokenClass::Eof || type != TokenClass::Invalid);
-}
-
-} /* Namespace HTMLUtils */
diff --git a/homework/81568/c2html/html_utils.h b/homework/81568/c2html/html_utils.h
deleted file mode 100644
index 8d8cf0d..0000000
--- a/homework/81568/c2html/html_utils.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef HTML_UTILS_H
-#define HTML_UTILS_H
-
-#include "lexcer.h"
-using LexCer::Token;
-using LexCer::TokenClass;
-using LexCer::Tokenizer;
-
-namespace HTMLUtils {
-
-std::string escapeHTML(const std::string &lexeme);
-bool writeToOutput(FILE *out, Token token);
-std::string getOutputFileName(const std::string &name);
-void lexCit(FILE *in, FILE *out);
-
-} /* Namespace HMTLUtils */
-
-#endif /* HTML_UTILS_H */
diff --git a/homework/81568/c2html/lexcer.cpp b/homework/81568/c2html/lexcer.cpp
deleted file mode 100644
index df28e6f..0000000
--- a/homework/81568/c2html/lexcer.cpp
+++ /dev/null
@@ -1,327 +0,0 @@
-#include "lexcer.h"
-#include "lexconst.h"
-
-#include <cctype>
-#include <cstdlib>
-
-namespace LexCer {
-
-Tokenizer::Tokenizer(FILE *in, FILE *out)
- : in(in), out(out) {
- token.type = TokenClass::Invalid;
- // The idea behind having modifiable typenames structure was to read #defines, but
- // maybe it is better if a whole preproccessor is written.
- typenames = {"void", "char", "short", "int", "long", "float", "double", "signed", "unsigned", "FILE"};
-}
-
-Token Tokenizer::makeToken(TokenClass type, std::string lexeme, double number) {
- token.type = type;
- token.line = line;
- token.lexeme = lexeme;
- token.number = number;
- return token;
-}
-
-bool Tokenizer::readNextDirective(std::string *lexeme) {
- char c;
- while (isalpha((c = fgetc(in))))
- lexeme->push_back(c);
- // we may need that last bit
- ungetc((unsigned) c, in);
- auto directive = lexeme->substr(1, lexeme->size() - 1);
- if (!preprocessor.count(directive))
- return false;
- if (directive.compare("define") == 0) {
- //readDefine();
- }
- return true;
-}
-
-bool Tokenizer::readNextString(std::string *lexeme, char oldc) {
- char c, prevc = oldc;
- while (((c = fgetc(in)) != '"' || prevc == '\\') && c != '\n' && c != EOF) {
- lexeme->push_back(c);
- prevc = c;
- }
-
- if (c == '\n' || c == EOF) {
- ungetc((unsigned) c, in);
- return false;
- }
- lexeme->push_back(c);
- return true;
-}
-
-bool Tokenizer::readNextIdentifier(std::string *lexeme) {
- char c;
- bool valid = true;
- while (isalnum(c = fgetc(in)) || c == '_') {
- lexeme->push_back(c);
- }
- ungetc((unsigned) c, in);
- return valid;
-}
-
-bool Tokenizer::readNextNumber(char beg, double *number, std::string *numberRepr) {
- bool valid = true;
- num_t base = DEC;
- char c;
- if (beg == '0') {
- c = fgetc(in);
- numberRepr->push_back(c);
- if (c == 'b')
- base = BIN;
- else if (c == 'x' || c == 'X')
- base = HEX;
- else if (isdigit(c))
- base = OCT;
- else
- ungetc((unsigned) c, in);
- }
-
- while (isValidDigit(c = fgetc(in), base)) {
- numberRepr->push_back(c);
- }
-
- if (c == '.') {
- numberRepr->push_back(c);
- while (isValidDigit(c = fgetc(in), base))
- numberRepr->push_back(c);
- }
- if (tolower(c) == 'e') {
- numberRepr->push_back(c);
- if (base != DEC)
- return false;
- if (!isdigit(c = fgetc(in)) && c != '-' && c != '+') {
- ungetc((unsigned) c, in);
- return false;
- }
- numberRepr->push_back(c);
- while (isValidDigit(c = fgetc(in), base))
- numberRepr->push_back(c);
- }
-
- char lower = tolower(c);
- if (lower == 'u') {
- numberRepr->push_back(c);
- lower = tolower(c = fgetc(in));
- }
- if (lower == 'f' || lower == 'l')
- numberRepr->push_back(c);
- else
- ungetc((unsigned) c, in);
-
- *number = this->atod(*numberRepr); // not working ...
- return true;
-}
-
-bool Tokenizer::isValidDigit(char c, num_t numType) const {
- bool valid;
- switch (numType) {
- case DEC:
- return isdigit(c);
- case BIN:
- return (c == '0' || c == '1');
- case OCT:
- return (c >= '0' || c <= '7');
- case HEX:
- return (isdigit(c) || tolower(c) >= 'a' || tolower(c) <= 'f');
- default:
- return false;
- }
-}
-
-bool Tokenizer::readLineComment(std::string *lexeme) {
- char c;
- while ((c = fgetc(in)) != '\n' && c != EOF)
- lexeme->push_back(c);
- ungetc((unsigned) c, in);
- return true; // for consistency
-}
-
-bool Tokenizer::readMultilineComment(std::string *lexeme) {
- char c, prevc = (char) -1;
- while (((c = fgetc(in)) != '/' && prevc != '*') && c != EOF)
- lexeme->push_back(c);
-
- if (c == EOF) {
- return false;
- }
- lexeme->push_back(c); // closing slash
- return true;
-}
-
-bool Tokenizer::readInclude(std::string *lexeme) {
- char c;
- bool valid = true;
- while ((c = fgetc(in)) != '>') {
- lexeme->push_back(c);
- if (!isalpha(c) && c != '_' && c != '.')
- valid = false;
- }
- lexeme->push_back(c);
- return valid;
-}
-
-bool Tokenizer::readUntilBlank(std::string *lexeme) {
- char c;
- while (!isblank(c = fgetc(in)) && c != EOF) ;
- ungetc((unsigned) c, in);
- return true;
-}
-
-Token Tokenizer::nextToken(std::string *lexeme, double *number) {
- TokenClass type;
- if (token.type == TokenClass::Eof) {
- return makeToken(TokenClass::Invalid, *lexeme, *number);
- }
-
- char c = fgetc(in);
- if (c == EOF) {
- return makeToken(TokenClass::Eof, *lexeme, *number);
- }
- lexeme->push_back(c);
- // operator || symbol || string || preprocessor directive
- // probably should check for errors like '5 * % 4;', but...
- switch(c) {
- case '\n':
- ++line;
- case '\t':
- case ' ':
- case ';':
- case ',':
- return makeToken(TokenClass::Skip, *lexeme, *number);
- case '(':
- return makeToken(TokenClass::LeftParen, *lexeme, *number);
- case ')':
- return makeToken(TokenClass::RightParen, *lexeme, *number);
- case '{':
- return makeToken(TokenClass::LeftCurly, *lexeme, *number);
- case '}':
- return makeToken(TokenClass::RightCurly, *lexeme, *number);
- case '[':
- case ']':
- case '?':
- case ':':
- return makeToken(TokenClass::Operator, *lexeme, *number);
- case '*':
- c = fgetc(in);
- if (c == '/') {
- return makeToken(TokenClass::Invalid, *lexeme, *number);
- }
- ungetc((unsigned) c, in);
- c = '*';
- case '^':
- case '%':
- case '=':
- case '!':
- case '~':
- c = fgetc(in);
- if (c != '=') ungetc((unsigned) c, in);
- else lexeme->push_back(c);
- return makeToken(TokenClass::Operator, *lexeme, *number);
- case '<':
- case '>':
- c = fgetc(in);
- if (c == lexeme->at(lexeme->size() - 1)) {
- lexeme->push_back(c);
- c = fgetc(in);
- if (c == '=')
- lexeme->push_back(c);
- else
- ungetc((unsigned) c, in);
- } else if (lexeme->at(lexeme->size() - 1) == '<' && isalpha(c)) {
- lexeme->push_back(c);
- if (!readInclude(lexeme))
- return makeToken(TokenClass::Invalid, *lexeme, *number);
- return makeToken(TokenClass::String, *lexeme, *number);
- } else
- ungetc((unsigned) c, in);
- return makeToken(TokenClass::Operator, *lexeme, *number);
- case '&':
- case '|':
- case '+':
- c = fgetc(in);
- if (c == lexeme->at(lexeme->size() - 1) || c == '=')
- lexeme->push_back(c);
- else
- ungetc((unsigned) c, in);
- return makeToken(TokenClass::Operator, *lexeme, *number);
- case '-':
- c = fgetc(in);
- if (c == '-' || c == '=' || c == '>')
- lexeme->push_back(c);
- else
- ungetc((unsigned) c, in);
- return makeToken(TokenClass::Operator, *lexeme, *number);
- case '#':
- if (readNextDirective(lexeme))
- return makeToken(TokenClass::PreprocessorDirective, *lexeme, *number);
- return makeToken(TokenClass::Invalid, *lexeme, *number);
- case '\'':
- lexeme->push_back(c = fgetc(in));
- if (c == '\\') {
- lexeme->push_back(c = fgetc(in));
- }
- lexeme->push_back(c = fgetc(in)); // the closing mark
- if (c != '\'')
- return makeToken(TokenClass::Invalid, *lexeme, *number);
- return makeToken(TokenClass::String, *lexeme, *number);
- case '"':
- if (readNextString(lexeme, c))
- return makeToken(TokenClass::String, *lexeme, *number);
- return makeToken(TokenClass::Invalid, *lexeme, *number);
- case '/':
- c = fgetc(in);
- lexeme->push_back(c);
- switch (c) {
- case '=':
- return makeToken(TokenClass::Operator, *lexeme, *number);
- case '/':
- if (!readLineComment(lexeme))
- return makeToken(TokenClass::Invalid, *lexeme, *number);
- return makeToken(TokenClass::Comment, *lexeme, *number);
- case '*':
- if (!readMultilineComment(lexeme))
- return makeToken(TokenClass::Invalid, *lexeme, *number);
- return makeToken(TokenClass::Comment, *lexeme, *number);
- default:
- if (!isblank(c) || !isdigit(c)) {
- ungetc((unsigned) c, in);
- lexeme->pop_back();
- return makeToken(TokenClass::Invalid, *lexeme, *number);
- }
- return makeToken(TokenClass::Operator, *lexeme, *number);
- }
- case '\\':
- c = fgetc(in);
- ungetc((unsigned) c, in);
- if (c != '\n')
- return makeToken(TokenClass::Invalid, *lexeme, *number); // stray '\'
- return makeToken(TokenClass::Operator, *lexeme, *number);
- }
-
- // identifier || keyword || typename
- if (isalpha(c) || c == '_') {
- if (readNextIdentifier(lexeme)) {
- if (keywords.count(*lexeme) != 0)
- return makeToken(TokenClass::Keyword, *lexeme, *number);
- else if (typenames.count(*lexeme) != 0)
- return makeToken(TokenClass::Typename, *lexeme, *number);
- return makeToken(TokenClass::Identifier, *lexeme, *number);
- } else {
- return makeToken(TokenClass::Invalid, *lexeme, *number);
- }
- }
-
- if (!isdigit(c)) {
- return makeToken(TokenClass::Invalid, *lexeme, *number);
- }
-
- // number
- if (readNextNumber(c, number, lexeme))
- return makeToken(TokenClass::Number, *lexeme, *number);
- return makeToken(TokenClass::Invalid, *lexeme, *number);
-}
-
-} /* Namespace Lexcer */
diff --git a/homework/81568/c2html/lexcer.h b/homework/81568/c2html/lexcer.h
deleted file mode 100644
index eb8afe0..0000000
--- a/homework/81568/c2html/lexcer.h
+++ /dev/null
@@ -1,76 +0,0 @@
-#ifndef FMI_IPL_LEXCER_H
-#define FMI_IPL_LEXCER_H
-
-#include <unordered_set>
-#include <unordered_map>
-#include <string>
-
-#include <cstdio>
-
-namespace LexCer {
-
-enum TokenClass : short {
- Operator,
- Keyword,
- PreprocessorDirective,
- Typename,
- Identifier,
- String,
- Comment,
- Number,
- LeftParen,
- RightParen,
- LeftCurly,
- RightCurly,
-
- Skip,
- Eof,
- Invalid
-};
-
-struct Token {
- TokenClass type;
- unsigned line;
- std::string lexeme;
- double number;
-};
-
-
-class Tokenizer {
-private:
- enum num_t {
- BIN = 2,
- OCT = 8,
- DEC = 10,
- HEX = 16
- };
-
-public:
- Tokenizer(FILE *in, FILE *out);
-
- Token nextToken(std::string *lexeme, double *number);
-
-private:
- Token makeToken(TokenClass type, std::string lexeme = std::string(), double number = 0.0);
- bool readNextDirective(std::string *lexeme);
- bool readNextString(std::string *lexeme, char oldc);
- bool readNextIdentifier(std::string *lexeme);
- bool readNextNumber(char beg, double *number, std::string *numberRepr);
- bool isValidDigit(char c, num_t numType) const ;
- bool readLineComment(std::string *lexeme);
- bool readMultilineComment(std::string *lexeme);
- bool readInclude(std::string *lexeme);
- bool readUntilBlank(std::string *lexeme);
-
- double atod(const std::string &number) const { return 0.0; }
-private:
- FILE *in;
- FILE *out;
- Token token; // current token
- unsigned line = 1;
- std::unordered_set<std::string> typenames;
-};
-
-} /* Namespace LexCer */
-
-#endif
diff --git a/homework/81568/c2html/lexconst.h b/homework/81568/c2html/lexconst.h
deleted file mode 100644
index cfb9e6d..0000000
--- a/homework/81568/c2html/lexconst.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef LEXCER_CONST_H
-#define LEXCER_CONST_H
-
-namespace LexCer {
-
-static const std::unordered_set<std::string> keywords =
- {"auto", "register", "static", "extern", "typedef", "struct", "union", "enum",
- "if", "else", "for", "while", "switch", "case", "default", "const", "break",
- "continue", "goto", "sizeof", "alignof", "volatile", "return"};
-
-static const std::unordered_set<std::string> preprocessor =
- {"include", "define", "undef", "if", "ifdef", "ifndef", "else", "elif", "endif",
- "line", "error", "pragma"};
-
-static const std::unordered_map<TokenClass, std::string> tokenToClass
- {
- {
- {TokenClass::Operator, "operator"},
- {TokenClass::Keyword, "keyword"},
- {TokenClass::Typename, "typename"},
- {TokenClass::PreprocessorDirective, "preproc"},
- {TokenClass::Identifier, "identifier"},
- {TokenClass::String, "string"},
- {TokenClass::Comment, "comment"},
- {TokenClass::Number, "number"},
- {TokenClass::Invalid, "invalid"},
- {TokenClass::LeftParen, "identifier"},
- {TokenClass::LeftCurly, "identifier"},
- {TokenClass::RightParen, "identifier"},
- {TokenClass::RightCurly, "identifier"},
- {TokenClass::RightParen, "identifier"}
- }
- };
-
-static const std::string spanBegin = "<span class=\"";
-static const std::string spanEnd = "</span>";
-
-static constexpr int MAX_EXP_LEN = 4;
-
-} /* Namespace LexCer */
-
-#endif
diff --git a/homework/81568/c2html/main.cpp b/homework/81568/c2html/main.cpp
deleted file mode 100644
index d4dbed3..0000000
--- a/homework/81568/c2html/main.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-#include <cstdio>
-#include <cstring>
-
-#include "cyclomatic.h"
-#include "html_utils.h"
-#include "lexcer.h"
-
-int main(int argc, char *argv[]) {
-
- if (argc != 2) {
- printf("Usage: %s <*.{c,h} file>\n", argv[0]);
- return 1; /* wrong usage */
- }
-
- auto fpIn = fopen(argv[1], "r");
- if (!fpIn) {
- return 2; /* unable to open file or inavlid file */
- }
-
- auto outputName = HTMLUtils::getOutputFileName(argv[1]);
- auto fpOut = fopen(outputName.c_str(), "w");
- if (!fpOut) {
- return 2;
- }
-
-
- fputs(
- "<!DOCTYPE html>\n"
- "<html>\n"
- "<head>\n"
- " <title>LexCed</title>\n"
- " <style>\n"
- " .keyword {\n"
- " color: purple;\n"
- " }\n"
- " .number {\n"
- " color: darkblue;\n"
- " }\n"
- " .string {\n"
- " color: green;\n"
- " }\n"
- " .operator {\n"
- " font-style: bold;\n"
- " }\n"
- " .invalid {\n"
- " text-decoration: underline;\n"
- " text-decoration-color: red;\n"
- " text-decoration-style: wavy;\n"
- " }\n"
- " .typename {\n"
- " color: blue;\n"
- " }\n"
- " .preproc {\n"
- " color: purple;\n"
- " }\n"
- " .identifier {\n"
- " color: black;\n"
- " }\n"
- " .string {\n"
- " color: brown;\n"
- " }\n"
- " .comment {\n"
- " color: green;\n"
- " }\n"
- " .complexity-level-one {\n"
- " background-color: PaleGreen;\n"
- " }\n"
- " .complexity-level-two {\n"
- " background-color: DarkGreen;\n"
- " }\n"
- " .complexity-level-three {\n"
- " background-color: SaddleBrown;\n"
- " }\n"
- " .complexity-level-four {\n"
- " background-color: Brown;\n"
- " }\n"
- " .complexity-level-five {\n"
- " background-color: Maroon;\n"
- " }\n"
- " </style>\n"
- "</head>\n"
- "<body onload=\"toggleComplexity()\">\n"
- "<pre class=\"code\">\n",
- fpOut
- );
- ParCer::outputWithCyclomaticComplexity(fpIn, fpOut);
- fputs("</pre>\n"
- "<script>\n"
- "function toggleComplexity() {\n"
- " var funcs = document.getElementsByClassName(\"func\");"
- " if (funcs.length == 0) return;\n"
- " var len = funcs.length;\n"
- " for (var i = 0; i < len; ++i) {\n"
- " var f = document.getElementsByClassName(\"func\")[0];\n"
- " var complexity = f.innerHTML.match(\"(<!-- )([0-9]+)( -->)\")[2];\n"
- " if (complexity < 3)\n"
- " f.className = \"complexity-level-one\";\n"
- " else if (complexity < 7)\n"
- " f.className = \"complexity-level-two\";\n"
- " else if (complexity < 15)\n"
- " f.className = \"complexity-level-three\";\n"
- " else if (complexity < 20)\n"
- " f.className = \"complexity-level-four\";\n"
- " else\n"
- " f.className = \"complexity-level-five\";\n"
- " }\n"
- "}\n",
- fpOut);
- fputs("</script></body></html>\n", fpOut);
-
- printf("Highlighted text written in %s!\n", outputName.c_str());
-
- return 0;
-}
diff --git a/homework/81568/c2html/test.c b/homework/81568/c2html/test.c
deleted file mode 100644
index 0aafa72..0000000
--- a/homework/81568/c2html/test.c
+++ /dev/null
@@ -1,114 +0,0 @@
-#ifndef SAMPLE_CODE_C
-#define SAMPLE_CODE_C
-
-#define ONE_LINE_MACRO 5
-
-#include <stdio.h>
-
-int bitcount(long long x) {
- int cnt = 0;
- while (x) {
- ++cnt;
- x &= (x-1);
- }
- return cnt;
-}
-
-void shift_to_pos(int *num, int p, int n) {
- *num = p > n ? *num << (p - n + 1) : *num >> (n - p + 1);
-}
-
-int setbits(x, p, n, y) {
- int mask = (1 << n) - 1;
- int to_set = y & mask;
- shift_to_pos(&mask, p, n);
- shift_to_pos(&to_set, p, n);
- return (x & ~mask) | to_set;
-}
-
-unsigned invert(unsigned x, unsigned p, unsigned n) {
- ++p; // in case p < n
- while(n-- && p--) {
- if (!(x & (1 << n))) {
- x |= (1 << n);
- } else {
- x ^= (1 << n);
- }
- }
- return x;
-}
-
-int rightrot(long long x, int n) {
- int bitcnt = bitcount(x);
- x <<= n;
- return (x & ( (1 << (bitcnt)) - 1) ) | (x & ~( (1 << bitcnt) - 1 )) >> bitcnt;
-}
-
-char num[32];
-
-void to_binary(unsigned x) {
- int i = 31;
- num[32] = '\0';
- while (x) {
- if (x & 1) num[i] = '1';
- else num[i] = '0';
- --i;
- x >>= 1;
- }
- for (; i >= 0; --i) num[i] = '0';
- for (; i < 32; ++i) {
- printf("%c%s", num[i], !((i+1) % 4) ? " " : "");
- }
-}
-
-void switch_why_not(void) {
- char c = 'X';
- switch(c) {
- case 'x':
- printf("hex\n");
- break;
- case 'X':
- printf("why break stuff\n");
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- default:
- break;
- }
-
- return;
-}
-
-main() {
- long long x = 0b110110;
- printf("rightrot:\n");
- to_binary(x);
- printf("\n");
- to_binary(rightrot(x, 3));
- printf("\n");
-
- unsigned i = 0b101010;
- printf("invert:\n");
- to_binary(i);
- printf("\n");
- to_binary(invert(i, 4, 4));
- printf("\n");
-
- long long a = 0b111001010011;
- long long b = 0b11111010;
- printf("bits of: "); to_binary(a); printf("\n");
- printf("bits to: "); to_binary(b); printf("\n");
- to_binary(setbits(a, 6, 4, b));
-
-
- int testInt = 12345678;
- float testFloat = 1234.5678f;
- double testDouble = 1234.5678;
-
- return 0;
-}
-
-#endif /* SAMPLE_CODE_C */
diff --git a/homework/81568/c2html/test.html b/homework/81568/c2html/test.html
deleted file mode 100644
index e39aec0..0000000
--- a/homework/81568/c2html/test.html
+++ /dev/null
@@ -1,192 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>LexCed</title>
- <style>
- .keyword {
- color: purple;
- }
- .number {
- color: darkblue;
- }
- .string {
- color: green;
- }
- .operator {
- font-style: bold;
- }
- .invalid {
- text-decoration: underline;
- text-decoration-color: red;
- text-decoration-style: wavy;
- }
- .typename {
- color: blue;
- }
- .preproc {
- color: purple;
- }
- .identifier {
- color: black;
- }
- .string {
- color: brown;
- }
- .comment {
- color: green;
- }
- .complexity-level-one {
- background-color: PaleGreen;
- }
- .complexity-level-two {
- background-color: DarkGreen;
- }
- .complexity-level-three {
- background-color: SaddleBrown;
- }
- .complexity-level-four {
- background-color: Brown;
- }
- .complexity-level-five {
- background-color: Maroon;
- }
- </style>
-</head>
-<body onload="toggleComplexity()">
-<pre class="code">
-<span class="preproc">#ifndef</span> <span class="identifier">SAMPLE_CODE_C</span>
-<span class="preproc">#define</span> <span class="identifier">SAMPLE_CODE_C</span>
-
-<span class="preproc">#define</span> <span class="identifier">ONE_LINE_MACRO</span> <span class="number">5</span>
-
-<span class="preproc">#include</span> <span class="string">&ltstdio.h&gt</span>
-
-<span class="typename">int</span> <span class="identifier">bitcount</span><span class="identifier">(</span><span class="typename">long</span> <span class="typename">long</span> <span class="identifier">x</span><span class="identifier">)</span> <div class="func"><span class="identifier">{</span>
- <span class="typename">int</span> <span class="identifier">cnt</span> <span class="operator">=</span> <span class="number">0;</span>;
- <span class="keyword">while</span> <span class="identifier">(</span><span class="identifier">x</span><span class="identifier">)</span> <span class="identifier">{</span>
- <span class="operator">++</span><span class="identifier">cnt</span>;
- <span class="identifier">x</span> <span class="operator">&amp=</span> <span class="identifier">(</span><span class="identifier">x</span><span class="operator">-</span><span class="number">1</span><span class="identifier">)</span>;
- <span class="identifier">}</span>
- <span class="keyword">return</span> <span class="identifier">cnt</span>;
-<!-- 2 --></div><span class="identifier">}</span>
-
-<span class="typename">void</span> <span class="identifier">shift_to_pos</span><span class="identifier">(</span><span class="typename">int</span> <span class="operator">*</span><span class="identifier">num</span>, <span class="typename">int</span> <span class="identifier">p</span>, <span class="typename">int</span> <span class="identifier">n</span><span class="identifier">)</span> <div class="func"><span class="identifier">{</span>
- <span class="operator">*</span><span class="identifier">num</span> <span class="operator">=</span> <span class="identifier">p</span> <span class="operator">&gt</span> <span class="identifier">n</span> <span class="operator">?</span> <span class="operator">*</span><span class="identifier">num</span> <span class="operator">&lt&lt</span> <span class="identifier">(</span><span class="identifier">p</span> <span class="operator">-</span> <span class="identifier">n</span> <span class="operator">+</span> <span class="number">1</span><span class="identifier">)</span> <span class="operator">:</span> <span class="operator">*</span><span class="identifier">num</span> <span class="operator">&gt&gt</span> <span class="identifier">(</span><span class="identifier">n</span> <span class="operator">-</span> <span class="identifier">p</span> <span class="operator">+</span> <span class="number">1</span><span class="identifier">)</span>;
-<!-- 1 --></div><span class="identifier">}</span>
-
-<span class="typename">int</span> <span class="identifier">setbits</span><span class="identifier">(</span><span class="identifier">x</span>, <span class="identifier">p</span>, <span class="identifier">n</span>, <span class="identifier">y</span><span class="identifier">)</span> <div class="func"><span class="identifier">{</span>
- <span class="typename">int</span> <span class="identifier">mask</span> <span class="operator">=</span> <span class="identifier">(</span><span class="number">1</span> <span class="operator">&lt&lt</span> <span class="identifier">n</span><span class="identifier">)</span> <span class="operator">-</span> <span class="number">1</span>;
- <span class="typename">int</span> <span class="identifier">to_set</span> <span class="operator">=</span> <span class="identifier">y</span> <span class="operator">&amp</span> <span class="identifier">mask</span>;
- <span class="identifier">shift_to_pos</span><span class="identifier">(</span><span class="operator">&amp</span><span class="identifier">mask</span>, <span class="identifier">p</span>, <span class="identifier">n</span><span class="identifier">)</span>;
- <span class="identifier">shift_to_pos</span><span class="identifier">(</span><span class="operator">&amp</span><span class="identifier">to_set</span>, <span class="identifier">p</span>, <span class="identifier">n</span><span class="identifier">)</span>;
- <span class="keyword">return</span> <span class="identifier">(</span><span class="identifier">x</span> <span class="operator">&amp</span> <span class="operator">~</span><span class="identifier">mask</span><span class="identifier">)</span> <span class="operator">|</span> <span class="identifier">to_set</span>;
-<!-- 1 --></div><span class="identifier">}</span>
-
-<span class="typename">unsigned</span> <span class="identifier">invert</span><span class="identifier">(</span><span class="typename">unsigned</span> <span class="identifier">x</span>, <span class="typename">unsigned</span> <span class="identifier">p</span>, <span class="typename">unsigned</span> <span class="identifier">n</span><span class="identifier">)</span> <div class="func"><span class="identifier">{</span>
- <span class="operator">++</span><span class="identifier">p</span>; <span class="comment">// in case p &lt n</span>
- <span class="keyword">while</span><span class="identifier">(</span><span class="identifier">n</span><span class="operator">--</span> <span class="operator">&amp&amp</span> <span class="identifier">p</span><span class="operator">--</span><span class="identifier">)</span> <span class="identifier">{</span>
- <span class="keyword">if</span> <span class="identifier">(</span><span class="operator">!</span><span class="identifier">(</span><span class="identifier">x</span> <span class="operator">&amp</span> <span class="identifier">(</span><span class="number">1</span> <span class="operator">&lt&lt</span> <span class="identifier">n</span><span class="identifier">)</span><span class="identifier">)</span><span class="identifier">)</span> <span class="identifier">{</span>
- <span class="identifier">x</span> <span class="operator">|=</span> <span class="identifier">(</span><span class="number">1</span> <span class="operator">&lt&lt</span> <span class="identifier">n</span><span class="identifier">)</span>;
- <span class="identifier">}</span> <span class="keyword">else</span> <span class="identifier">{</span>
- <span class="identifier">x</span> <span class="operator">^=</span> <span class="identifier">(</span><span class="number">1</span> <span class="operator">&lt&lt</span> <span class="identifier">n</span><span class="identifier">)</span>;
- <span class="identifier">}</span>
- <span class="identifier">}</span>
- <span class="keyword">return</span> <span class="identifier">x</span>;
-<!-- 3 --></div><span class="identifier">}</span>
-
-<span class="typename">int</span> <span class="identifier">rightrot</span><span class="identifier">(</span><span class="typename">long</span> <span class="typename">long</span> <span class="identifier">x</span>, <span class="typename">int</span> <span class="identifier">n</span><span class="identifier">)</span> <div class="func"><span class="identifier">{</span>
- <span class="typename">int</span> <span class="identifier">bitcnt</span> <span class="operator">=</span> <span class="identifier">bitcount</span><span class="identifier">(</span><span class="identifier">x</span><span class="identifier">)</span>;
- <span class="identifier">x</span> <span class="operator">&lt&lt=</span> <span class="identifier">n</span>;
- <span class="keyword">return</span> <span class="identifier">(</span><span class="identifier">x</span> <span class="operator">&amp</span> <span class="identifier">(</span> <span class="identifier">(</span><span class="number">1</span> <span class="operator">&lt&lt</span> <span class="identifier">(</span><span class="identifier">bitcnt</span><span class="identifier">)</span><span class="identifier">)</span> <span class="operator">-</span> <span class="number">1</span><span class="identifier">)</span> <span class="identifier">)</span> <span class="operator">|</span> <span class="identifier">(</span><span class="identifier">x</span> <span class="operator">&amp</span> <span class="operator">~</span><span class="identifier">(</span> <span class="identifier">(</span><span class="number">1</span> <span class="operator">&lt&lt</span> <span class="identifier">bitcnt</span><span class="identifier">)</span> <span class="operator">-</span> <span class="number">1</span> <span class="identifier">)</span><span class="identifier">)</span> <span class="operator">&gt&gt</span> <span class="identifier">bitcnt</span>;
-<!-- 1 --></div><span class="identifier">}</span>
-
-<span class="typename">char</span> <span class="identifier">num</span><span class="operator">[</span><span class="number">32</span><span class="operator">]</span>;
-
-<span class="typename">void</span> <span class="identifier">to_binary</span><span class="identifier">(</span><span class="typename">unsigned</span> <span class="identifier">x</span><span class="identifier">)</span> <div class="func"><span class="identifier">{</span>
- <span class="typename">int</span> <span class="identifier">i</span> <span class="operator">=</span> <span class="number">31</span>;
- <span class="identifier">num</span><span class="operator">[</span><span class="number">32</span><span class="operator">]</span> <span class="operator">=</span> <span class="string">'\0'</span>;
- <span class="keyword">while</span> <span class="identifier">(</span><span class="identifier">x</span><span class="identifier">)</span> <span class="identifier">{</span>
- <span class="keyword">if</span> <span class="identifier">(</span><span class="identifier">x</span> <span class="operator">&amp</span> <span class="number">1</span><span class="identifier">)</span> <span class="identifier">num</span><span class="operator">[</span><span class="identifier">i</span><span class="operator">]</span> <span class="operator">=</span> <span class="string">'1'</span>;
- <span class="keyword">else</span> <span class="identifier">num</span><span class="operator">[</span><span class="identifier">i</span><span class="operator">]</span> <span class="operator">=</span> <span class="string">'0'</span>;
- <span class="operator">--</span><span class="identifier">i</span>;
- <span class="identifier">x</span> <span class="operator">&gt&gt=</span> <span class="number">1</span>;
- <span class="identifier">}</span>
- <span class="keyword">for</span> <span class="identifier">(</span>; <span class="identifier">i</span> <span class="operator">&gt</span><span class="operator">=</span> <span class="number">0;</span>; <span class="operator">--</span><span class="identifier">i</span><span class="identifier">)</span> <span class="identifier">num</span><span class="operator">[</span><span class="identifier">i</span><span class="operator">]</span> <span class="operator">=</span> <span class="string">'0'</span>;
- <span class="keyword">for</span> <span class="identifier">(</span>; <span class="identifier">i</span> <span class="operator">&lt</span> <span class="number">32</span>; <span class="operator">++</span><span class="identifier">i</span><span class="identifier">)</span> <span class="identifier">{</span>
- <span class="identifier">printf</span><span class="identifier">(</span><span class="string">"%c%s"</span>, <span class="identifier">num</span><span class="operator">[</span><span class="identifier">i</span><span class="operator">]</span>, <span class="operator">!</span><span class="identifier">(</span><span class="identifier">(</span><span class="identifier">i</span><span class="operator">+</span><span class="number">1</span><span class="identifier">)</span> <span class="operator">%</span> <span class="number">4</span><span class="identifier">)</span> <span class="operator">?</span> <span class="string">" "</span> <span class="operator">:</span> <span class="string">""</span><span class="identifier">)</span>;
- <span class="identifier">}</span>
-<!-- 5 --></div><span class="identifier">}</span>
-
-<span class="typename">void</span> <span class="identifier">switch_why_not</span><span class="identifier">(</span><span class="typename">void</span><span class="identifier">)</span> <div class="func"><span class="identifier">{</span>
- <span class="typename">char</span> <span class="identifier">c</span> <span class="operator">=</span> <span class="string">'X'</span>;
- <span class="keyword">switch</span><span class="identifier">(</span><span class="identifier">c</span><span class="identifier">)</span> <span class="identifier">{</span>
- <span class="keyword">case</span> <span class="string">'x'</span><span class="operator">:</span>
- <span class="identifier">printf</span><span class="identifier">(</span><span class="string">"hex\n"</span><span class="identifier">)</span>;
- <span class="keyword">break</span>;
- <span class="keyword">case</span> <span class="string">'X'</span><span class="operator">:</span>
- <span class="identifier">printf</span><span class="identifier">(</span><span class="string">"why break stuff\n"</span><span class="identifier">)</span>;
- <span class="keyword">case</span> <span class="number">1</span><span class="operator">:</span>
- <span class="keyword">case</span> <span class="number">2</span><span class="operator">:</span>
- <span class="keyword">case</span> <span class="number">3</span><span class="operator">:</span>
- <span class="keyword">case</span> <span class="number">4</span><span class="operator">:</span>
- <span class="keyword">case</span> <span class="number">5</span><span class="operator">:</span>
- <span class="keyword">case</span> <span class="number">6</span><span class="operator">:</span>
- <span class="keyword">default</span><span class="operator">:</span>
- <span class="keyword">break</span>;
- <span class="identifier">}</span>
-
- <span class="keyword">return</span>;
-<!-- 10 --></div><span class="identifier">}</span>
-
-<span class="identifier">main</span><span class="identifier">(</span><span class="identifier">)</span> <div class="func"><span class="identifier">{</span>
- <span class="typename">long</span> <span class="typename">long</span> <span class="identifier">x</span> <span class="operator">=</span> <span class="number">0b110110</span>;
- <span class="identifier">printf</span><span class="identifier">(</span><span class="string">"rightrot:\n"</span><span class="identifier">)</span>;
- <span class="identifier">to_binary</span><span class="identifier">(</span><span class="identifier">x</span><span class="identifier">)</span>;
- <span class="identifier">printf</span><span class="identifier">(</span><span class="string">"\n"</span><span class="identifier">)</span>;
- <span class="identifier">to_binary</span><span class="identifier">(</span><span class="identifier">rightrot</span><span class="identifier">(</span><span class="identifier">x</span>, <span class="number">3</span><span class="identifier">)</span><span class="identifier">)</span>;
- <span class="identifier">printf</span><span class="identifier">(</span><span class="string">"\n"</span><span class="identifier">)</span>;
-
- <span class="typename">unsigned</span> <span class="identifier">i</span> <span class="operator">=</span> <span class="number">0b101010</span>;
- <span class="identifier">printf</span><span class="identifier">(</span><span class="string">"invert:\n"</span><span class="identifier">)</span>;
- <span class="identifier">to_binary</span><span class="identifier">(</span><span class="identifier">i</span><span class="identifier">)</span>;
- <span class="identifier">printf</span><span class="identifier">(</span><span class="string">"\n"</span><span class="identifier">)</span>;
- <span class="identifier">to_binary</span><span class="identifier">(</span><span class="identifier">invert</span><span class="identifier">(</span><span class="identifier">i</span>, <span class="number">4</span>, <span class="number">4</span><span class="identifier">)</span><span class="identifier">)</span>;
- <span class="identifier">printf</span><span class="identifier">(</span><span class="string">"\n"</span><span class="identifier">)</span>;
-
- <span class="typename">long</span> <span class="typename">long</span> <span class="identifier">a</span> <span class="operator">=</span> <span class="number">0b111001010011</span>;
- <span class="typename">long</span> <span class="typename">long</span> <span class="identifier">b</span> <span class="operator">=</span> <span class="number">0b11111010</span>;
- <span class="identifier">printf</span><span class="identifier">(</span><span class="string">"bits of: "</span><span class="identifier">)</span>; <span class="identifier">to_binary</span><span class="identifier">(</span><span class="identifier">a</span><span class="identifier">)</span>; <span class="identifier">printf</span><span class="identifier">(</span><span class="string">"\n"</span><span class="identifier">)</span>;
- <span class="identifier">printf</span><span class="identifier">(</span><span class="string">"bits to: "</span><span class="identifier">)</span>; <span class="identifier">to_binary</span><span class="identifier">(</span><span class="identifier">b</span><span class="identifier">)</span>; <span class="identifier">printf</span><span class="identifier">(</span><span class="string">"\n"</span><span class="identifier">)</span>;
- <span class="identifier">to_binary</span><span class="identifier">(</span><span class="identifier">setbits</span><span class="identifier">(</span><span class="identifier">a</span>, <span class="number">6</span>, <span class="number">4</span>, <span class="identifier">b</span><span class="identifier">)</span><span class="identifier">)</span>;
-
-
- <span class="typename">int</span> <span class="identifier">testInt</span> <span class="operator">=</span> <span class="number">12345678</span>;
- <span class="typename">float</span> <span class="identifier">testFloat</span> <span class="operator">=</span> <span class="number">1234.5678f</span>;
- <span class="typename">double</span> <span class="identifier">testDouble</span> <span class="operator">=</span> <span class="number">1234.5678</span>;
-
- <span class="keyword">return</span> <span class="number">0;</span>;
-<!-- 1 --></div><span class="identifier">}</span>
-
-<span class="preproc">#endif</span> <span class="comment">/* SAMPLE_CODE_C */</span>
-
-</pre>
-<script>
-function toggleComplexity() {
- var funcs = document.getElementsByClassName("func"); if (funcs.length == 0) return;
- var len = funcs.length;
- for (var i = 0; i < len; ++i) {
- var f = document.getElementsByClassName("func")[0];
- var complexity = f.innerHTML.match("(<!-- )([0-9]+)( -->)")[2];
- if (complexity < 3)
- f.className = "complexity-level-one";
- else if (complexity < 7)
- f.className = "complexity-level-two";
- else if (complexity < 15)
- f.className = "complexity-level-three";
- else if (complexity < 20)
- f.className = "complexity-level-four";
- else
- f.className = "complexity-level-five";
- }
-}
-</script></body></html>
diff --git a/homework/81625/Brainfuck-Interpretator/README.md b/homework/81625/Brainfuck-Interpretator/README.md
deleted file mode 100644
index e7000be..0000000
--- a/homework/81625/Brainfuck-Interpretator/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# IPL Homework 3 - Brainfuck Interpreter
-# How to run:
-Execute the 'run.sh' script from the src folder
diff --git a/homework/81625/Brainfuck-Interpretator/src/BFI.cpp b/homework/81625/Brainfuck-Interpretator/src/BFI.cpp
deleted file mode 100644
index 23d8c3e..0000000
--- a/homework/81625/Brainfuck-Interpretator/src/BFI.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-#include "BFI.h"
-
-void BFI::moveMPLeft()
-{
- --mMP;
-}
-
-void BFI::moveMPRight()
-{
- ++mMP;
- if(mMP > mMemoryUsed) mMemoryUsed = mMP;
-}
-
-void BFI::incCellAtMP()
-{
- if(mMP >= 0 && mMP < MEMORY_SIZE)
- {
- ++mMemory[mMP];
- }
- else
- {
- std::cout << "Out of memory bounds!!! MP: " << mMP << " IP: " << mIP << " " << mCode[mIP] << std::endl;
- exit(1);
- }
-}
-
-void BFI::decCellAtMP()
-{
- if(mMP >= 0 && mMP < MEMORY_SIZE)
- {
- --mMemory[mMP];
- }
- else
- {
- std::cout << "Out of memory bounds!!! MP: " << mMP << " IP: " << mIP << " " << mCode[mIP] << std::endl;
- exit(1);
- }
-}
-
-void BFI::printCellAtMP()
-{
- if(mMP >= 0 && mMP < MEMORY_SIZE)
- {
- if(mMemory[mMP] == 10)
- {
- std::cout<<"\n";
- }
- else
- {
- std::cout<<mMemory[mMP];
- }
- }
- else
- {
- std::cout << "Out of memory bounds!!! MP: " << mMP << " IP: " << mIP << " " << mCode[mIP] << std::endl;
- exit(1);
- }
-}
-
-void BFI::readToCellAtMP()
-{
- unsigned char c;
- std::cin>>c;
- if(mMP >= 0 && mMP < MEMORY_SIZE)
- {
- mMemory[mMP] = c;
- }
- else
- {
- std::cout << "Out of memory bounds!!! MP: " << mMP << " IP: " << mIP << " " << mCode[mIP] << std::endl;
- exit(1);
- }
-}
-void BFI::loopStart()
-{
- if(mMP >= 0 && mMP < MEMORY_SIZE)
- {
- if(mMemory[mMP] == 0)
- {
- mIP = mBrackets[mIP];
- }
- }
- else
- {
- std::cout << "Out of memory bounds!!! MP: " << mMP << " IP: " << mIP << " " << mCode[mIP] << std::endl;
- exit(1);
- }
-}
-
-void BFI::loopEnd()
-{
- if(mMP >= 0 && mMP < MEMORY_SIZE)
- {
- if(mMemory[mMP] != 0)
- {
- mIP = mBrackets[mIP];
- }
- }
- else
- {
- std::cout << "Out of memory bounds!!! MP: " << mMP << " IP: " << mIP << " " << mCode[mIP] << std::endl;
- exit(1);
- }
-}
-
-void BFI::interpret()
-{
- while(mCode[mIP] != '\0')
- {
- if(mCode[mIP] == '[')
- {
- mStack.push(mIP);
- }
- else if(mCode[mIP] == ']')
- {
- if(mStack.empty())
- {
- std::cout << "Unexpected closing bracket!!!\n";
- exit(1);
- }
- mBrackets[mIP] = mStack.top();
- mBrackets[mStack.top()] = mIP;
- mStack.pop();
- }
- ++mIP;
- }
- if(!mStack.empty())
- {
- std::cout << "Unclosed opening bracket!!!\n";
- exit(1);
- }
- mIP = 0;
- while(mCode[mIP] != '\0')
- {
- switch(mCode[mIP])
- {
- case '>': moveMPRight(); break;
- case '<': moveMPLeft(); break;
- case '+': incCellAtMP(); break;
- case '-': decCellAtMP(); break;
- case '.': printCellAtMP(); break;
- case ',': readToCellAtMP(); break;
- case '[': loopStart(); break;
- case ']': loopEnd(); break;
- }
- ++mIP;
- }
-}
-
-void BFI::printUsedMemory()
-{
- unsigned cols = 16;
- unsigned rows = mMemoryUsed/cols;
- unsigned lastRow = mMemoryUsed%cols;
- unsigned ind = 0;
- std::cout.fill('0');
- for(unsigned i = 0; i < rows; ++i)
- {
- std::cout << std::setw(4) << ind << ": ";
- for(unsigned j = 0; j < cols; j++)
- {
- std::cout << std::setw(3) << (unsigned)mMemory[ind++] << " ";
- }
- std::cout << std::endl;
- }
- if(lastRow != 0)
- {
- std::cout << std::setw(4) << ind << ": ";
- while(ind <= mMemoryUsed)
- {
- std::cout << std::setw(3) << (unsigned)mMemory[ind++] << " ";
- }
- std::cout << std::endl;
- }
-}
diff --git a/homework/81625/Brainfuck-Interpretator/src/BFI.h b/homework/81625/Brainfuck-Interpretator/src/BFI.h
deleted file mode 100644
index a058567..0000000
--- a/homework/81625/Brainfuck-Interpretator/src/BFI.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef BFI_H
-#define BFI_H
-
-#include<iostream>
-#include<stack>
-#include<vector>
-#include<iomanip>
-
-class BFI
-{
-private:
- static const unsigned MEMORY_SIZE = 2048;
- std::string mCode;
- unsigned mIP, mMemoryUsed;
- unsigned char mMemory[MEMORY_SIZE];
- int mMP;
- std::stack<unsigned> mStack;
- std::vector<unsigned> mBrackets;
-
- void moveMPLeft();
- void moveMPRight();
- void incCellAtMP();
- void decCellAtMP();
- void printCellAtMP();
- void readToCellAtMP();
- void loopStart();
- void loopEnd();
-
-public:
- BFI(const std::string& code) :
- mCode(code), mIP(0), mMP(0), mMemoryUsed(0),mMemory{0}
- {
- mBrackets.reserve(mCode.length());
- }
- void interpret();
- void printUsedMemory();
-};
-
-#endif // BFI_H
diff --git a/homework/81625/Brainfuck-Interpretator/src/main.cpp b/homework/81625/Brainfuck-Interpretator/src/main.cpp
deleted file mode 100644
index 7003a78..0000000
--- a/homework/81625/Brainfuck-Interpretator/src/main.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "BFI.h"
-
-int main()
-{
- std::string helloWorld = "++++++++++[>+>+++>+++++++>++++++++++<<<<-]>>>++.>+.+++++++..+++.<<++.>+++++++++++++++.>.+++.------.--------.<<+.<.";
- std::string squares = "++++[>+++++<-]>[<+++++>-]+<+[>[>+>+<<-]++>>[<<+>>-]>>>[-]++>[-]+>>>+[[-]++++++>>>]<<<[[<++++++++<++>>-]+<.<[>----<-]<]<<[>>>>>[>>>[-]+++++++++<[>-<-]+++++++++>[-[<->-]+[<<<]]<[>+<-]>]<<-]<<-]";
- std::string beer = ">++++++++++[<++++++++++>-]<->>>>>+++[>+++>+++<<-]<<<<+<[>[>+>+<<-]>>[-<<+>>]++++"
- ">+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[[-]>>>>>>[[-]<++++++++++<->>]<-[>+>+<<-]>[<+>"
- "-]+>[[-]<->]<<<<<<<<<->>]<[>+>+<<-]>>[-<<+>>]+>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<"
- "<[>>+>+<<<-]>>>[-<<<+>>>]++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[>+<[-]]<[>>+<<[-]]"
- ">>[<<+>>[-]]<<<[>>+>+<<<-]>>>[-<<<+>>>]++++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[>+"
- "<[-]]<[>>+<<[-]]>>[<<+>>[-]]<<[[-]>>>++++++++[>>++++++<<-]>[<++++++++[>++++++<-]"
- ">.<++++++++[>------<-]>[<<+>>-]]>.<<++++++++[>>------<<-]<[->>+<<]<++++++++[<+++"
- "+>-]<.>+++++++[>+++++++++<-]>+++.<+++++[>+++++++++<-]>.+++++..--------.-------.+"
- "+++++++++++++>>[>>>+>+<<<<-]>>>>[-<<<<+>>>>]>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<<<"
- "[>>>+>+<<<<-]>>>>[-<<<<+>>>>]+>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<<[>>+<<[-]]>[>+<"
- "[-]]++>>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<+<[[-]>-<]>[<<<<<<<.>>>>>>>[-]]<<<<<<<<<"
- ".>>----.---------.<<.>>----.+++..+++++++++++++.[-]<<[-]]<[>+>+<<-]>>[-<<+>>]+>+<"
- "[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<<[>>+>+<<<-]>>>[-<<<+>>>]++++>+<[-<->]<[[-]>>-<<]"
- ">>[[-]<<+>>]<<[>+<[-]]<[>>+<<[-]]>>[<<+>>[-]]<<[[-]>++++++++[<++++>-]<.>++++++++"
- "++[>+++++++++++<-]>+.-.<<.>>++++++.------------.---.<<.>++++++[>+++<-]>.<++++++["
- ">----<-]>++.+++++++++++..[-]<<[-]++++++++++.[-]]<[>+>+<<-]>>[-<<+>>]+++>+<[-<->]"
- "<[[-]>>-<<]>>[[-]<<+>>]<<[[-]++++++++++.>+++++++++[>+++++++++<-]>+++.+++++++++++"
- "++.++++++++++.------.<++++++++[>>++++<<-]>>.<++++++++++.-.---------.>.<-.+++++++"
- "++++.++++++++.---------.>.<-------------.+++++++++++++.----------.>.<+++++++++++"
- "+.---------------.<+++[>++++++<-]>..>.<----------.+++++++++++.>.<<+++[>------<-]"
- ">-.+++++++++++++++++.---.++++++.-------.----------.[-]>[-]<<<.[-]]<[>+>+<<-]>>[-"
- "<<+>>]++++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[[-]++++++++++.[-]<[-]>]<+<]";
- std::string triangle = ">++++[<++++++++>-]>++++++++[>++++<-]>>++>>>+>>>+<<<<<<<<<<[-[->+<]>[-<+>>>.<<]>>>[[->++++++++[>++++<-]>.<<[->+<]+>[->++++++++++<<+>]>.[-]>]]+<<<[-[->+<]+>[-<+>>>-[->+<]++>[-<->]<<<]<<<<]++++++++++.+++.[-]<]+++++";
-
-
- BFI bfi(beer);
- bfi.interpret();
- bfi.printUsedMemory();
- return 0;
-}
-
diff --git a/homework/81625/Brainfuck-Interpretator/src/run.sh b/homework/81625/Brainfuck-Interpretator/src/run.sh
deleted file mode 100644
index edbb3e4..0000000
--- a/homework/81625/Brainfuck-Interpretator/src/run.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-g++ -std=c++11 main.cpp BFI.cpp -o run
-./run
-rm run
diff --git a/homework/81625/cpp2html/.gitignore b/homework/81625/cpp2html/.gitignore
deleted file mode 100644
index c53f09b..0000000
--- a/homework/81625/cpp2html/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-cpp2html
-Lexer.h~
-Lexer.cpp~
-main.cpp~
-.gitignore~
diff --git a/homework/81625/cpp2html/cpp2.html b/homework/81625/cpp2html/cpp2.html
deleted file mode 100644
index 3c37e5e..0000000
--- a/homework/81625/cpp2html/cpp2.html
+++ /dev/null
@@ -1,41 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <style>
- body {
- font-size: 20px;
- }
-
- .number {
- color: pink;
- }
-
- .string {
- color: blue;
- }
-
- .keyword {
- color: purple;
- font-weight: bold;
- }
-
- .operator {
- color: red;
- }
-
- .comment {
- color: gray;
- font-style: italic;
- }
-
- .preprocessor {
- color: green;
- font-weight: bold;
- }
-
- </style>
-</head>
-<body>
-<span class="preprocessor">#include</span><span class="operator"><</span>iostream<span class="operator">></span><br><span class="keyword">bool</span>&nbspisCapitalCase<span class="operator">(</span><span class="keyword">char</span>&nbspc<span class="operator">)</span><br><span class="operator">{</span><br>&nbsp&nbsp&nbsp&nbsp<span class="keyword">return</span>&nbspc&nbsp<span class="operator">>=</span>&nbsp<span class="string">'A'</span>&nbsp<span class="operator">&&</span>&nbspc&nbsp<span class="operator"><=</span>&nbsp<span class="string">'Z'</span><span class="operator">;</span><br><span class="operator">}</span><br>m_KeyWordsTable<span class="operator">[</span><span class="string">"break"</span><span class="operator">]</span>&nbsp<span class="operator">=</span>&nbspTokenType<span class="operator">::</span>Break<span class="operator">;</span><br><span class="comment">// this is a comment test</span><br><span class="comment">/* another one */</span>
-</body>
-</html> \ No newline at end of file
diff --git a/homework/81625/cpp2html/src/Lexer.cpp b/homework/81625/cpp2html/src/Lexer.cpp
deleted file mode 100644
index 63d208b..0000000
--- a/homework/81625/cpp2html/src/Lexer.cpp
+++ /dev/null
@@ -1,689 +0,0 @@
-#include "Lexer.h"
-
-bool isDigit(char c)
-{
- return c >= '0' && c <= '9';
-}
-
-bool isLowerCase(char c)
-{
- return c >= 'a' && c <= 'z';
-}
-
-bool isCapitalCase(char c)
-{
- return c >= 'A' && c <= 'Z';
-}
-
-
-Tokenizer::Tokenizer(const char* code) :
- line(1), column(0), codeIndex(0), code(code), state(State::SUCCESS)
-{
- keywords["alignas"] = TokenType::ALIGNAS;
- keywords["alignof"] = TokenType::ALIGNOF;
- keywords["and"] = TokenType::AND;
- keywords["and_eq"] = TokenType::AND_EQ;
- keywords["asm"] = TokenType::ASM;
- keywords["auto"] = TokenType::AUTO;
- keywords["bitand"] = TokenType::BITAND;
- keywords["bitor"] = TokenType::BITOR;
- keywords["bool"] = TokenType::BOOL;
- keywords["break"] = TokenType::BREAK;
- keywords["case"] = TokenType::CASE;
- keywords["catch"] = TokenType::CATCH;
- keywords["char"] = TokenType::CHAR;
- keywords["char16_t"] = TokenType::CHAR16_T;
- keywords["char32_t"] = TokenType::CHAR32_T;
- keywords["class"] = TokenType::CLASS;
- keywords["compl"] = TokenType::COMPL;
- keywords["const"] = TokenType::CONST;
- keywords["constexpr"] = TokenType::CONSTEXPR;
- keywords["const_cast"] = TokenType::CONST_CAST;
- keywords["continue"] = TokenType::CONTINUE;
- keywords["decltype"] = TokenType::DECLTYPE;
- keywords["default"] = TokenType::DEFAULT;
- keywords["delete"] = TokenType::DELETE;
- keywords["do"] = TokenType::DO;
- keywords["double"] = TokenType::DOUBLE;
- keywords["dynamic_cast"] = TokenType::DYNAMIC_CAST;
- keywords["else"] = TokenType::ELSE;
- keywords["enum"] = TokenType::ENUM;
- keywords["explicit"] = TokenType::EXPLICIT;
- keywords["export"] = TokenType::EXPORT;
- keywords["extern"] = TokenType::EXTERN;
- keywords["false"] = TokenType::FALSE;
- keywords["float"] = TokenType::FLOAT;
- keywords["for"] = TokenType::FOR;
- keywords["friend"] = TokenType::FRIEND;
- keywords["goto"] = TokenType::GOTO;
- keywords["if"] = TokenType::IF;
- keywords["inline"] = TokenType::INLINE;
- keywords["int"] = TokenType::INT;
- keywords["long"] = TokenType::LONG;
- keywords["mutable"] = TokenType::MUTABLE;
- keywords["namespace"] = TokenType::NAMESPACE;
- keywords["new"] = TokenType::NEW;
- keywords["noexcept"] = TokenType::NOEXCEPT;
- keywords["not"] = TokenType::NOT;
- keywords["not_eq"] = TokenType::NOT_EQ;
- keywords["nullptr"] = TokenType::NULLPTR;
- keywords["operator"] = TokenType::OPERATOR;
- keywords["or"] = TokenType::OR;
- keywords["or_eq"] = TokenType::OR_EQ;
- keywords["private"] = TokenType::PRIVATE;
- keywords["protected"] = TokenType::PROTECTED;
- keywords["public"] = TokenType::PUBLIC;
- keywords["register"] = TokenType::REGISTER;
- keywords["reinterpret_cast"]= TokenType::REINTERPRET_CAST;
- keywords["return"] = TokenType::RETURN;
- keywords["short"] = TokenType::SHORT;
- keywords["signed"] = TokenType::SIGNED;
- keywords["sizeof"] = TokenType::SIZEOF;
- keywords["static"] = TokenType::STATIC;
- keywords["static_assert"] = TokenType::STATIC_ASSERT;
- keywords["static_cast"] = TokenType::STATIC_CAST;
- keywords["struct"] = TokenType::STRUCT;
- keywords["switch"] = TokenType::SWITCH;
- keywords["template"] = TokenType::TEMPLATE;
- keywords["this"] = TokenType::THIS;
- keywords["thread_local"] = TokenType::THREAD_LOCAL;
- keywords["throw"] = TokenType::THROW;
- keywords["true"] = TokenType::TRUE;
- keywords["try"] = TokenType::TRY;
- keywords["typedef"] = TokenType::TYPEDEF;
- keywords["typeid"] = TokenType::TYPEID;
- keywords["typename"] = TokenType::TYPENAME;
- keywords["union"] = TokenType::UNION;
- keywords["unsigned"] = TokenType::UNSIGNED;
- keywords["using"] = TokenType::USING;
- keywords["virtual"] = TokenType::VIRTUAL;
- keywords["void"] = TokenType::VOID;
- keywords["volatile"] = TokenType::VOLATILE;
- keywords["wchar_t"] = TokenType::WCHAR_T;
- keywords["while"] = TokenType::WHILE;
- keywords["xor"] = TokenType::XOR;
- keywords["xor_eq"] = TokenType::XOR_EQ;
-
- preprocessors["#define"] = TokenType::PRE_DEFINE;
- preprocessors["#undef"] = TokenType::PRE_UNDEF;
- preprocessors["#include"] = TokenType::PRE_INCLUDE;
- preprocessors["#if"] = TokenType::PRE_IF;
- preprocessors["#ifdef"] = TokenType::PRE_IFDEF;
- preprocessors["#ifndef"] = TokenType::PRE_IFNDEF;
- preprocessors["#else"] = TokenType::PRE_ELSE;
- preprocessors["#elif"] = TokenType::PRE_ELIF;
- preprocessors["#endif"] = TokenType::PRE_ENDIF;
- preprocessors["#line"] = TokenType::PRE_LINE;
- preprocessors["#error"] = TokenType::PRE_ERROR;
- preprocessors["#pragma"] = TokenType::PRE_PRAGMA;
-}
-
-bool Tokenizer::isAtEOF() const
-{
- return code[codeIndex] == '\0';
-}
-
-bool Tokenizer::match(char c) const
-{
- return code[codeIndex] == c;
-}
-
-bool Tokenizer::isStateError() const
-{
- return state == State::ERROR;
-}
-
-bool Tokenizer::isStateSuccess() const
-{
- return state == State::SUCCESS;
-}
-
-bool Tokenizer::tokenize(std::vector<Token> &tokens)
-{
- Token token;
- do
- {
- token = nextToken();
- if(token.type == TokenType::INVALID)
- {
- return false;
- }
- tokens.push_back(token);
-
- } while(token.type != TokenType::Eof);
-
- return true;
-}
-
-void Tokenizer::skipWhiteSpaces()
-{
- while(true)
- {
- if(code[codeIndex] == ' ' || code[codeIndex] == '\t')
- {
- column++;
- }
- else if(code[codeIndex] == '\n')
- {
- column = 0;
- line++;
- }
- else
- {
- break;
- }
- codeIndex++;
- }
-}
-
-void Tokenizer::nextSymbol()
-{
- codeIndex++;
- column++;
-}
-
-void Tokenizer::prevSymbol()
-{
- codeIndex--;
- column--;
-}
-
-double Tokenizer::parseNumber()
-{
- try
- {
- size_t bytes = 0;
- double d = std::stod(code + codeIndex, &bytes);
- codeIndex += static_cast<unsigned>(bytes);
- column += static_cast<unsigned>(bytes);
- state = State::SUCCESS;
- return d;
- }
- catch(std::invalid_argument &e)
- {
- state = State::FAIL;
- return 0;
- }
- catch(std::out_of_range &e)
- {
- state = State::ERROR;
- return 0;
- }
-}
-
-std::string Tokenizer::parseComment()
-{
- if(code[codeIndex] == '/')
- {
- unsigned start = codeIndex;
- nextSymbol();
- if(code[codeIndex] == '/')
- {
- nextSymbol();
- while(code[codeIndex] != '\n')
- {
- nextSymbol();
- }
- state = State::SUCCESS;
- return std::string(code, start, codeIndex-start);
- }
- if(code[codeIndex] == '*')
- {
- nextSymbol();
- bool flag = true;
- while(flag)
- {
- while(code[codeIndex] != '*' && !isAtEOF())
- {
- nextSymbol();
- }
-
- if(isAtEOF())
- {
- state = State::ERROR;
- return "";
- }
-
- nextSymbol();
- if(code[codeIndex] == '/')
- {
- nextSymbol();
- flag = false;
- }
- }
- state = State::SUCCESS;
- return std::string(code, start, codeIndex-start);
- }
- }
-
- state = State::FAIL;
- return "";
-}
-
-std::string Tokenizer::parseString()
-{
- // not a string
- if(code[codeIndex] != '\'' && code[codeIndex] != '"' )
- {
- state = State::FAIL;
- return "";
- }
-
- const char bound = code[codeIndex];
- const unsigned start = codeIndex;
-
- nextSymbol();
- while(true)
- {
- while(code[codeIndex] != bound && !isAtEOF() && code[codeIndex] != '\n')
- {
- nextSymbol();
- }
-
- if(code[codeIndex] == bound)
- {
- // escaping character
- if(code[codeIndex-1] != '\\')
- {
- nextSymbol();
- state = State::SUCCESS;
- return std::string(code, start, codeIndex-start);
- }
- else
- {
- codeIndex++;
- }
- }
- else break;
- }
-
- // not a correct string
- state = State::ERROR;
- return "";
-}
-
-Token Tokenizer::parseKeyword()
-{
- if(!isLowerCase(code[codeIndex]))
- {
- state = State::FAIL;
- return produceToken(TokenType::INVALID);
- }
-
- const unsigned start = codeIndex;
- nextSymbol();
- while(isLowerCase(code[codeIndex]) || isDigit(code[codeIndex]) || code[codeIndex] == '_')
- {
- nextSymbol();
- }
-
- const std::string key = std::string(code, start, codeIndex-start);
- const auto keyword = keywords.find(key);
-
- if(keyword == keywords.end())
- {
- column -= codeIndex-start;
- codeIndex = start;
- state = State::FAIL;
- return produceToken(TokenType::INVALID);
- }
-
- state = State::SUCCESS;
- return produceToken(keyword->second, keyword->first);
-}
-
-Token Tokenizer::parsePreprocessor()
-{
- // not a preprocessor
- if(code[codeIndex] != '#')
- {
- state = State::FAIL;
- return produceToken(TokenType::INVALID);
- }
-
- const unsigned start = codeIndex;
- nextSymbol();
- while(isLowerCase(code[codeIndex]))
- {
- nextSymbol();
- }
-
- const std::string key = std::string(code, start, codeIndex-start);
- const auto preproc = preprocessors.find(key);
-
- if(preproc == preprocessors.end())
- {
- column -= codeIndex-start;
- codeIndex = start;
- state = State::FAIL;
- return produceToken(TokenType::INVALID);
- }
- state = State::SUCCESS;
- return produceToken(preproc->second, preproc->first);
-}
-
-std::string Tokenizer::parseIdentifier()
-{
- if(!isLowerCase(code[codeIndex]) && !isCapitalCase(code[codeIndex]) && code[codeIndex] != '_')
- {
- state = State::FAIL;
- return "";
- }
-
- const unsigned start = codeIndex;
-
- nextSymbol();
- while(isLowerCase(code[codeIndex]) || isCapitalCase(code[codeIndex]) ||
- isDigit(code[codeIndex]) || code[codeIndex] == '_')
- {
- nextSymbol();
- }
-
- state = State::SUCCESS;
- return std::string(code, start, codeIndex-start);
-}
-
-Token Tokenizer::produceToken(TokenType type, std::string lexeme, double val)
-{
- return Token{type, line, lexeme, val};
-}
-
-Token Tokenizer::produceToken(TokenType type)
-{
- switch(type)
- {
- case TokenType::LEFT_PAREN: return produceToken(type, "(");
- case TokenType::RIGHT_PAREN: return produceToken(type, ")");
- case TokenType::LEFT_BRACKET: return produceToken(type, "[");
- case TokenType::RIGHT_BRACKET: return produceToken(type, "]");
- case TokenType::LEFT_CUR_BRAC: return produceToken(type, "{");
- case TokenType::RIGHT_CUR_BRAC: return produceToken(type, "}");
- case TokenType::PLUS: return produceToken(type, "+");
- case TokenType::MINUS: return produceToken(type, "-");
- case TokenType::MULTIPLICATION: return produceToken(type, "*");
- case TokenType::DIVIDE: return produceToken(type, "/");
- case TokenType::MODULO: return produceToken(type, "%");
- case TokenType::LESSER: return produceToken(type, "<");
- case TokenType::GREATER: return produceToken(type, ">");
- case TokenType::ASSIGN: return produceToken(type, "=");
- case TokenType::SEMI_COLON: return produceToken(type, ";");
- case TokenType::QUESTION_MARK: return produceToken(type, "?");
- case TokenType::EXCLAMATION_MARK: return produceToken(type, "!");
- case TokenType::COLON: return produceToken(type, ":");
- case TokenType::BITWISE_AND: return produceToken(type, "&");
- case TokenType::BITWISE_OR: return produceToken(type, "|");
- case TokenType::BITWISE_XOR: return produceToken(type, "^");
- case TokenType::BITWISE_NOT: return produceToken(type, "~");
- case TokenType::DOT: return produceToken(type, ".");
- case TokenType::SCOPE: return produceToken(type, "::");
- case TokenType::PLUS_PLUS: return produceToken(type, "++");
- case TokenType::MINUS_MINUS: return produceToken(type, "--");
- case TokenType::PTR_ARROW: return produceToken(type, "->");
- case TokenType::LEFT_BITWISE_SHIFT: return produceToken(type, "<<");
- case TokenType::RIGHT_BITWISE_SHIFT: return produceToken(type, ">>");
- case TokenType::EQUAL: return produceToken(type, "==");
- case TokenType::NOT_EQUAL: return produceToken(type, "!=");
- case TokenType::LESS_EQUAL: return produceToken(type, "<=");
- case TokenType::GREATER_EQUAL: return produceToken(type, ">=");
- case TokenType::LOGIC_AND: return produceToken(type, "&&");
- case TokenType::LOGIC_OR: return produceToken(type, "||");
- case TokenType::MOD_EQUAL: return produceToken(type, "%=");
- case TokenType::MULT_EQUAL: return produceToken(type, "*=");
- case TokenType::DIV_EQUAL: return produceToken(type, "/=");
- case TokenType::PLUS_EQUAL: return produceToken(type, "+=");
- case TokenType::MINUS_EQUAL: return produceToken(type, "-=");
- case TokenType::BIT_AND_EQUAL: return produceToken(type, "&=");
- case TokenType::BIT_OR_EQUAL: return produceToken(type, "|=");
- case TokenType::BIT_XOR_EQUAL: return produceToken(type, "^=");
- case TokenType::LEFT_SHIFT_EQUAL: return produceToken(type, "<<=");
- case TokenType::RIGHT_SHIFT_EQUAL: return produceToken(type, ">>=");
- default: return produceToken(type, "");
- }
-}
-
-Token Tokenizer::nextToken()
-{
- if(isAtEOF())
- {
- return produceToken(TokenType::Eof);
- }
-
- skipWhiteSpaces();
-
- // comments
- std::string comment = parseComment();
- if(isStateSuccess())
- {
- return produceToken(TokenType::COMMENT, comment);
- }
-
- // preprocessors
- Token preproc = parsePreprocessor();
- if(isStateSuccess())
- {
- return preproc;
- }
-
- switch(code[codeIndex])
- {
- case '(':
- nextSymbol();
- return produceToken(TokenType::LEFT_PAREN);
- case ')':
- nextSymbol();
- return produceToken(TokenType::RIGHT_PAREN);
- case '[':
- nextSymbol();
- return produceToken(TokenType::LEFT_BRACKET);
- case ']':
- nextSymbol();
- return produceToken(TokenType::RIGHT_BRACKET);
- case '{':
- nextSymbol();
- return produceToken(TokenType::LEFT_CUR_BRAC);
- case '}':
- nextSymbol();
- return produceToken(TokenType::RIGHT_CUR_BRAC);
- case '+':
- nextSymbol();
- if(match('+'))
- {
- nextSymbol();
- return produceToken(TokenType::PLUS_PLUS);
- }
- if(match('='))
- {
- nextSymbol();
- return produceToken(TokenType::PLUS_EQUAL);
- }
- return produceToken(TokenType::PLUS);
- case '-':
- nextSymbol();
- if(match('-'))
- {
- nextSymbol();
- return produceToken(TokenType::MINUS_MINUS);
- }
- if(match('='))
- {
- nextSymbol();
- return produceToken(TokenType::MINUS_EQUAL);
- }
- if(match('>'))
- {
- nextSymbol();
- return produceToken(TokenType::PTR_ARROW);
- }
- return produceToken(TokenType::MINUS);
- case '*':
- nextSymbol();
- if(match('='))
- {
- nextSymbol();
- return produceToken(TokenType::MULT_EQUAL);
- }
- return produceToken(TokenType::MULTIPLICATION);
- case '/':
- nextSymbol();
- if(match('='))
- {
- nextSymbol();
- return produceToken(TokenType::DIV_EQUAL);
- }
- return produceToken(TokenType::DIVIDE);
- case '%':
- nextSymbol();
- if(match('='))
- {
- nextSymbol();
- return produceToken(TokenType::MOD_EQUAL);
- }
- return produceToken(TokenType::MODULO);
- case '<':
- nextSymbol();
- if(match('<'))
- {
- nextSymbol();
- if(match('='))
- {
- nextSymbol();
- return produceToken(TokenType::LEFT_SHIFT_EQUAL);
- }
- return produceToken(TokenType::LEFT_BITWISE_SHIFT);
- }
- if(match('='))
- {
- nextSymbol();
- return produceToken(TokenType::LESS_EQUAL);
- }
- return produceToken(TokenType::LESSER);
- case '>':
- nextSymbol();
- if(match('>'))
- {
- nextSymbol();
- if(match('='))
- {
- nextSymbol();
- return produceToken(TokenType::RIGHT_SHIFT_EQUAL);
- }
- return produceToken(TokenType::RIGHT_BITWISE_SHIFT);
- }
- if(match('='))
- {
- nextSymbol();
- return produceToken(TokenType::GREATER_EQUAL);
- }
- return produceToken(TokenType::GREATER);
- case '=':
- nextSymbol();
- if(match('='))
- {
- nextSymbol();
- return produceToken(TokenType::EQUAL);
- }
- return produceToken(TokenType::ASSIGN);
- case ';':
- nextSymbol();
- return produceToken(TokenType::SEMI_COLON);
- case '?':
- nextSymbol();
- return produceToken(TokenType::QUESTION_MARK);
- case '!':
- nextSymbol();
- if(match('='))
- {
- nextSymbol();
- return produceToken(TokenType::NOT_EQUAL);
- }
- return produceToken(TokenType::EXCLAMATION_MARK);
- case ':':
- nextSymbol();
- if(match(':'))
- {
- nextSymbol();
- return produceToken(TokenType::SCOPE);
- }
- return produceToken(TokenType::COLON);
- case '&':
- nextSymbol();
- if(match('&'))
- {
- nextSymbol();
- return produceToken(TokenType::LOGIC_AND);
- }
- if(match('='))
- {
- nextSymbol();
- return produceToken(TokenType::BIT_AND_EQUAL);
- }
- return produceToken(TokenType::BITWISE_AND);
- case '|':
- nextSymbol();
- if(match('|'))
- {
- nextSymbol();
- return produceToken(TokenType::LOGIC_AND);
- }
- if(match('='))
- {
- nextSymbol();
- return produceToken(TokenType::BIT_OR_EQUAL);
- }
- return produceToken(TokenType::BITWISE_OR);
- case '^':
- nextSymbol();
- if(match('='))
- {
- nextSymbol();
- return produceToken(TokenType::BIT_XOR_EQUAL);
- }
- return produceToken(TokenType::BITWISE_XOR);
- case '~':
- nextSymbol();
- return produceToken(TokenType::BITWISE_NOT);
- case '.':
- nextSymbol();
- return produceToken(TokenType::DOT);
- default: break;
- }
-
- // number literals
- double num = parseNumber();
- if(isStateSuccess())
- {
- return produceToken(TokenType::NUMBER, "", num);
- }
- else if(isStateError())
- {
- return produceToken(TokenType::INVALID);
- }
-
- // string literals
- std::string lex = parseString();
- if(isStateSuccess())
- {
- return produceToken(TokenType::STRING, lex);
- }
- else if(isStateError())
- {
- return produceToken(TokenType::INVALID);
- }
-
- // keywords
- Token tkn = parseKeyword();
- if(isStateSuccess())
- {
- return tkn;
- }
-
- // identifiers
- std::string identifier = parseIdentifier();
- if(isStateSuccess())
- {
- return produceToken(TokenType::IDENTIFIER, identifier);
- }
-
- return produceToken(TokenType::INVALID);
-}
-
diff --git a/homework/81625/cpp2html/src/Lexer.h b/homework/81625/cpp2html/src/Lexer.h
deleted file mode 100644
index 92c2f53..0000000
--- a/homework/81625/cpp2html/src/Lexer.h
+++ /dev/null
@@ -1,223 +0,0 @@
-#ifndef LEXER_H
-#define LEXER_H
-
-#include <vector>
-#include <map>
-#include <string>
-
-enum TokenType
-{
-// Single character tokens
- LEFT_PAREN = 1, // (
- RIGHT_PAREN, // )
- LEFT_BRACKET, // [
- RIGHT_BRACKET, // ]
- LEFT_CUR_BRAC, // {
- RIGHT_CUR_BRAC, // }
- PLUS, // +
- MINUS, // -
- MULTIPLICATION, // *
- DIVIDE, // /
- MODULO, // %
- LESSER, // <
- GREATER, // >
- ASSIGN, // =
- SEMI_COLON, // ;
- QUESTION_MARK, // ?
- EXCLAMATION_MARK, // !
- COLON, // :
- BITWISE_AND, // &
- BITWISE_OR, // |
- BITWISE_XOR, // ^
- BITWISE_NOT, // ~
- DOT, // .
-
-// Double character tokens
- SCOPE, // ::
- PLUS_PLUS, // ++
- MINUS_MINUS, // --
- PTR_ARROW, // ->
- LEFT_BITWISE_SHIFT, // <<
- RIGHT_BITWISE_SHIFT,// >>
- EQUAL, // ==
- NOT_EQUAL, // !=
- LESS_EQUAL, // <=
- GREATER_EQUAL, // >=
- LOGIC_AND, // &&
- LOGIC_OR, // ||
- MOD_EQUAL, // %=
- MULT_EQUAL, // *=
- DIV_EQUAL, // /=
- PLUS_EQUAL, // +=
- MINUS_EQUAL, // -=
- BIT_AND_EQUAL, // &=
- BIT_OR_EQUAL, // |=
- BIT_XOR_EQUAL, // ^=
-
-// Three character tokens
- LEFT_SHIFT_EQUAL, // <<=
- RIGHT_SHIFT_EQUAL, // >>=
-
-// Keyword Tokens
- ALIGNAS,
- ALIGNOF,
- AND,
- AND_EQ,
- ASM,
- AUTO,
- BITAND,
- BITOR,
- BOOL,
- BREAK,
- CASE,
- CATCH,
- CHAR,
- CHAR16_T,
- CHAR32_T,
- CLASS,
- COMPL,
- CONST,
- CONSTEXPR,
- CONST_CAST,
- CONTINUE,
- DECLTYPE,
- DEFAULT,
- DELETE,
- DO,
- DOUBLE,
- DYNAMIC_CAST,
- ELSE,
- ENUM,
- EXPLICIT,
- EXPORT,
- EXTERN,
- FALSE,
- FLOAT,
- FOR,
- FRIEND,
- GOTO,
- IF,
- INLINE,
- INT,
- LONG,
- MUTABLE,
- NAMESPACE,
- NEW,
- NOEXCEPT,
- NOT,
- NOT_EQ,
- NULLPTR,
- OPERATOR,
- OR,
- OR_EQ,
- PRIVATE,
- PROTECTED,
- PUBLIC,
- REGISTER,
- REINTERPRET_CAST,
- RETURN,
- SHORT,
- SIGNED,
- SIZEOF,
- STATIC,
- STATIC_ASSERT,
- STATIC_CAST,
- STRUCT,
- SWITCH,
- TEMPLATE,
- THIS,
- THREAD_LOCAL,
- THROW,
- TRUE,
- TRY,
- TYPEDEF,
- TYPEID,
- TYPENAME,
- UNION,
- UNSIGNED,
- USING,
- VIRTUAL,
- VOID,
- VOLATILE,
- WCHAR_T,
- WHILE,
- XOR,
- XOR_EQ,
-
- // preprocessors
- PRE_DEFINE,
- PRE_UNDEF,
- PRE_INCLUDE,
- PRE_IF,
- PRE_IFDEF,
- PRE_IFNDEF,
- PRE_ELSE,
- PRE_ELIF,
- PRE_ENDIF,
- PRE_LINE,
- PRE_ERROR,
- PRE_PRAGMA,
-
- NUMBER,
- IDENTIFIER,
- STRING,
- COMMENT,
- Eof,
- INVALID
-};
-
-enum State
-{
- FAIL,
- SUCCESS,
- ERROR
-};
-
-struct Token
-{
- TokenType type;
- unsigned line;
- std::string lexeme;
- double value;
-};
-
-class Tokenizer
-{
-private:
- const char* code;
- unsigned line;
- unsigned column;
- unsigned codeIndex;
- State state;
- std::map<std::string, TokenType> keywords;
- std::map<std::string, TokenType> preprocessors;
-
-public:
- Tokenizer(const char* code);
- Token nextToken();
- Token produceToken(TokenType type, std::string lexeme, double val = 0.0);
- Token produceToken(TokenType type);
-
- bool isAtEOF() const;
- bool match(char c) const;
- bool isStateError() const;
- bool isStateSuccess() const;
- bool tokenize(std::vector<Token> &tokens);
-
- double parseNumber();
- std::string parseComment();
- std::string parseString();
- Token parseKeyword();
- Token parsePreprocessor();
- std::string parseIdentifier();
-
- void skipWhiteSpaces();
- void nextSymbol();
- void prevSymbol();
-
-};
-
-//#include "Lexer.cpp"
-
-#endif
-
diff --git a/homework/81625/cpp2html/src/main.cpp b/homework/81625/cpp2html/src/main.cpp
deleted file mode 100644
index 92f4d30..0000000
--- a/homework/81625/cpp2html/src/main.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-#include <iostream>
-#include <fstream>
-#include <vector>
-#include "Lexer.h"
-
-void printTokens(std::vector<Token> &tokens)
-{
- for(int i = 0;i<tokens.size();i++)
- {
- std::cout<<tokens[i].type<<" "<<tokens[i].lexeme <<" on line " << tokens[i].line <<std::endl;
- }
-}
-
-void cpp2html(std::vector<Token> &tokens, const char* code)
-{
- std::ofstream out("../cpp2.html");
- std::string header = "<!DOCTYPE html>\n"
- "<html lang=\"en\">\n"
- "<head>\n"
- " <style>\n"
- " body {\n"
- " font-size: 20px;\n"
- " }\n\n"
- " .number {\n"
- " color: pink;\n"
- " }\n\n"
- " .string {\n"
- " color: blue;\n"
- " }\n\n"
- " .keyword {\n"
- " color: purple;\n"
- " font-weight: bold;\n"
- " }\n\n"
- " .operator {\n"
- " color: red;\n"
- " }\n\n"
- " .comment {\n"
- " color: gray;\n"
- " font-style: italic;\n"
- " }\n\n"
- " .preprocessor {\n"
- " color: green;\n"
- " font-weight: bold;\n"
- " }\n\n"
- " </style>\n"
- "</head>\n"
- "<body>\n";
- out << header;
- unsigned codeInd = 0;
- for(int i = 0;i < tokens.size();i++)
- {
- while(code[codeInd] == ' ' || code[codeInd] == '\t' || code[codeInd] == '\n')
- {
- if(code[codeInd] == '\n') out << "<br>";
- else out << "&nbsp";
- //else out <<
- ++codeInd;
- }
- if(tokens[i].type == TokenType::NUMBER)
- {
- out << "<span class=\"number\">" << tokens[i].value <<"</span>";
- }
- else if(tokens[i].type == TokenType::STRING)
- {
- out << "<span class=\"string\">" << tokens[i].lexeme <<"</span>";
- }
- else if(tokens[i].type == TokenType::COMMENT)
- {
- out << "<span class=\"comment\">" << tokens[i].lexeme <<"</span>";
- }
- else if(tokens[i].type <= TokenType::RIGHT_SHIFT_EQUAL)
- {
- out << "<span class=\"operator\">" << tokens[i].lexeme <<"</span>";
- }
- else if(tokens[i].type <= TokenType::XOR_EQ)
- {
- out << "<span class=\"keyword\">" << tokens[i].lexeme <<"</span>";
- }
- else if(tokens[i].type <= TokenType::PRE_PRAGMA)
- {
- out << "<span class=\"preprocessor\">" << tokens[i].lexeme <<"</span>";
- }
- else
- {
- out << tokens[i].lexeme;
- }
- codeInd += tokens[i].lexeme.length();
- }
- out << "\n</body>\n</html>";
- out.close();
-}
-
-int main()
-{
- char code[] = "#include<iostream>\nbool isCapitalCase(char c)\n{\n return c >= 'A' && c <= 'Z';\n}\nm_KeyWordsTable[\"break\"] = TokenType::Break;\n// this is a comment test\n"
- "/* another one */";
- Tokenizer tokenizer(code);
- std::vector<Token> tokens;
-
- if(tokenizer.tokenize(tokens))
- {
- cpp2html(tokens, code);
- }
- //printTokens(tokens);
- return 0;
-}
-
diff --git a/homework/81709/.gitignore b/homework/81709/.gitignore
deleted file mode 100644
index f00a0eb..0000000
--- a/homework/81709/.gitignore
+++ /dev/null
@@ -1,334 +0,0 @@
-## Ignore Visual Studio temporary files, build results, and
-## files generated by popular Visual Studio add-ons.
-##
-## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
-
-# User-specific files
-*.rsuser
-*.suo
-*.user
-*.userosscache
-*.sln.docstates
-
-# User-specific files (MonoDevelop/Xamarin Studio)
-*.userprefs
-
-# Build results
-[Dd]ebug/
-[Dd]ebugPublic/
-[Rr]elease/
-[Rr]eleases/
-x64/
-x86/
-bld/
-[Bb]in/
-[Oo]bj/
-[Ll]og/
-
-# Visual Studio 2015/2017 cache/options directory
-.vs/
-# Uncomment if you have tasks that create the project's static files in wwwroot
-#wwwroot/
-
-# Visual Studio 2017 auto generated files
-Generated\ Files/
-
-# MSTest test Results
-[Tt]est[Rr]esult*/
-[Bb]uild[Ll]og.*
-
-# NUNIT
-*.VisualState.xml
-TestResult.xml
-
-# Build Results of an ATL Project
-[Dd]ebugPS/
-[Rr]eleasePS/
-dlldata.c
-
-# Benchmark Results
-BenchmarkDotNet.Artifacts/
-
-# .NET Core
-project.lock.json
-project.fragment.lock.json
-artifacts/
-
-# StyleCop
-StyleCopReport.xml
-
-# Files built by Visual Studio
-*_i.c
-*_p.c
-*_h.h
-*.ilk
-*.meta
-*.obj
-*.iobj
-*.pch
-*.pdb
-*.ipdb
-*.pgc
-*.pgd
-*.rsp
-*.sbr
-*.tlb
-*.tli
-*.tlh
-*.tmp
-*.tmp_proj
-*_wpftmp.csproj
-*.log
-*.vspscc
-*.vssscc
-.builds
-*.pidb
-*.svclog
-*.scc
-
-# Chutzpah Test files
-_Chutzpah*
-
-# Visual C++ cache files
-ipch/
-*.aps
-*.ncb
-*.opendb
-*.opensdf
-*.sdf
-*.cachefile
-*.VC.db
-*.VC.VC.opendb
-
-# Visual Studio profiler
-*.psess
-*.vsp
-*.vspx
-*.sap
-
-# Visual Studio Trace Files
-*.e2e
-
-# TFS 2012 Local Workspace
-$tf/
-
-# Guidance Automation Toolkit
-*.gpState
-
-# ReSharper is a .NET coding add-in
-_ReSharper*/
-*.[Rr]e[Ss]harper
-*.DotSettings.user
-
-# JustCode is a .NET coding add-in
-.JustCode
-
-# TeamCity is a build add-in
-_TeamCity*
-
-# DotCover is a Code Coverage Tool
-*.dotCover
-
-# AxoCover is a Code Coverage Tool
-.axoCover/*
-!.axoCover/settings.json
-
-# Visual Studio code coverage results
-*.coverage
-*.coveragexml
-
-# NCrunch
-_NCrunch_*
-.*crunch*.local.xml
-nCrunchTemp_*
-
-# MightyMoose
-*.mm.*
-AutoTest.Net/
-
-# Web workbench (sass)
-.sass-cache/
-
-# Installshield output folder
-[Ee]xpress/
-
-# DocProject is a documentation generator add-in
-DocProject/buildhelp/
-DocProject/Help/*.HxT
-DocProject/Help/*.HxC
-DocProject/Help/*.hhc
-DocProject/Help/*.hhk
-DocProject/Help/*.hhp
-DocProject/Help/Html2
-DocProject/Help/html
-
-# Click-Once directory
-publish/
-
-# Publish Web Output
-*.[Pp]ublish.xml
-*.azurePubxml
-# Note: Comment the next line if you want to checkin your web deploy settings,
-# but database connection strings (with potential passwords) will be unencrypted
-*.pubxml
-*.publishproj
-
-# Microsoft Azure Web App publish settings. Comment the next line if you want to
-# checkin your Azure Web App publish settings, but sensitive information contained
-# in these scripts will be unencrypted
-PublishScripts/
-
-# NuGet Packages
-*.nupkg
-# The packages folder can be ignored because of Package Restore
-**/[Pp]ackages/*
-# except build/, which is used as an MSBuild target.
-!**/[Pp]ackages/build/
-# Uncomment if necessary however generally it will be regenerated when needed
-#!**/[Pp]ackages/repositories.config
-# NuGet v3's project.json files produces more ignorable files
-*.nuget.props
-*.nuget.targets
-
-# Microsoft Azure Build Output
-csx/
-*.build.csdef
-
-# Microsoft Azure Emulator
-ecf/
-rcf/
-
-# Windows Store app package directories and files
-AppPackages/
-BundleArtifacts/
-Package.StoreAssociation.xml
-_pkginfo.txt
-*.appx
-
-# Visual Studio cache files
-# files ending in .cache can be ignored
-*.[Cc]ache
-# but keep track of directories ending in .cache
-!*.[Cc]ache/
-
-# Others
-ClientBin/
-~$*
-*~
-*.dbmdl
-*.dbproj.schemaview
-*.jfm
-*.pfx
-*.publishsettings
-orleans.codegen.cs
-
-# Including strong name files can present a security risk
-# (https://github.com/github/gitignore/pull/2483#issue-259490424)
-#*.snk
-
-# Since there are multiple workflows, uncomment next line to ignore bower_components
-# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
-#bower_components/
-
-# RIA/Silverlight projects
-Generated_Code/
-
-# Backup & report files from converting an old project file
-# to a newer Visual Studio version. Backup files are not needed,
-# because we have git ;-)
-_UpgradeReport_Files/
-Backup*/
-UpgradeLog*.XML
-UpgradeLog*.htm
-ServiceFabricBackup/
-*.rptproj.bak
-
-# SQL Server files
-*.mdf
-*.ldf
-*.ndf
-
-# Business Intelligence projects
-*.rdl.data
-*.bim.layout
-*.bim_*.settings
-*.rptproj.rsuser
-
-# Microsoft Fakes
-FakesAssemblies/
-
-# GhostDoc plugin setting file
-*.GhostDoc.xml
-
-# Node.js Tools for Visual Studio
-.ntvs_analysis.dat
-node_modules/
-
-# Visual Studio 6 build log
-*.plg
-
-# Visual Studio 6 workspace options file
-*.opt
-
-# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
-*.vbw
-
-# Visual Studio LightSwitch build output
-**/*.HTMLClient/GeneratedArtifacts
-**/*.DesktopClient/GeneratedArtifacts
-**/*.DesktopClient/ModelManifest.xml
-**/*.Server/GeneratedArtifacts
-**/*.Server/ModelManifest.xml
-_Pvt_Extensions
-
-# Paket dependency manager
-.paket/paket.exe
-paket-files/
-
-# FAKE - F# Make
-.fake/
-
-# JetBrains Rider
-.idea/
-*.sln.iml
-
-# CodeRush personal settings
-.cr/personal
-
-# Python Tools for Visual Studio (PTVS)
-__pycache__/
-*.pyc
-
-# Cake - Uncomment if you are using it
-# tools/**
-# !tools/packages.config
-
-# Tabs Studio
-*.tss
-
-# Telerik's JustMock configuration file
-*.jmconfig
-
-# BizTalk build output
-*.btp.cs
-*.btm.cs
-*.odx.cs
-*.xsd.cs
-
-# OpenCover UI analysis results
-OpenCover/
-
-# Azure Stream Analytics local run output
-ASALocalRun/
-
-# MSBuild Binary and Structured Log
-*.binlog
-
-# NVidia Nsight GPU debugger configuration file
-*.nvuser
-
-# MFractors (Xamarin productivity tool) working folder
-.mfractor/
-
-# Local History for Visual Studio
-.localhistory/ \ No newline at end of file
diff --git a/homework/81709/JSCompiler.Core.Tests/BaseInputStreamFileTests.cs b/homework/81709/JSCompiler.Core.Tests/BaseInputStreamFileTests.cs
deleted file mode 100644
index ebc557c..0000000
--- a/homework/81709/JSCompiler.Core.Tests/BaseInputStreamFileTests.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.IO;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace JSCompiler.Core.Tests
-{
- [TestClass]
- public class BaseInputStreamTests
- {
- [TestMethod]
- public void IsEndOfStream_WhenNotEnd_ReturnsFalse()
- {
- byte[] buff = new byte[3] { 32, 14, 25 };
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream testInputStream = new BaseInputStream(memStream);
-
- bool isEnd;
- for(int i = 0; i < 2; i++)
- {
- isEnd = testInputStream.IsEndOfStream();
- testInputStream.Next();
- Assert.IsFalse(isEnd);
- }
- }
-
- [TestMethod]
- public void IsEndOfStream_AtBeginningWithoutData_ReturnsTrue()
- {
- MemoryStream memStream = new MemoryStream();
- BaseInputStream testInputStream = new BaseInputStream(memStream);
-
- bool isEnd = testInputStream.IsEndOfStream();
-
- Assert.IsTrue(isEnd);
- }
-
- [TestMethod]
- public void IsEndOfStream_WhenEnd_ReturnsTrue()
- {
- byte[] buff = new byte[3] { 32, 14, 25 };
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream testInputStream = new BaseInputStream(memStream);
-
- for (int i = 0; i < 3; i++, testInputStream.Next());
- bool isEnd = testInputStream.IsEndOfStream();
-
- Assert.IsTrue(isEnd);
- }
-
- [TestMethod]
- public void Peek_AtPosition_ReturnsCorrectItemFromStream()
- {
- byte[] buff = new byte[8] { 32, 14, 25, 14, 12, 51, 25, 33 };
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream testInputStream = new BaseInputStream(memStream);
- char item;
-
- for (int i = 0; i < 5; i++, testInputStream.Next())
- {
- item = testInputStream.Peek();
- Assert.AreEqual((char)buff[i], item);
- }
- }
-
- [TestMethod]
- public void Peek_AtEnd_ReturnsEndItem()
- {
- byte[] buff = new byte[3] { 32, 14, 25 };
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream testInputStream = new BaseInputStream(memStream);
-
- for (int i = 0; i < 3; i++, testInputStream.Next());
- char last = testInputStream.Peek();
-
- Assert.AreEqual(0, last);
- }
-
- [TestMethod]
- [ExpectedException(typeof(EndOfStreamException))]
- public void Next_WhenEndStream_ThrowsEndOfStreamException()
- {
- byte[] buff = new byte[3] { 32, 14, 25 };
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream testInputStream = new BaseInputStream(memStream);
-
- for (int i = 0; i < 4; i++, testInputStream.Next());
- }
-
- [TestMethod]
- public void Next_WhenBuffersAreSwapped_ReturnsCorrectItem()
- {
- byte[] buff = new byte[10] { 32, 14, 25, 14, 23, 42, 16, 21, 15, 76 };
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream testInputStream = new BaseInputStream(memStream, 3);
-
- for (int i = 0; i < 10; i++)
- {
- char curr = testInputStream.Next();
- Assert.AreEqual((char)buff[i], curr);
- }
- }
-
- [TestMethod]
- public void Line_NewLinesTracking_ReturnsCorrectNumberOfLines()
- {
- byte[] buff = new byte[10] { (byte) '\n', 32, 14, 25, 14, (byte) '\n', 42, 16, (byte) '\n', (byte)'\n' };
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream testInputStream = new BaseInputStream(memStream);
-
- for (int i = 0; i < 10; i++, testInputStream.Next());
-
- Assert.AreEqual(4, testInputStream.Line);
- }
- }
-}
diff --git a/homework/81709/JSCompiler.Core.Tests/JSCompiler.Core.Tests.csproj b/homework/81709/JSCompiler.Core.Tests/JSCompiler.Core.Tests.csproj
deleted file mode 100644
index 838feb3..0000000
--- a/homework/81709/JSCompiler.Core.Tests/JSCompiler.Core.Tests.csproj
+++ /dev/null
@@ -1,75 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" />
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{F2211B16-C27C-40D6-A856-8A6B5A3787EF}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>JSCompiler.Core.Tests</RootNamespace>
- <AssemblyName>JSCompiler.Core.Tests</AssemblyName>
- <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
- <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
- <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
- <IsCodedUITest>False</IsCodedUITest>
- <TestProjectType>UnitTest</TestProjectType>
- <NuGetPackageImportStamp>
- </NuGetPackageImportStamp>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <HintPath>..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
- </Reference>
- <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <HintPath>..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="BaseInputStreamFileTests.cs" />
- <Compile Include="LexerTests.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- </ItemGroup>
- <ItemGroup>
- <None Include="packages.config" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\JSCompiler.Core\JSCompiler.Core.csproj">
- <Project>{C8DD3D07-6AE9-444B-8BA0-22DC633A9432}</Project>
- <Name>JSCompiler.Core</Name>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
- <PropertyGroup>
- <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
- </PropertyGroup>
- <Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props'))" />
- <Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets'))" />
- </Target>
- <Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" />
-</Project> \ No newline at end of file
diff --git a/homework/81709/JSCompiler.Core.Tests/LexerTests.cs b/homework/81709/JSCompiler.Core.Tests/LexerTests.cs
deleted file mode 100644
index 92df168..0000000
--- a/homework/81709/JSCompiler.Core.Tests/LexerTests.cs
+++ /dev/null
@@ -1,576 +0,0 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using JSCompiler.Core;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.IO;
-using System.Threading.Tasks;
-
-namespace JSCompiler.Core.Tests
-{
- [TestClass()]
- public class LexerTests
- {
-
- [TestMethod]
- public void Tokenize_Tab_ReturnsTabToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes("\t ");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
-
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Tab),
- new Token(TokenType.Whitespace),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_SkipCarriageReturn_ReturnsNextToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes("\r\r");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
-
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_WhiteSpace_ReturnsWhitespaceToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes(" ");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
-
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Whitespace),
- new Token(TokenType.Whitespace),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_MultilineComment_ReturnsCommentToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes("/* \n\n**\n this is comment */**");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
- List<Token> expected = new List<Token>
- {
- new WordToken("/* \n\n**\n this is comment */", TokenType.Comment),
- new Token(TokenType.Star),
- new Token(TokenType.Star),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_MultilineCommentUnclosed_ReturnsCommentTokenAndCallsOnError()
- {
- byte[] buff = Encoding.ASCII.GetBytes("/* \n\n**\n this is comment ** ////gvj");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.AreEqual(Lexer.UNCLOSED_MULTILINE_COMMENT, cause));
- List<Token> expected = new List<Token>
- {
- new WordToken("/* \n\n**\n this is comment ** ////gvj", TokenType.Comment),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_SingleLineCommentStopOnCarriageReturn_ReturnsCommentToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes("// some comment here \r\n*");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
- List<Token> expected = new List<Token>
- {
- new WordToken("// some comment here ", TokenType.Comment),
- new Token(TokenType.NewLine),
- new Token(TokenType.Star),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_SingleLineCommentStopOnNewLine_ReturnsCommentToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes("// some comment here \n\n*");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
- List<Token> expected = new List<Token>
- {
- new WordToken("// some comment here ", TokenType.Comment),
- new Token(TokenType.NewLine),
- new Token(TokenType.NewLine),
- new Token(TokenType.Star),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_SingleLineCommentStopOnEndStream_ReturnsCommentToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes("// some comment here ");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
- List<Token> expected = new List<Token>
- {
- new WordToken("// some comment here ", TokenType.Comment),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_Operators_ReturnsOperatorTokens()
- {
- byte[] buff = Encoding.ASCII.GetBytes("(){},.-+;*/%~&^|?:[]=!><\\=====!==!=>=<=--++>><<&&||*=/=%=+=-=<<=>>=&=^=|=");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.LeftParen),
- new Token(TokenType.RightParen),
- new Token(TokenType.LeftBrace),
- new Token(TokenType.RightBrace),
- new Token(TokenType.Comma),
- new Token(TokenType.Dot),
- new Token(TokenType.Minus),
- new Token(TokenType.Plus),
- new Token(TokenType.Semicolon),
- new Token(TokenType.Star),
- new Token(TokenType.Division),
- new Token(TokenType.Modulo),
- new Token(TokenType.BitwiseNot),
- new Token(TokenType.BitwiseAnd),
- new Token(TokenType.BitwiseXor),
- new Token(TokenType.BitwiseOr),
- new Token(TokenType.QuestionMark),
- new Token(TokenType.Colon),
- new Token(TokenType.LeftSquareBracket),
- new Token(TokenType.RightSquareBracket),
- new Token(TokenType.Equal),
- new Token(TokenType.Bang),
- new Token(TokenType.Greater),
- new Token(TokenType.Less),
- new Token(TokenType.Backslash),
-
- new WordToken("===", TokenType.StrictEqual),
- new WordToken("==", TokenType.EqualEqual),
- new WordToken("!==", TokenType.StrictNotEqual),
- new WordToken("!=", TokenType.NotEqual),
- new WordToken(">=", TokenType.GreaterEqual),
- new WordToken("<=", TokenType.LessEqual),
- new WordToken("--", TokenType.MinusMinus),
- new WordToken("++", TokenType.PlusPlus),
- new WordToken(">>", TokenType.RightShift),
- new WordToken("<<", TokenType.LeftShift),
- new WordToken("&&", TokenType.LogicalAnd),
- new WordToken("||", TokenType.LogicalOr),
- new WordToken("*=", TokenType.StarEqual),
- new WordToken("/=", TokenType.DivideEqual),
- new WordToken("%=", TokenType.ModuloEqual),
- new WordToken("+=", TokenType.PlusEqual),
- new WordToken("-=", TokenType.MinusEqual),
- new WordToken("<<=", TokenType.LeftShiftEqual),
- new WordToken(">>=", TokenType.RightShiftEqual),
- new WordToken("&=", TokenType.BitwiseAndEqual),
- new WordToken("^=", TokenType.BitwiseXorEqual),
- new WordToken("|=", TokenType.BitwiseOrEqual),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_StringDoubleQuotes_ReturnsStringToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes(" \"This is string\" ");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Whitespace),
- new WordToken("\"This is string\"", TokenType.String),
- new Token(TokenType.Whitespace),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_StringDoubleQuotesUnclosed_ReturnsStringTokenAndCallsOnError()
- {
- byte[] buff = Encoding.ASCII.GetBytes(" \"This is string ");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.AreEqual(cause, Lexer.UNCLOSED_STRING));
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Whitespace),
- new WordToken("\"This is string ", TokenType.Error),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_StringDoubleQuotesUnclosedNewLine_ReturnsStringTokenAndCallsOnError()
- {
- byte[] buff = Encoding.ASCII.GetBytes(" \"This is string \n \" \r\n");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.AreEqual(cause, Lexer.UNCLOSED_STRING_NEWLINE));
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Whitespace),
- new WordToken("\"This is string ", TokenType.Error),
- new Token(TokenType.NewLine),
- new Token(TokenType.Whitespace),
- new WordToken("\" ", TokenType.Error),
- new Token(TokenType.NewLine),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_StringDoubleQuotesEscapeNewLine_ReturnsStringToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes(" \"This is string \\\r\n \\\n +\"");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Whitespace),
- new WordToken("\"This is string \\\r\n \\\n +\"", TokenType.String),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_StringDoubleQuotesEscapeDoubleQuote_ReturnsStringToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes(" \"This is string \\\"inner\\\" \"");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Whitespace),
- new WordToken("\"This is string \\\"inner\\\" \"", TokenType.String),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_StringDoubleQuotesEscapeBackslash_ReturnsStringToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes(" \"This is string \\\\ or this \\ \"");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Whitespace),
- new WordToken("\"This is string \\\\ or this \\ \"", TokenType.String),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_StringDoubleQuotesSingleQuotesCombination_ReturnsStringToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes(" \"This is string 'inner'\"");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Whitespace),
- new WordToken("\"This is string 'inner'\"", TokenType.String),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_StringSingleQuotes_ReturnsStringToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes(" 'This is string' ");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Whitespace),
- new WordToken("'This is string'", TokenType.String),
- new Token(TokenType.Whitespace),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_StringSingleQuotesUnclosed_ReturnsStringTokenAndCallsOnError()
- {
- byte[] buff = Encoding.ASCII.GetBytes(" 'This is string ");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.AreEqual(cause, Lexer.UNCLOSED_STRING));
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Whitespace),
- new WordToken("'This is string ", TokenType.Error),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_StringSingleQuotesUnclosedNewLine_ReturnsStringTokenAndCallsOnError()
- {
- byte[] buff = Encoding.ASCII.GetBytes(" 'This is string \n ' \r\n");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.AreEqual(cause, Lexer.UNCLOSED_STRING_NEWLINE));
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Whitespace),
- new WordToken("'This is string ", TokenType.Error),
- new Token(TokenType.NewLine),
- new Token(TokenType.Whitespace),
- new WordToken("' ", TokenType.Error),
- new Token(TokenType.NewLine),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_StringSingleQuotesEscapeNewLine_ReturnsStringToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes(" 'This is string \\\r\n \\\n +'");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Whitespace),
- new WordToken("'This is string \\\r\n \\\n +'", TokenType.String),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_StringSingleQuotesEscapeDoubleQuote_ReturnsStringToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes(" 'This is string \\'inner\\' '");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Whitespace),
- new WordToken("'This is string \\'inner\\' '", TokenType.String),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_StringSingleQuotesEscapeBackslash_ReturnsStringToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes(" 'This is string \\\\ or this \\ '");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Whitespace),
- new WordToken("'This is string \\\\ or this \\ '", TokenType.String),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_StringSingleQuotesSingleQuotesCombination_ReturnsStringToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes(" 'This is string \"inner\"'");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Whitespace),
- new WordToken("'This is string \"inner\"'", TokenType.String),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_Number_ReturnsNumberToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes(" 1234");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Whitespace),
- new NumToken(1234),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_ReservedOrIdentifier_ReturnsReservedToken()
- {
- byte[] buff = Encoding.ASCII.GetBytes(" Object var someIdentifier132 ");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.Fail());
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Whitespace),
- new WordToken("Object", TokenType.Object),
- new Token(TokenType.Whitespace),
- new WordToken("var", TokenType.Var),
- new Token(TokenType.Whitespace),
- new WordToken("someIdentifier132", TokenType.Identifier),
- new Token(TokenType.Whitespace),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
-
- [TestMethod]
- public void Tokenize_UnresolvedSymbol_ReturnsUnidentifiedTokenAndCallsOnError()
- {
- byte[] buff = Encoding.ASCII.GetBytes(" Object `");
- MemoryStream memStream = new MemoryStream(buff);
- BaseInputStream inputStream = new BaseInputStream(memStream);
- Lexer lexer = new Lexer(inputStream);
-
- List<Token> tokens = lexer.Tokenize((line, cause) => Assert.AreEqual(cause, Lexer.UNIDENTIFIED_SYMBOL));
- List<Token> expected = new List<Token>
- {
- new Token(TokenType.Whitespace),
- new WordToken("Object", TokenType.Object),
- new Token(TokenType.Whitespace),
- new WordToken("`", TokenType.Error),
- new Token(TokenType.EOF)
- };
-
- CollectionAssert.AreEqual(tokens, expected);
- }
- }
-} \ No newline at end of file
diff --git a/homework/81709/JSCompiler.Core.Tests/Properties/AssemblyInfo.cs b/homework/81709/JSCompiler.Core.Tests/Properties/AssemblyInfo.cs
deleted file mode 100644
index 8cbad7f..0000000
--- a/homework/81709/JSCompiler.Core.Tests/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("JSCompiler.Core.Tests")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("JSCompiler.Core.Tests")]
-[assembly: AssemblyCopyright("Copyright © 2018")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-[assembly: ComVisible(false)]
-
-[assembly: Guid("f2211b16-c27c-40d6-a856-8a6b5a3787ef")]
-
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/homework/81709/JSCompiler.Core.Tests/packages.config b/homework/81709/JSCompiler.Core.Tests/packages.config
deleted file mode 100644
index 1eae809..0000000
--- a/homework/81709/JSCompiler.Core.Tests/packages.config
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="MSTest.TestAdapter" version="1.3.2" targetFramework="net471" />
- <package id="MSTest.TestFramework" version="1.3.2" targetFramework="net471" />
-</packages> \ No newline at end of file
diff --git a/homework/81709/JSCompiler.Core/BaseInputStream.cs b/homework/81709/JSCompiler.Core/BaseInputStream.cs
deleted file mode 100644
index 7145ce8..0000000
--- a/homework/81709/JSCompiler.Core/BaseInputStream.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using System;
-using System.IO;
-using System.Collections;
-using System.Collections.Generic;
-
-namespace JSCompiler.Core
-{
- public class BaseInputStream : IInputStream
- {
- private char[][] buffs;
-
- private int index;
-
- private int activeBuffer;
-
- private StreamReader reader;
-
- public BaseInputStream(Stream stream, int buffLength = 4096)
- {
- this.Line = 0;
- this.index = 0;
- this.activeBuffer = 0;
- this.buffs = new char[2][];
- this.buffs[0] = new char[buffLength];
- this.buffs[1] = new char[buffLength];
- this.reader = new StreamReader(stream);
-
- ReadStream(buffs[0], buffLength);
- }
-
- public BaseInputStream(string path, int buffLength = 4096)
- : this(new FileStream(path, FileMode.Open), buffLength) { }
-
- public int Line { get; private set; }
-
- public void Close()
- {
- reader.Close();
- }
-
- public bool IsEndOfStream()
- {
- return Peek() == 0;
- }
-
- public char Next()
- {
- if (IsEndOfStream()) throw new EndOfStreamException();
-
- char cur = Peek();
-
- if (cur == '\n')
- {
- Line++;
- }
-
- index++;
-
- if (index >= buffs[activeBuffer].Length)
- {
- SwitchBuffers();
- }
-
- return cur;
- }
-
- public char Peek()
- {
- return buffs[activeBuffer][index];
- }
-
- private void SwitchBuffers()
- {
- index = 0;
- activeBuffer = activeBuffer == 0 ? 1 : 0;
- ReadStream(buffs[activeBuffer], buffs[activeBuffer].Length);
- }
-
- private int ReadStream(char[] buffer, int length)
- {
- int bytesRead = reader.Read(buffer, 0, length);
-
- if (bytesRead < length)
- {
- buffer[bytesRead] = (char) 0;
- }
-
- return bytesRead;
- }
- }
-}
diff --git a/homework/81709/JSCompiler.Core/IInputStream.cs b/homework/81709/JSCompiler.Core/IInputStream.cs
deleted file mode 100644
index ced31d3..0000000
--- a/homework/81709/JSCompiler.Core/IInputStream.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace JSCompiler.Core
-{
- public interface IInputStream
- {
- void Close();
- bool IsEndOfStream();
- char Next();
- char Peek();
- int Line { get; }
- }
-}
diff --git a/homework/81709/JSCompiler.Core/JSCompiler.Core.csproj b/homework/81709/JSCompiler.Core/JSCompiler.Core.csproj
deleted file mode 100644
index 7b10dd1..0000000
--- a/homework/81709/JSCompiler.Core/JSCompiler.Core.csproj
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{C8DD3D07-6AE9-444B-8BA0-22DC633A9432}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>JSCompiler.Core</RootNamespace>
- <AssemblyName>JSCompiler.Core</AssemblyName>
- <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- <Deterministic>true</Deterministic>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Net.Http" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="IInputStream.cs" />
- <Compile Include="BaseInputStream.cs" />
- <Compile Include="Lexer.cs" />
- <Compile Include="NumToken.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="ReservedStrings.cs" />
- <Compile Include="Token.cs" />
- <Compile Include="TokenType.cs" />
- <Compile Include="Utils.cs" />
- <Compile Include="WordToken.cs" />
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-</Project> \ No newline at end of file
diff --git a/homework/81709/JSCompiler.Core/Lexer.cs b/homework/81709/JSCompiler.Core/Lexer.cs
deleted file mode 100644
index 18df998..0000000
--- a/homework/81709/JSCompiler.Core/Lexer.cs
+++ /dev/null
@@ -1,276 +0,0 @@
-using JSCompiler.Core;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace JSCompiler.Core
-{
- public class Lexer
- {
- public static readonly string UNCLOSED_MULTILINE_COMMENT = "Unclosed mulitline comment";
-
- public static readonly string UNCLOSED_STRING = "Unclosed string";
-
- public static readonly string UNCLOSED_STRING_NEWLINE = "Unclosed string newline";
-
- public static readonly string UNIDENTIFIED_SYMBOL = "Unidentified symbol";
-
-
- private Dictionary<string, TokenType> keywords;
-
- private Dictionary<string, TokenType> otherReserved;
-
- private IInputStream stream;
-
- public Lexer(IInputStream stream)
- {
- this.stream = stream;
- this.keywords = ReservedStrings.KeywordsAsMap();
- this.otherReserved = ReservedStrings.OthersAsMap();
- }
-
- public List<Token> Tokenize(Action<int, string> onError)
- {
- List<Token> tokens = new List<Token>();
- do
- {
- Token next = NextToken(onError);
- if(next.Type != TokenType.Skip)
- {
- tokens.Add(next);
- }
- } while (!stream.IsEndOfStream());
- tokens.Add(new Token(TokenType.EOF));
- return tokens;
- }
-
- public Token NextToken(Action<int, string> onError)
- {
- char cur = stream.Next();
-
- if (Utils.IsCarriageReturn(cur))
- return new Token(TokenType.Skip);
-
- if (Utils.IsWhiteSpace(cur))
- return new Token(TokenType.Whitespace);
-
- if (Utils.IsTab(cur))
- return new Token(TokenType.Tab);
-
- if (Utils.IsNewLine(cur))
- return new Token(TokenType.NewLine);
-
- switch (cur)
- {
- case '=':
- return Match('=') ? Match('=') ? new WordToken("===", TokenType.StrictEqual)
- : new WordToken("==", TokenType.EqualEqual)
- : new Token(TokenType.Equal);
- case '!':
- return Match('=') ? Match('=') ? new WordToken("!==", TokenType.StrictNotEqual)
- : new WordToken("!=", TokenType.NotEqual)
- : new Token(TokenType.Bang);
- case '>':
- return Match('=') ? new WordToken(">=", TokenType.GreaterEqual)
- : Match('>') ? Match('=') ? new WordToken(">>=", TokenType.RightShiftEqual)
- : new WordToken(">>", TokenType.RightShift)
- : new Token(TokenType.Greater);
- case '<':
- return Match('=') ? new WordToken("<=", TokenType.LessEqual)
- : Match('<') ? Match('=') ? new WordToken("<<=", TokenType.LeftShiftEqual)
- : new WordToken("<<", TokenType.LeftShift)
- : new Token(TokenType.Less);
- case '+':
- return Match('+') ? new WordToken("++", TokenType.PlusPlus)
- : Match('=') ? new WordToken("+=", TokenType.PlusEqual)
- : new Token(TokenType.Plus);
- case '-':
- return Match('-') ? new WordToken("--", TokenType.MinusMinus)
- : Match('=') ? new WordToken("-=", TokenType.MinusEqual)
- : new Token(TokenType.Minus);
- case '*':
- return Match('=') ? new WordToken("*=", TokenType.StarEqual)
- : new Token(TokenType.Star);
- case '/':
- return Match('/') ? ParseOneLineComment()
- : Match('*') ? ParseMultilineToken(onError)
- : Match('=') ? new WordToken("/=", TokenType.DivideEqual)
- : new Token(TokenType.Division);
- case '%':
- return Match('=') ? new WordToken("%=", TokenType.ModuloEqual)
- : new Token(TokenType.Modulo);
- case '^':
- return Match('=') ? new WordToken("^=", TokenType.BitwiseXorEqual)
- : new Token(TokenType.BitwiseXor);
- case '|':
- return Match('=') ? new WordToken("|=", TokenType.BitwiseOrEqual)
- : Match('|') ? new WordToken("||", TokenType.LogicalOr)
- : new Token(TokenType.BitwiseOr);
- case '&':
- return Match('=') ? new WordToken("&=", TokenType.BitwiseAndEqual)
- : Match('&') ? new WordToken("&&", TokenType.LogicalAnd)
- : new Token(TokenType.BitwiseAnd);
- default:
- break;
- }
-
- if (cur < 127 && Enum.IsDefined(typeof(TokenType), (int)cur))
- return new Token((TokenType)cur);
-
- if(Utils.IsStringSingleQuote(cur) || Utils.IsStringDoubleQuote(cur))
- {
- return ParseSingleQuoteString(cur, onError);
- }
-
- if (char.IsDigit(cur))
- {
- return ParseNumber(cur);
- }
-
- if (char.IsLetter(cur))
- {
- return ParseReservedOrIdentifier(cur);
- }
-
- onError(stream.Line, UNIDENTIFIED_SYMBOL);
- return new WordToken(cur.ToString(), TokenType.Error);
- }
-
- private bool Match(char ch)
- {
- if(stream.Peek() == ch)
- {
- stream.Next();
- return true;
- }
- return false;
- }
-
- private Token ParseOneLineComment()
- {
- string lexeme = "//";
- char peek = stream.Peek();
- while(!Utils.IsNewLine(peek) && !Utils.IsCarriageReturn(peek) && !stream.IsEndOfStream())
- {
- lexeme += stream.Next();
- peek = stream.Peek();
- }
- return new WordToken(lexeme, TokenType.Comment);
- }
-
- private Token ParseMultilineToken(Action<int, string> onError)
- {
- string lexeme = "/*";
- int lineBeg = stream.Line + 1;
- while (!stream.IsEndOfStream())
- {
- while (stream.Peek() != '*')
- {
- if (stream.IsEndOfStream())
- {
- onError(lineBeg, UNCLOSED_MULTILINE_COMMENT);
- return new WordToken(lexeme, TokenType.Comment);
- }
-
- lexeme += stream.Next();
- };
- lexeme += stream.Next();
- if (stream.Peek() == '/')
- {
- lexeme += stream.Next();
- return new WordToken(lexeme, TokenType.Comment);
- }
- }
- onError(lineBeg, UNCLOSED_MULTILINE_COMMENT);
- return new WordToken(lexeme, TokenType.Comment);
- }
-
- private Token ParseSingleQuoteString(char quote, Action<int, string> onError)
- {
- string lexeme = "" + quote;
- int startLine = stream.Line + 1;
- char peek = stream.Peek();
- while(peek != quote)
- {
- if (Utils.IsNewLine(peek) || Utils.IsCarriageReturn(peek))
- {
- onError(startLine, UNCLOSED_STRING_NEWLINE);
- return new WordToken(lexeme, TokenType.Error);
- }
-
- if (stream.IsEndOfStream())
- {
- onError(startLine, UNCLOSED_STRING);
- return new WordToken(lexeme, TokenType.Error);
- }
-
- lexeme += peek;
- stream.Next();
-
- if(peek == '\\')
- {
- char next = stream.Peek();
-
- if (next == quote || next == '\\')
- {
- lexeme += next;
- stream.Next();
- }
- else
- {
- if (Utils.IsCarriageReturn(next)) //Skip Carriage return
- {
- lexeme += stream.Next();
- next = stream.Peek();
- }
- if (Utils.IsNewLine(next))
- {
- lexeme += stream.Next();
- }
- }
- }
-
- peek = stream.Peek();
- }
-
- lexeme += stream.Next();
- return new WordToken(lexeme, TokenType.String);
- }
-
- private Token ParseNumber(char cur)
- {
- long num = cur - '0';
- char peek = stream.Peek();
- while (char.IsDigit(peek) && !stream.IsEndOfStream())
- {
- num = num * 10 + (stream.Next() - '0');
- peek = stream.Peek();
- }
- return new NumToken(num);
- }
-
- private Token ParseReservedOrIdentifier(char ch)
- {
- string lexeme = "" + ch;
-
- while (char.IsLetterOrDigit(stream.Peek()) && !stream.IsEndOfStream())
- {
- lexeme += stream.Next();
- }
-
- TokenType reservedType;
-
- keywords.TryGetValue(lexeme, out reservedType);
- if(reservedType != 0)
- return new WordToken(lexeme, reservedType);
-
- otherReserved.TryGetValue(lexeme, out reservedType);
- if(reservedType != 0)
- return new WordToken(lexeme, reservedType);
-
- return new WordToken(lexeme, TokenType.Identifier);
- }
- }
-}
diff --git a/homework/81709/JSCompiler.Core/NumToken.cs b/homework/81709/JSCompiler.Core/NumToken.cs
deleted file mode 100644
index 53af034..0000000
--- a/homework/81709/JSCompiler.Core/NumToken.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace JSCompiler.Core
-{
- public class NumToken : Token, IEquatable<NumToken>
- {
- public NumToken(long num) : base(TokenType.Number)
- {
- Num = num;
- }
-
- public long Num { get; private set; }
-
- public bool Equals(NumToken other)
- {
- return other.Num == Num && base.Equals((Token)other);
- }
-
- public override bool Equals(object obj)
- {
- var item = obj as NumToken;
-
- if (item == null) return false;
-
- return Equals(item);
- }
-
- public override int GetHashCode()
- {
- return Num.GetHashCode() * 17 + base.GetHashCode();
- }
-
- public override string ToString()
- {
- return Num.ToString();
- }
- }
-}
diff --git a/homework/81709/JSCompiler.Core/Properties/AssemblyInfo.cs b/homework/81709/JSCompiler.Core/Properties/AssemblyInfo.cs
deleted file mode 100644
index ead40a3..0000000
--- a/homework/81709/JSCompiler.Core/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("JSCompiler.Core")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("JSCompiler.Core")]
-[assembly: AssemblyCopyright("Copyright © 2018")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("c8dd3d07-6ae9-444b-8ba0-22dc633a9432")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/homework/81709/JSCompiler.Core/ReservedStrings.cs b/homework/81709/JSCompiler.Core/ReservedStrings.cs
deleted file mode 100644
index 261e444..0000000
--- a/homework/81709/JSCompiler.Core/ReservedStrings.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace JSCompiler.Core
-{
- public static class ReservedStrings
- {
- public static Dictionary<string, TokenType> KeywordsAsMap()
- {
- return new Dictionary<string, TokenType>
- {
- {"break", TokenType.Break },
- {"case", TokenType.Case },
- {"catch", TokenType.Catch },
- {"class", TokenType.Class },
- {"const", TokenType.Const },
- {"continue", TokenType.Continue },
- {"debugger", TokenType.Debugger },
- {"default", TokenType.Default },
- {"delete", TokenType.Delete },
- {"do" , TokenType.Do },
- {"else", TokenType.Else },
- {"export", TokenType.Export },
- {"extends", TokenType.Extends },
- {"finally", TokenType.Finally },
- {"for", TokenType.For },
- {"function", TokenType.Function },
- {"if", TokenType.If },
- {"import", TokenType.Import },
- {"in", TokenType.In },
- {"instance", TokenType.Instanceof },
- {"new", TokenType.New },
- {"return", TokenType.Return },
- {"super", TokenType.Super },
- {"switch", TokenType.Switch },
- {"this", TokenType.This },
- {"throw", TokenType.Throw },
- {"try", TokenType.Try },
- {"typeof", TokenType.Typeof },
- {"var", TokenType.Var },
- {"let", TokenType.Let },
- {"void", TokenType.Void },
- {"while", TokenType.While },
- {"with", TokenType.With },
- {"yield", TokenType.Yield },
- {"null", TokenType.Null },
- {"true", TokenType.True },
- { "false", TokenType.False }
- };
- }
-
- public static Dictionary<string, TokenType> OthersAsMap()
- {
- return new Dictionary<string, TokenType>
- {
- {"Array", TokenType.Array },
- {"Date", TokenType.Date },
- {"eval", TokenType.Eval },
- {"hasOwnProperty", TokenType.HasOwnProperty },
- {"Infinity", TokenType.Infinity },
- {"isFinite", TokenType.IsFinite },
- {"isNaN", TokenType.IsNaN },
- {"isPrototypeOf", TokenType.IsPrototypeOf },
- {"length", TokenType.Length },
- {"Math" , TokenType.Math },
- {"NaN", TokenType.NaN },
- {"name", TokenType.Name },
- {"String", TokenType.StringObj },
- {"Number", TokenType.NumberObj },
- {"toString", TokenType.ToString },
- {"Object", TokenType.Object },
- {"undefined", TokenType.Undefined },
- {"prototype", TokenType.Prototype },
- {"valueOf", TokenType.ValueOf }
- };
- }
-
- }
-}
diff --git a/homework/81709/JSCompiler.Core/Token.cs b/homework/81709/JSCompiler.Core/Token.cs
deleted file mode 100644
index efa2dd8..0000000
--- a/homework/81709/JSCompiler.Core/Token.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace JSCompiler.Core
-{
- public class Token : IEquatable<Token>
- {
- public Token(TokenType type)
- {
- Type = type;
- }
-
- public TokenType Type { get; private set; }
-
- public override bool Equals(object obj)
- {
- var item = obj as Token;
-
- if(item == null)
- {
- return false;
- }
-
- return Equals(item);
- }
-
- public bool Equals(Token other)
- {
- return Type == other.Type;
- }
-
- public override int GetHashCode()
- {
- return this.Type.GetHashCode();
- }
-
- public override string ToString()
- {
- return ((char)Type).ToString();
- }
- }
-
-
-
-}
diff --git a/homework/81709/JSCompiler.Core/TokenType.cs b/homework/81709/JSCompiler.Core/TokenType.cs
deleted file mode 100644
index a65f7a2..0000000
--- a/homework/81709/JSCompiler.Core/TokenType.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace JSCompiler.Core
-{
- public enum TokenType
- {
- // Single-character token types mapped to ASCII codes
- LeftParen = 40, // (
- RightParen = 41, // )
- LeftBrace = 123, // {
- RightBrace = 125, // }
- Comma = 44, // ,
- Dot = 46, // .
- Minus = 45, // -
- Plus = 43, // +
- Semicolon = 59, // ;
- Star = 42, // *
- Division = 47, // /
- Modulo = 37, // %
- BitwiseNot = 126, // ~
- BitwiseAnd = 38, // &
- BitwiseXor = 94, // ^
- BitwiseOr = 124, // |
- QuestionMark = 63, // ?
- Colon = 58, // :
- LeftSquareBracket = 91, // [
- RightSquareBracket = 93, // ]
- Bang = 33, // !
- Equal = 61, // =
- Greater = 62, // >
- Less = 60, // <
- Backslash = 92, // \
-
- Invalid = 127,
- NewLine,
- Tab,
- Whitespace,
- Comment,
- EOF,
- Skip,
-
- NotEqual, // !=
- EqualEqual, // ==
- StrictEqual, // ===
- StrictNotEqual, // !==
- GreaterEqual, // >=
- LessEqual, // <=
- MinusMinus, // --
- PlusPlus, // ++
- LeftShift, // <<
- RightShift, // >>
- LogicalAnd, // &&
- LogicalOr, // ||
- StarEqual, // *=
- DivideEqual, // /=
- ModuloEqual, // %=
- PlusEqual, // +=
- MinusEqual, // -=
- LeftShiftEqual, // <<=
- RightShiftEqual, // >>=
- BitwiseAndEqual, // &=
- BitwiseXorEqual, // ^=
- BitwiseOrEqual, // |=
-
- Identifier,
- String,
- Number,
- Error,
-
- // Keywords. ECMAScript 2015
- Break,
- Case,
- Catch,
- Class,
- Const,
- Continue,
- Debugger,
- Default,
- Delete,
- Do,
- Else,
- Export,
- Extends,
- Finally,
- For,
- Function,
- If,
- Import,
- In,
- Instanceof,
- New,
- Return,
- Super,
- Switch,
- This,
- Throw,
- Try,
- Typeof,
- Var,
- Let,
- Void,
- While,
- With,
- Yield,
- Null,
- True,
- False,
-
- //Objects and other
- Array,
- Date,
- Eval,
- HasOwnProperty,
- Infinity,
- IsFinite,
- IsNaN,
- IsPrototypeOf,
- Length,
- Math,
- NaN,
- Name,
- NumberObj,
- Object,
- Prototype,
- StringObj,
- ToString,
- Undefined,
- ValueOf
- }
-}
diff --git a/homework/81709/JSCompiler.Core/Utils.cs b/homework/81709/JSCompiler.Core/Utils.cs
deleted file mode 100644
index 17210bc..0000000
--- a/homework/81709/JSCompiler.Core/Utils.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace JSCompiler.Core
-{
- public static class Utils
- {
- public static bool IsWhiteSpace(char ch)
- {
- return ch == ' ';
- }
-
- public static bool IsCarriageReturn(char ch)
- {
- return ch == '\r';
- }
-
- public static bool IsNewLine(char ch)
- {
- return ch == '\n';
- }
-
- public static bool IsTab(char ch)
- {
- return ch == '\t';
- }
-
- public static bool IsStringSingleQuote(char ch)
- {
- return ch == '\'';
- }
-
- public static bool IsStringDoubleQuote(char ch)
- {
- return ch == '"';
- }
- }
-}
diff --git a/homework/81709/JSCompiler.Core/WordToken.cs b/homework/81709/JSCompiler.Core/WordToken.cs
deleted file mode 100644
index cee419e..0000000
--- a/homework/81709/JSCompiler.Core/WordToken.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace JSCompiler.Core
-{
- public class WordToken : Token, IEquatable<WordToken>
- {
- public WordToken(string lexeme, TokenType type) : base(type)
- {
- Lexeme = lexeme;
- }
-
- public string Lexeme { get; private set; }
-
- public override bool Equals(object obj)
- {
- var item = obj as WordToken;
-
- if(item == null)
- {
- return false;
- }
-
- return Equals(item);
- }
-
- public bool Equals(WordToken token)
- {
- return base.Equals((Token) token) && string.Equals(Lexeme, token.Lexeme);
- }
-
- public override int GetHashCode()
- {
- return Lexeme.GetHashCode() * 17 + base.GetHashCode();
- }
-
- public override string ToString()
- {
- return Lexeme;
- }
- }
-}
diff --git a/homework/81709/JSCompiler.SyntaxHighlighter/App.config b/homework/81709/JSCompiler.SyntaxHighlighter/App.config
deleted file mode 100644
index 62c8f44..0000000
--- a/homework/81709/JSCompiler.SyntaxHighlighter/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configuration>
- <startup>
- <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1"/>
- </startup>
-</configuration>
diff --git a/homework/81709/JSCompiler.SyntaxHighlighter/JSCompiler.SyntaxHighlighter.csproj b/homework/81709/JSCompiler.SyntaxHighlighter/JSCompiler.SyntaxHighlighter.csproj
deleted file mode 100644
index cb321ea..0000000
--- a/homework/81709/JSCompiler.SyntaxHighlighter/JSCompiler.SyntaxHighlighter.csproj
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{D555ADB4-0161-4DF9-8098-1A72C03C1576}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <RootNamespace>JSCompiler.SyntaxHighlighter</RootNamespace>
- <AssemblyName>JSCompiler.SyntaxHighlighter</AssemblyName>
- <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
- <TargetFrameworkProfile />
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <PlatformTarget>AnyCPU</PlatformTarget>
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <PlatformTarget>AnyCPU</PlatformTarget>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Net.Http" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Program.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="SyntaxHighlighter.cs" />
- </ItemGroup>
- <ItemGroup>
- <None Include="App.config">
- <SubType>Designer</SubType>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\JSCompiler.Core\JSCompiler.Core.csproj">
- <Project>{c8dd3d07-6ae9-444b-8ba0-22dc633a9432}</Project>
- <Name>JSCompiler.Core</Name>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-</Project> \ No newline at end of file
diff --git a/homework/81709/JSCompiler.SyntaxHighlighter/Program.cs b/homework/81709/JSCompiler.SyntaxHighlighter/Program.cs
deleted file mode 100644
index fd0d539..0000000
--- a/homework/81709/JSCompiler.SyntaxHighlighter/Program.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using JSCompiler.Core;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace JSCompiler.SyntaxHighlighter
-{
- class Program
- {
- static int Main(string[] args)
- {
- if(args.Length < 2)
- {
- Console.WriteLine("Input and output destinations not specified!");
- return 1;
- }
-
- try
- {
- BaseInputStream stream = new BaseInputStream(args[0]);
- Lexer lex = new Lexer(stream);
- List<Token> tokens = lex.Tokenize((line, cause) => Console.Out.WriteLine($"On line {line} error: {cause}"));
- SyntaxHighlighter.GenerateHtml(tokens, args[1]);
- }
- catch(Exception e)
- {
- Console.WriteLine(e.Message);
- return 1;
- }
-
- return 0;
- }
- }
-}
diff --git a/homework/81709/JSCompiler.SyntaxHighlighter/Properties/AssemblyInfo.cs b/homework/81709/JSCompiler.SyntaxHighlighter/Properties/AssemblyInfo.cs
deleted file mode 100644
index 6d5d657..0000000
--- a/homework/81709/JSCompiler.SyntaxHighlighter/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("JSCompiler.SyntaxHighlighter")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("JSCompiler.SyntaxHighlighter")]
-[assembly: AssemblyCopyright("Copyright © 2018")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("d555adb4-0161-4df9-8098-1a72c03c1576")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/homework/81709/JSCompiler.SyntaxHighlighter/SyntaxHighlighter.cs b/homework/81709/JSCompiler.SyntaxHighlighter/SyntaxHighlighter.cs
deleted file mode 100644
index fd8572f..0000000
--- a/homework/81709/JSCompiler.SyntaxHighlighter/SyntaxHighlighter.cs
+++ /dev/null
@@ -1,187 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.IO;
-using JSCompiler.Core;
-
-namespace JSCompiler.SyntaxHighlighter
-{
- public static class SyntaxHighlighter
- {
- private static readonly string HTML =
- @"<!DOCTYPE html>
-<html>
-<head>
-{0}
-<title> {1} </title>
-</head>
-<body> {2} </body></html>";
-
- private static readonly string DEFAULT_CSS =
- @"<style>
-body {
- font-size: 20px;
- font-family: ""Verdana"";
-}
-.number {
- color: Orange;
-}
-.string {
- color: Gray;
- white-space: pre-wrap;
-}
-.keyword {
- color: Blue;
-}
-.identifier {
- color: Black;
-}
-.operator {
- color: DarkBlue;
-}
-.comment {
- color: Green;
- font-style: italic;
- white-space: pre-wrap;
-}
-
-.reserved {
- color: MediumVioletRed;
-}
-
-.undefined{
- color: Black;
-}
-
-.default {
- color: DarkBlue;
-}
-</style>";
-
- private static IEnumerable<TokenType> KEYWORDS = ReservedStrings.KeywordsAsMap().Values;
-
- private static IEnumerable<TokenType> OTHER_RESERVED = ReservedStrings.OthersAsMap().Values;
-
- private static IEnumerable<TokenType> ONE_SYMBOL_OPERATORS = new List<TokenType>
- {
- TokenType.Minus, // -
- TokenType.Plus, // +
- TokenType.Star, // *
- TokenType.Division, // /
- TokenType.Modulo, // %
- TokenType.BitwiseNot, // ~
- TokenType.BitwiseAnd, // &
- TokenType.BitwiseXor, // ^
- TokenType.BitwiseOr, // |
- TokenType.QuestionMark, // ?
- TokenType.Bang, // !
- TokenType.Equal, // =
- TokenType.Greater, // >
- TokenType.Less, // <
- TokenType.Backslash, // \
- };
-
- private static IEnumerable<TokenType> MULT_SYMBOL_OPERATORS = new List<TokenType>
- {
- TokenType.NotEqual, // !=
- TokenType.EqualEqual, // ==
- TokenType.StrictEqual, // ===
- TokenType.StrictNotEqual, // !==
- TokenType.GreaterEqual, // >=
- TokenType.LessEqual, // <=
- TokenType.MinusMinus, // --
- TokenType.PlusPlus, // ++
- TokenType.LeftShift, // <<
- TokenType.RightShift, // >>
- TokenType.LogicalAnd, // &&
- TokenType.LogicalOr, // ||
- TokenType.StarEqual, // *=
- TokenType.DivideEqual, // /=
- TokenType.ModuloEqual, // %=
- TokenType.PlusEqual, // +=
- TokenType.MinusEqual, // -=
- TokenType.LeftShiftEqual, // <<=
- TokenType.RightShiftEqual, // >>=
- TokenType.BitwiseAndEqual, // &=
- TokenType.BitwiseXorEqual, // ^=
- TokenType.BitwiseOrEqual, // |=
- };
-
- public static void GenerateHtml(IEnumerable<Token> tokens, string fileName, string css = null)
- {
- if (css == null) css = DEFAULT_CSS;
-
- string code = "";
- IEnumerator<Token> tokenEnum = tokens.GetEnumerator();
- if (!tokenEnum.MoveNext()) return;
- Token cur;
- do
- {
- cur = tokenEnum.Current;
- TokenType type = cur.Type;
-
- switch (type)
- {
- case TokenType.Whitespace:
- code += "&nbsp";
- break;
- case TokenType.Tab:
- code += "&nbsp" + "&nbsp" + "&nbsp" + "&nbsp";
- break;
- case TokenType.NewLine:
- code += "<br>";
- break;
- case TokenType.Number:
- code += "<span class=\"number\">" + ((NumToken)cur).Num + "</span>";
- break;
- case TokenType.String:
- code += "<span class=\"string\">" + ((WordToken)cur).Lexeme + "</span>";
- break;
- case TokenType.Identifier:
- code += "<span class=\"identifier\">" + ((WordToken)cur).Lexeme + "</span>";
- break;
- case TokenType.Comment:
- code += "<span class=\"comment\">" + ((WordToken)cur).Lexeme + "</span>";
- break;
- case TokenType.Error:
- code += "<span class=\"undefined\">" + ((WordToken)cur).Lexeme + "</span>";
- break;
-
- default:
- if (KEYWORDS.Contains(type))
- {
- code += "<span class=\"keyword\">" + ((WordToken)cur).Lexeme + "</span>";
- }
- else if(OTHER_RESERVED.Contains(type))
- {
- code += "<span class=\"reserved\">" + ((WordToken)cur).Lexeme + "</span>";
- }
- else if (ONE_SYMBOL_OPERATORS.Contains(type))
- {
- code += "<span class=\"operator\">" + cur.ToString() + "</span>";
- }
- else if (MULT_SYMBOL_OPERATORS.Contains(type))
- {
- code += "<span class=\"operator\">" + ((WordToken)cur).Lexeme + "</span>";
- }
- else
- {
- code += "<span class=\"default\">" + cur.ToString() + "</span>";
- break;
- }
- break;
- }
- }
- while (tokenEnum.MoveNext() && tokenEnum.Current.Type != TokenType.EOF);
-
- string shouldWrite = string.Format(HTML, css, fileName, code);
-
- using (StreamWriter writer = new StreamWriter(fileName))
- {
- writer.Write(shouldWrite);
- }
- }
- }
-}
diff --git a/homework/81709/JSCompiler.SyntaxHighlighter/test/test.js b/homework/81709/JSCompiler.SyntaxHighlighter/test/test.js
deleted file mode 100644
index 537e59f..0000000
--- a/homework/81709/JSCompiler.SyntaxHighlighter/test/test.js
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-** This is a test function to demonstrate syntax highlighting!
-*/
-function myFunction() {
- var res = "";
- res = res +isNaN(123) + ": 123";
- res = res + isNaN(-1.23) + ": -1.23";
- res = res + isNaN(5-2) + ": 5-2";
- res = res + isNaN(0) + ": 0";
- res = res + isNaN('123') + ": 123
- ";
- //oops!
- res = res + isNaN(true) + ": true";
- res = res + isNaN(undefined) + ": undefined \
- nextString \
- ";
- res = res + isNaN('NaN') + ": NaN 'Hell no'";
- res = res + isNaN(NaN) + ': NaN \\n \';
- res = res + isNaN(0 / 0) + ": 0 / 0 \ ";
-
- document.getElementById("demo").innerHTML = res;
-}
-//Cool, it works! \ No newline at end of file
diff --git a/homework/81709/JSCompiler.SyntaxHighlighter/test/testout.html b/homework/81709/JSCompiler.SyntaxHighlighter/test/testout.html
deleted file mode 100644
index d1182c2..0000000
--- a/homework/81709/JSCompiler.SyntaxHighlighter/test/testout.html
+++ /dev/null
@@ -1,49 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<style>
-body {
- font-size: 20px;
- font-family: "Verdana";
-}
-.number {
- color: Orange;
-}
-.string {
- color: Gray;
- white-space: pre-wrap;
-}
-.keyword {
- color: Blue;
-}
-.identifier {
- color: Black;
-}
-.operator {
- color: DarkBlue;
-}
-.comment {
- color: Green;
- font-style: italic;
- white-space: pre-wrap;
-}
-
-.reserved {
- color: MediumVioletRed;
-}
-
-.undefined{
- color: Black;
-}
-
-.default {
- color: DarkBlue;
-}
-</style>
-<title> ..\..\test\testout.html </title>
-</head>
-<body> <span class="comment">/*
-** This is a test function to demonstrate syntax highlighting!
-*/</span><br><span class="keyword">function</span>&nbsp<span class="identifier">myFunction</span><span class="default">(</span><span class="default">)</span>&nbsp<span class="default">{</span><br>&nbsp&nbsp&nbsp&nbsp<span class="keyword">var</span>&nbsp<span class="identifier">res</span>&nbsp<span class="operator">=</span>&nbsp<span class="string">""</span><span class="default">;</span><br>&nbsp&nbsp&nbsp&nbsp<span class="identifier">res</span>&nbsp<span class="operator">=</span>&nbsp<span class="identifier">res</span>&nbsp<span class="operator">+</span><span class="reserved">isNaN</span><span class="default">(</span><span class="number">123</span><span class="default">)</span>&nbsp<span class="operator">+</span>&nbsp<span class="string">": 123"</span><span class="default">;</span><br>&nbsp&nbsp&nbsp&nbsp<span class="identifier">res</span>&nbsp<span class="operator">=</span>&nbsp<span class="identifier">res</span>&nbsp<span class="operator">+</span>&nbsp<span class="reserved">isNaN</span><span class="default">(</span><span class="operator">-</span><span class="number">1</span><span class="default">.</span><span class="number">23</span><span class="default">)</span>&nbsp<span class="operator">+</span>&nbsp<span class="string">": -1.23"</span><span class="default">;</span><br>&nbsp&nbsp&nbsp&nbsp<span class="identifier">res</span>&nbsp<span class="operator">=</span>&nbsp<span class="identifier">res</span>&nbsp<span class="operator">+</span>&nbsp<span class="reserved">isNaN</span><span class="default">(</span><span class="number">5</span><span class="operator">-</span><span class="number">2</span><span class="default">)</span>&nbsp<span class="operator">+</span>&nbsp<span class="string">": 5-2"</span><span class="default">;</span><br>&nbsp&nbsp&nbsp&nbsp<span class="identifier">res</span>&nbsp<span class="operator">=</span>&nbsp<span class="identifier">res</span>&nbsp<span class="operator">+</span>&nbsp<span class="reserved">isNaN</span><span class="default">(</span><span class="number">0</span><span class="default">)</span>&nbsp<span class="operator">+</span>&nbsp<span class="string">": 0"</span><span class="default">;</span><br>&nbsp&nbsp&nbsp&nbsp<span class="identifier">res</span>&nbsp<span class="operator">=</span>&nbsp<span class="identifier">res</span>&nbsp<span class="operator">+</span>&nbsp<span class="reserved">isNaN</span><span class="default">(</span><span class="string">'123'</span><span class="default">)</span>&nbsp<span class="operator">+</span>&nbsp<span class="undefined">": 123</span><br>&nbsp&nbsp&nbsp&nbsp<span class="undefined">"; </span><br>&nbsp&nbsp&nbsp&nbsp<span class="comment">//oops!</span><br>&nbsp&nbsp&nbsp&nbsp<span class="identifier">res</span>&nbsp<span class="operator">=</span>&nbsp<span class="identifier">res</span>&nbsp<span class="operator">+</span>&nbsp<span class="reserved">isNaN</span><span class="default">(</span><span class="keyword">true</span><span class="default">)</span>&nbsp<span class="operator">+</span>&nbsp<span class="string">": true"</span><span class="default">;</span><br>&nbsp&nbsp&nbsp&nbsp<span class="identifier">res</span>&nbsp<span class="operator">=</span>&nbsp<span class="identifier">res</span>&nbsp<span class="operator">+</span>&nbsp<span class="reserved">isNaN</span><span class="default">(</span><span class="reserved">undefined</span><span class="default">)</span>&nbsp<span class="operator">+</span>&nbsp<span class="string">": undefined \
- nextString \
- "</span><span class="default">;</span><br>&nbsp&nbsp&nbsp&nbsp<span class="identifier">res</span>&nbsp<span class="operator">=</span>&nbsp<span class="identifier">res</span>&nbsp<span class="operator">+</span>&nbsp<span class="reserved">isNaN</span><span class="default">(</span><span class="string">'NaN'</span><span class="default">)</span>&nbsp<span class="operator">+</span>&nbsp<span class="string">": NaN 'Hell no'"</span><span class="default">;</span><br>&nbsp&nbsp&nbsp&nbsp<span class="identifier">res</span>&nbsp<span class="operator">=</span>&nbsp<span class="identifier">res</span>&nbsp<span class="operator">+</span>&nbsp<span class="reserved">isNaN</span><span class="default">(</span><span class="reserved">NaN</span><span class="default">)</span>&nbsp<span class="operator">+</span>&nbsp<span class="undefined">': NaN \\n \';</span><br>&nbsp&nbsp&nbsp&nbsp<span class="identifier">res</span>&nbsp<span class="operator">=</span>&nbsp<span class="identifier">res</span>&nbsp<span class="operator">+</span>&nbsp<span class="reserved">isNaN</span><span class="default">(</span><span class="number">0</span>&nbsp<span class="operator">/</span>&nbsp<span class="number">0</span><span class="default">)</span>&nbsp<span class="operator">+</span>&nbsp<span class="string">": 0 / 0 \ "</span><span class="default">;</span><br><br>&nbsp&nbsp&nbsp&nbsp<span class="identifier">document</span><span class="default">.</span><span class="identifier">getElementById</span><span class="default">(</span><span class="string">"demo"</span><span class="default">)</span><span class="default">.</span><span class="identifier">innerHTML</span>&nbsp<span class="operator">=</span>&nbsp<span class="identifier">res</span><span class="default">;</span><br><span class="default">}</span><br><span class="comment">//Cool, it works!</span> </body></html> \ No newline at end of file
diff --git a/homework/81709/JSCompiler.sln b/homework/81709/JSCompiler.sln
deleted file mode 100644
index ab09e37..0000000
--- a/homework/81709/JSCompiler.sln
+++ /dev/null
@@ -1,42 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27130.2036
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSCompiler.Core", "JSCompiler.Core\JSCompiler.Core.csproj", "{C8DD3D07-6AE9-444B-8BA0-22DC633A9432}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSCompiler.SyntaxHighlighter", "JSCompiler.SyntaxHighlighter\JSCompiler.SyntaxHighlighter.csproj", "{D555ADB4-0161-4DF9-8098-1A72C03C1576}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{7A1EFAF1-7755-47BF-ACC3-E17F3C456CEC}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSCompiler.Core.Tests", "JSCompiler.Core.Tests\JSCompiler.Core.Tests.csproj", "{F2211B16-C27C-40D6-A856-8A6B5A3787EF}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {C8DD3D07-6AE9-444B-8BA0-22DC633A9432}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {C8DD3D07-6AE9-444B-8BA0-22DC633A9432}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {C8DD3D07-6AE9-444B-8BA0-22DC633A9432}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {C8DD3D07-6AE9-444B-8BA0-22DC633A9432}.Release|Any CPU.Build.0 = Release|Any CPU
- {D555ADB4-0161-4DF9-8098-1A72C03C1576}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D555ADB4-0161-4DF9-8098-1A72C03C1576}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D555ADB4-0161-4DF9-8098-1A72C03C1576}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D555ADB4-0161-4DF9-8098-1A72C03C1576}.Release|Any CPU.Build.0 = Release|Any CPU
- {F2211B16-C27C-40D6-A856-8A6B5A3787EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {F2211B16-C27C-40D6-A856-8A6B5A3787EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {F2211B16-C27C-40D6-A856-8A6B5A3787EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {F2211B16-C27C-40D6-A856-8A6B5A3787EF}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(NestedProjects) = preSolution
- {F2211B16-C27C-40D6-A856-8A6B5A3787EF} = {7A1EFAF1-7755-47BF-ACC3-E17F3C456CEC}
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {4D495C27-7CDB-4B11-9A8B-0919861303BC}
- EndGlobalSection
-EndGlobal
diff --git a/homework/81709/README.md b/homework/81709/README.md
deleted file mode 100644
index 2d3f4b1..0000000
--- a/homework/81709/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# Syntax Highlighter
-
-Run JSCompiler.SyntaxHighlighter with two command line arguments - first is the path to the input file you want to highlight and the second is the path to the html file you want to generate.
-
-> Example arguments: ..\\..\\test\\test.js ..\\..\\test\\testout.html \ No newline at end of file