35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.IO;
|
|
|
|
// TODO: add foreach support at some point
|
|
// this will save enormous amounts of time when processing data
|
|
|
|
namespace GASi {
|
|
class Transpiler {
|
|
static void Main(string[] args) {
|
|
var test = File.ReadAllLines("test.gi");
|
|
var result = Lexer.Interpret(test);
|
|
FancyPrint(result);
|
|
|
|
while(true) ;
|
|
}
|
|
|
|
static void FancyPrint(IEnumerable<Lexer.Token> tokens) {
|
|
var longestCount = 0;
|
|
foreach(var token in tokens)
|
|
longestCount = Math.Max(longestCount, token.Value.Length);
|
|
|
|
foreach(var token in tokens) {
|
|
Console.WriteLine("{0, 20}{1}", "(" + token.Type.ToString() + ") | ", token.Value);
|
|
}
|
|
}
|
|
|
|
public static Exception Exception(string text, int line, int column) {
|
|
return new Exception("ERROR: " + text + " (line: " + (line + 1) + ", column: " + (column + 1) + ")");
|
|
}
|
|
}
|
|
}
|