Website Summary Files Commits Branches @commit @diff @stats
path: root / homework / 81709 / JSCompiler.SyntaxHighlighter / Program.cs
blob: fd0d539c17256c83ca0e04c51fe346210a1e0a92 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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<Token> 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;
        }
    }
}