//[TestMethod] public void TestNondetCS() { var pgm = Parser.ParseFromFile(srcDirectory + "Fast.Tests/FastSamples/nondetcs.fast"); FastTransducerInstance fti = FastTransducerInstance.MkFastTransducerInstance(pgm); Assert.IsTrue(fti.treeDefinitions["A"].transducers.Count == 1); StringBuilder sb = new StringBuilder(); fti.ToFast(sb); var q = new List <TreeTransducer>(fti.treeDefinitions["A"].transducers.Values)[0]; var A = q.InputAlphabet; var T = A.MkAttr(A.TT.Z.True); Func <Expr, Expr> one = x => A.MkTree("one", T, x); Expr zero = A.MkTree("zero", T); var t1 = one(one(one(zero))); var t1s = q[t1]; var t2 = one(one(one(one(zero)))); var t2s = q[t2]; Assert.AreEqual <int>(8, t1s.Length); Assert.AreEqual <int>(16, t2s.Length); }
/// <summary> /// Generates C# code from a Fast program /// </summary> /// <param name="inputPath">the Fast file from which it generates the CSharp code</param> /// <param name="outputPath">the C# file into which the CSharp code is generated</param> /// <param name="ns">the package the generated file will belong to</param> /// <param name="flag">true to generate the transducer's optimized version</param> public static bool GenerateCSharp(String inputPath, String outputPath, String ns, bool flag) { var pgm = Parser.ParseFromFile(inputPath); FastTransducerInstance fti = FastTransducerInstance.MkFastTransducerInstance(pgm); StringBuilder sb = new StringBuilder(); fti.ToFast(sb); pgm = Parser.ParseFromString(sb.ToString()); return(CsharpGenerator.GenerateCode(pgm, outputPath, ns)); }
public void TestWitGen() { var pgm = Parser.ParseFromFile(srcDirectory + "Fast.Tests/FastSamples/witness.fast"); FastTransducerInstance fti = FastTransducerInstance.MkFastTransducerInstance(pgm); StringBuilder sb = new StringBuilder(); fti.ToFast(sb); pgm = Parser.ParseFromString(sb.ToString()); //bool b = CsharpGenerator.GenerateCode(pgm, "../../../src/Fast.Tests/GeneratedCS/trees.cs", "Microsoft.Fast.Tests.Trees"); }
public void TestFunctions() { var pgm = Parser.ParseFromFile(srcDirectory + "Fast.Tests/FastSamples/functions.fast"); Assert.IsTrue(pgm.defs.Count == 6); FastTransducerInstance fti = FastTransducerInstance.MkFastTransducerInstance(pgm); StringBuilder sb = new StringBuilder(); fti.ToFast(sb); //TBD: ToFast produces code in old prefix notation //pgm = Parser.ParseFromString(sb.ToString()); //bool b = CsharpGenerator.GenerateCode(pgm, "../../../src/Fast.Tests/GeneratedCS/functions.cs", "Microsoft.Fast.Tests.Functions"); Assert.IsTrue(pgm.defs.Count == 6); }