diff options
Homework 1 (#21)
* Commiting .gitignore before real solution
* C# project implementing very basic functionality of the lexer, needs
refactoring.
* Added most javascript reserved keywords
* Added logic for most js operators in Tokenizer.cs
* added lexemes for operator tokens
also created the PrettyPrint() function
* added a coloring logic to the parsed text
* Refactored Lexer class, added TokenHandler class
PrettyPrint colors require tweaking, Lexer needs more refactoring
* created TokenHandler to pretty print text to html
* Deleted project files
* Updated Program.cs
1 files changed, 58 insertions, 0 deletions
| -rw-r--r-- | homework/81498/Project/Wizard/Misc/KeywordsToTokensMap.cs | 58 |
diff --git a/homework/81498/Project/Wizard/Misc/KeywordsToTokensMap.cs b/homework/81498/Project/Wizard/Misc/KeywordsToTokensMap.cs new file mode 100644 index 0000000..85783ab --- /dev/null +++ b/homework/81498/Project/Wizard/Misc/KeywordsToTokensMap.cs @@ -0,0 +1,58 @@ +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(); + } + } +} |
