<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using com.calitha.goldparser;
using billc.TreeNodes;
using billc.Visitors;

namespace billc
{
    class Program
    {
        static void Main(string[] args)
        { 
            //These tests create semantically invalid programs, but are sufficient to test construction of the AST
            string binop_test = "void main() {\n int a = a + 2;\n}";
            string fxn_test = "void main() {\n int a = 5;\n return a;\n}";
            string if_test = "void main() {\n int a = 5;\n if (a == 5) { return 1 + 2;} return 2;\n}";
            string while_test = "void main() {\n while(b){ return 2; }\n}";
            string assign_test = "void main() {\n a = 7;\n}";
            string invoke_test = "void main() { foo(5);\n}";
            string invoke_test2 = "void main() { foo(5, true, 2.5); \n}";
            string member_test = "void main() { a.thing = 10; }";
            string class_test = "class foo(int a, string s){ }";
            string interpret_test = "void main() { println(\"hello world\"); }";
            string interpret2_test = "void main() { println(toStr(2)); }";
            string interpret3_test = "void main() { println(toStr(1 + 2)); }";
            string interpret4_test = "void main() { int a = 2 + 5; \n println(toStr(a)); }";

            //Tests to see quality of parsing error messages
            string missingBrace = "void main() { ";
            string extraBrace = "void main() { }}";
            string badExpression = "void main() {\n int a = 5 + ;\n}";

            //Type checker errors
            string emptyProgram = "";
            string no_identifier = "void main() {\n\n\n int a = b + 2;\n}";

            MyParser parser = new MyParser("Bill_Grammar.cgt");

            ProgramNode program = (ProgramNode)parser.Parse(if_test);

            if (program == null)
            {
                ErrorReporter.Error("Parsing failed, Exiting.");
                return;
            } 

            TypeValidatorVisitor tvv = new TypeValidatorVisitor();
            
            program.accept(tvv);

            if (!tvv.isValidProgram)
            {
                ErrorReporter.Error("Type check failed, Exiting.");
                return;
            }
            Console.WriteLine(program.ToString());

            //InterpreterVisitor iv = new InterpreterVisitor();

            //Console.WriteLine("Execute interpreter");
            //program.accept(iv);
            //Console.WriteLine("Execution complete");

            Console.ReadLine();
        }
    }
}
<commit_msg>Adding check<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using com.calitha.goldparser;
using billc.TreeNodes;
using billc.Visitors;

namespace billc
{
    class Program
    {
        static void Main(string[] args)
        { 
            //These tests create semantically invalid programs, but are sufficient to test construction of the AST
            string binop_test = "void main() {\n int a = a + 2;\n}";
            string fxn_test = "void main() {\n int a = 5;\n return a;\n}";
            string if_test = "void main() {\n int a = 5;\n if (a == 5) { return 1 + 2;} return 2;\n}";
            string while_test = "void main() {\n while(b){ return 2; }\n}";
            string assign_test = "void main() {\n a = 7;\n}";
            string invoke_test = "void main() { foo(5);\n}";
            string invoke_test2 = "void main() { foo(5, true, 2.5); \n}";
            string member_test = "void main() { a.thing = 10; }";
            string class_test = "class foo(int a, string s){ }";
            string interpret_test = "void main() { println(\"hello world\"); }";
            string interpret2_test = "void main() { println(toStr(2)); }";
            string interpret3_test = "void main() { println(toStr(1 + 2)); }";
            string interpret4_test = "void main() { int a = 2 + 5; \n println(toStr(a)); }";

            //Tests to see quality of parsing error messages
            string missingBrace = "void main() { ";
            string extraBrace = "void main() { }}";
            string badExpression = "void main() {\n int a = 5 + ;\n}";

            //Type checker errors
            string emptyProgram = "";
            string no_identifier = "void main() {\n\n\n int a = b + 2;\n}";
            string badCond = "void main() {\n if (5) { }\n }";

            MyParser parser = new MyParser("Bill_Grammar.cgt");

            ProgramNode program = (ProgramNode)parser.Parse(badCond);

            if (program == null)
            {
                ErrorReporter.Error("Parsing failed, Exiting.");
                return;
            } 

            TypeValidatorVisitor tvv = new TypeValidatorVisitor();
            
            program.accept(tvv);

            if (!tvv.isValidProgram)
            {
                ErrorReporter.Error("Type check failed, Exiting.");
                return;
            }
            Console.WriteLine(program.ToString());

            //InterpreterVisitor iv = new InterpreterVisitor();

            //Console.WriteLine("Execute interpreter");
            //program.accept(iv);
            //Console.WriteLine("Execution complete");

            Console.ReadLine();
        }
    }
}

{'fraction_non_alphanumeric': 0.1360771227289581, 'fraction_numerical': 0.00982573229514275, 'mean_word_length': 1.8927613941018766, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1839271', 'n_tokens_mistral': 1561, 'n_tokens_neox': 1493, 'n_words': 447}