Exemplo n.º 1
0
        private ParseTree Parse(string source, List <EqlError> errors)
        {
            if (string.IsNullOrWhiteSpace(source))
            {
                throw new EqlException("Source is empty.");
            }

            if (errors == null)
            {
                errors = new List <EqlError>();
            }

            var grammar  = new EqlGrammar();
            var language = new LanguageData(grammar);
            var parser   = new Parser(language);
            var tree     = parser.Parse(source);

            if (tree.HasErrors())
            {
                foreach (var error in tree.ParserMessages.Where(x => x.Level == Irony.ErrorLevel.Error))
                {
                    EqlError err = new EqlError {
                        Message = error.Message
                    };
                    err.Line   = error.Location.Line;
                    err.Column = error.Location.Column;
                    errors.Add(err);
                }
            }

            return(tree);
        }
Exemplo n.º 2
0
 public EqlException(EqlError error) : base(error?.Message ?? "One or more Eql errors occurred.")
 {
     Errors.Add(error);
 }