Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commitc9de201989370c6ded6c944d818b7e7c104edf6d (patch)
Author
 GMarinov2 <gmarinov1@uni-sofia.bg>
2018-11-03 13:54:35 +0200
Committer
 Martin Dobrev <martindobrev0@gmail.com>
2018-11-03 13:54:35 +0200
Files2d873b712c0e36e1d568ba32466d953a0721c468
IPL-c9de201989370c6ded6c944d818b7e7c104edf6d.tar
IPL-c9de201989370c6ded6c944d818b7e7c104edf6d.tar.gz
IPL-c9de201989370c6ded6c944d818b7e7c104edf6d.zip
Parentccd71ee220093774a35708d8c1e31936b012930a (diff)
Homework 1 (#26)
* Finished homework 1 * Removed the binaries. * Adding gitignore and solution * Removed unnecessary code. * Removed the .sln for the appveyor build.
diff --git a/homework/45278/js2html/.gitignore b/homework/45278/js2html/.gitignore
new file mode 100644
index 0000000..f00a0eb
--- /dev/null
+++ b/homework/45278/js2html/.gitignore
@@ -0,0 +1,334 @@
+## 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
new file mode 100644
index 0000000..1a9da1b
--- /dev/null
+++ b/homework/45278/js2html/js2html/Extensions/TokenizerExtensions.cs
@@ -0,0 +1,79 @@
+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
new file mode 100644
index 0000000..a0204f3
--- /dev/null
+++ b/homework/45278/js2html/js2html/Models/Token.cs
@@ -0,0 +1,22 @@
+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
new file mode 100644
index 0000000..13061e9
--- /dev/null
+++ b/homework/45278/js2html/js2html/Models/TokenType.cs
@@ -0,0 +1,106 @@
+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
new file mode 100644
index 0000000..9bf0ebb
--- /dev/null
+++ b/homework/45278/js2html/js2html/Program.cs
@@ -0,0 +1,29 @@
+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
new file mode 100644
index 0000000..fa61775
--- /dev/null
+++ b/homework/45278/js2html/js2html/Tokenizer.cs
@@ -0,0 +1,288 @@
+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
new file mode 100644
index 0000000..2c8f911
--- /dev/null
+++ b/homework/45278/js2html/js2html/hello.html
@@ -0,0 +1,7 @@
+<!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
new file mode 100644
index 0000000..ab5524a
--- /dev/null
+++ b/homework/45278/js2html/js2html/hello.js
@@ -0,0 +1,4 @@
+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
new file mode 100644
index 0000000..b5c27ba
--- /dev/null
+++ b/homework/45278/js2html/js2html/js2html.csproj
@@ -0,0 +1,14 @@
+<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>