public static void Run(string source, TextWriter tw = null, string cs_master_file = "", string filename = "pgm.fast") { if (tw == null) { tw = Console.Out; } try { var pgm = FastPgmParser.Parse(source, filename); FastTransducerInstance fti = FastTransducerInstance.MkFastTransducerInstance(pgm, tw, LogLevel.Minimal); FastTransducerInstance.DisposeZ3P(); } catch (FastParseException e) { tw.WriteLine(e.ToString()); return; } catch (FastAssertException e) { tw.WriteLine("{3}({0},{1}): error : AssertionViolated, {2}", min1(e.line), min1(e.pos), e.Message, filename); return; } catch (FastException e) { tw.WriteLine("{3}({0},{1}): error : FastError, {2}", 1, 1, e.Message, filename); return; } catch (Exception e) { tw.WriteLine("{3}({0},{1}): error : InternalError, {2}", 1, 1, filename); return; } }
/// <summary> /// Parses a fast program from a stream. /// Throws FastParseException when parsing fails. /// </summary> /// <param name="source">given source stream</param> /// <param name="infersorts">if false sort inference is omitted</param> public static FastPgm ParseFromStream(Stream source, bool infersorts = true) { if (source == null) { throw new ArgumentNullException("source"); } var pgm = FastPgmParser.Parse(source); if (infersorts) { pgm.Typecheck(); } return(pgm); }
/// <summary> /// Parses a fast program from text. /// Throws FastParseException when parsing fails. /// </summary> /// <param name="source">given source string</param> /// <param name="infersorts">if false sort inference is omitted</param> public static FastPgm ParseFromString(string source, bool infersorts = true) { if (source == null) { throw new ArgumentNullException("source"); } if (source.Length == 0) { throw new ArgumentException("must be nonempty string", "source"); } var pgm = FastPgmParser.Parse(source); if (infersorts) { pgm.Typecheck(); } return(pgm); }
/// <summary> /// Parses a fast program from multiple files. /// Throws FastParseException when parsing fails. /// </summary> /// <param name="files">given source files</param> /// <param name="infersorts">if false sort inference is omitted</param> public static FastPgm ParseFromFiles(string[] files, bool infersorts = true) { if (files == null) { throw new ArgumentNullException("files"); } if (files.Length == 0) { throw new ArgumentException("must be nonempty", "files"); } var pgm = FastPgmParser.ParseFiles(files); if (infersorts) { pgm.Typecheck(); } return(pgm); }