Beispiel #1
0
        public static List<IOperation> Compile(string assembly)
        {
            var stream = new AntlrInputStream(assembly);
            var lexer = new TisLangLexer(stream);
            var tokens = new CommonTokenStream(lexer);
            var parser = new TisLangParser(tokens);
            var program = parser.program();

            if (parser.NumberOfSyntaxErrors > 0) {
                throw new Exception("Failed to parse program");
            }

            var labels = new LabelGatherer();
            labels.Gather(program);

            var operations = new OperationGatherer();
            operations.Gather(program, labels.Labels);

            return operations.Operations;
        }