Exemplo n.º 1
0
 public static ISource FromFile(FileRef sourceFile)
 {
     try
     {
         return(new Source(sourceFile.FileName, sourceFile.GetContent()));
     }
     catch (FileNotFoundException)
     {
         throw new MessageException(new MessageError(MessageCode.SourceFileNotFound, sourceFile));
     }
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
 public static Source FromFile(FileRef file, string name)
 {
     return(new Source(file, name, file.GetContent()));
 }