public void ConstantMapTest() { HoistedIdentifierMap gl = new(); TypeIdentifierMap tp = new(); FrameworkIntegration.PopulateWithFrameworkSymbols(gl, tp); string[] constants = { "PI", "E", "TAU", "PHI" }; foreach (string c in constants) { Assert.IsTrue(gl.TryGet(c, out var sym)); Assert.IsInstanceOf <ConstantSymbolNode <Rational> >(sym); } }
public void IntegrationTest() { HoistedIdentifierMap gl = new(); TypeIdentifierMap tp = new(); FrameworkIntegration.PopulateWithFrameworkSymbols(gl, tp); string[] types = { "String", "Int", "Char", "Complex", "Bool", "Rational" }; foreach (string t in types) { Assert.IsTrue(tp.TryGet(t, out _)); } Assert.IsTrue(gl.TryGet("Output", out _)); }
public static Compilation?Analyse(string code) { // For unit tests FrameworkIntegration.Reset(); Lexer lexer = new(code); LexemeCollection?lexemes = lexer.LexAll(); if (lexemes == null) { return(null); } ProgramParser parser = new(lexemes, code); ProgramNode? program = parser.ParseWholeProgram(); if (program == null) { return(null); } Compilation compilation = new(program, code); Binder binder = new(compilation); bool success = binder.PerformBinding(); //SemanticalAnalyser semanticalAnalyser = new(compilation); //bool success = semanticalAnalyser.PerformSemanticalAnalysis(); if (!success) { return(null); } return(compilation); }