diff options
| Commit | 93cd8cac8a616ae13bd42dcbee0bb9da278eb49d (patch) | |
|---|---|---|
| Author | 2018-11-07 14:26:16 +0200 | |
| Committer | 2018-11-07 14:26:16 +0200 | |
| Files | ce8b306af9c36d6443fe2fc34526223e44c804cf /homework/81013/go2html/Lexer.h | |
| IPL-93cd8cac8a616ae13bd42dcbee0bb9da278eb49d.tar IPL-93cd8cac8a616ae13bd42dcbee0bb9da278eb49d.tar.gz IPL-93cd8cac8a616ae13bd42dcbee0bb9da278eb49d.zip | ||
| Parent | 47e8c6f331525f01f150ba80a3557a18618b0cf5 (diff) | |
Solution to first homework (#25)
* Add token types enum for Lexer
* Local test if I've correctly switched from https to ssh
* Adds initial Lexer logic; Reuses JSImpl's Lexer logic; Still needs refactoring;
* Adds README.md
* Adds README.md
* Adds tokenization of strings and a few operators
* Adds some operators
* Adds highlighter and sample for future testing
* Adds runes & fixes double whitespace bug
* API fix, premake, solution
* Update README.md
* Delete HL.sln
* Delete HL.vcxproj
1 files changed, 125 insertions, 0 deletions
| -rw-r--r-- | homework/81013/go2html/Lexer.h | 125 |
diff --git a/homework/81013/go2html/Lexer.h b/homework/81013/go2html/Lexer.h new file mode 100644 index 0000000..d1b5ae6 --- /dev/null +++ b/homework/81013/go2html/Lexer.h @@ -0,0 +1,125 @@ +#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 |
