Website Summary Files Commits Branches @commit @diff @stats
path: root / homework / 81568 / c2html / lexconst.h
diff options
context:
space:
mode:
Commit06811744a002f4ab332d94d510475231afcd45a1 (patch)
Author
 Mincho Paskalev <minchopaskal@gmail.com>
2018-11-03 13:36:57 +0200
Committer
 Martin Dobrev <martindobrev0@gmail.com>
2018-11-03 13:36:57 +0200
Files91c41776fbdf899dcb61a8d5df3ac1316c24f3c8 /homework/81568/c2html/lexconst.h
IPL-06811744a002f4ab332d94d510475231afcd45a1.tar
IPL-06811744a002f4ab332d94d510475231afcd45a1.tar.gz
IPL-06811744a002f4ab332d94d510475231afcd45a1.zip
Parent26e5f891d537b5d4fc2890c9cdbeb73d5748d568 (diff)
First HW (#9)
* Add 1st hw * --amend * moving readme for 1st hw to designated folder * renamed TokenType enum to TokenClass * fixed character constant lexing. added sampe output file * add new line at end-of-file. added gitignore * a bit of refactoring
1 files changed, 39 insertions, 0 deletions
-rw-r--r--homework/81568/c2html/lexconst.h39
diff --git a/homework/81568/c2html/lexconst.h b/homework/81568/c2html/lexconst.h
new file mode 100644
index 0000000..9d2068d
--- /dev/null
+++ b/homework/81568/c2html/lexconst.h
@@ -0,0 +1,39 @@
+#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::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