From 47e8c6f331525f01f150ba80a3557a18618b0cf5 Mon Sep 17 00:00:00 2001 From: Georgi Barnev Date: Wed, 7 Nov 2018 13:05:43 +0200 Subject: Homework 1 - C# Lexer and Syntax Highlighter for Javascript (#34) * Initial lexer structure * Added IInputStream interface for the Lexer and its base implementation in FileInputStream not implemented yet. * Extend InputStream interface * Implement FileInputStream not tested * Lexer almost ready - comments need to be parsed. InputStream ready * Added some TODOs * Add error token type and almost parse comments * Parse multiline comments and fix string parsing to not include the quotes. * Added Syntax Highlighter, added support for more js reserved words, removed error tokens to not break the actual word tokens, fixed comments and string token representation to include its special characters * Initial lexer structure * Added IInputStream interface for the Lexer and its base implementation in FileInputStream not implemented yet. * Extend InputStream interface * Implement FileInputStream not tested * Lexer almost ready - comments need to be parsed. InputStream ready * Added some TODOs * Add error token type and almost parse comments * Parse multiline comments and fix string parsing to not include the quotes. * Added Syntax Highlighter, added support for more js reserved words, removed error tokens to not break the actual word tokens, fixed comments and string token representation to include its special characters * Improve project structure and add tests * Fix physical path structure of the projects * Write tests, fix tokenizer bugs * Fix README format, fix AssemblyInfo name * Escape slashes in readme --- .../81709/JSCompiler.SyntaxHighlighter/Program.cs | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 homework/81709/JSCompiler.SyntaxHighlighter/Program.cs (limited to 'homework/81709/JSCompiler.SyntaxHighlighter/Program.cs') diff --git a/homework/81709/JSCompiler.SyntaxHighlighter/Program.cs b/homework/81709/JSCompiler.SyntaxHighlighter/Program.cs new file mode 100644 index 0000000..fd0d539 --- /dev/null +++ b/homework/81709/JSCompiler.SyntaxHighlighter/Program.cs @@ -0,0 +1,36 @@ +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 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; + } + } +} -- cgit v1.3.1-23-gd82d