public static ISource FromFile(FileRef sourceFile) { try { return(new Source(sourceFile.FileName, sourceFile.GetContent())); } catch (FileNotFoundException) { throw new MessageException(new MessageError(MessageCode.SourceFileNotFound, sourceFile)); } }
public static ISource?FromFile(ICompileResult result, FileRef sourceFile) { try { return(new Source(sourceFile.FileName, sourceFile.GetContent())); } catch (FileNotFoundException) { result.AddError(new MessageError(MessageCode.SourceFileNotFound, sourceFile)); } return(null); }
public static bool Run(FileRef file, Outcome outcome) { var source = new Source(file.FileName, file.GetContent()); var lexer = new Json.JsonLexer(source); var parser = new Json.JsonParser(lexer); var x = parser.Parse(); switch (outcome) { case Outcome.Succeed: return(x != null && parser.Error == null); case Outcome.Fail: return(x == null && parser.Error != null); default: return(true); } }
public static Source FromFile(FileRef file, string name) { return(new Source(file, name, file.GetContent())); }