Example #1
0
 public PGNException(string message, PGNToken token, ParserSource source = ParserSource.Parser)
     : base(message)
 {
     SourceComponent = source;
     Index = token.Index;
     PgnToken = token;
 }
Example #2
0
 public PGNException(string message, PGNToken token, ParserSource source, Exception innerException)
     : base(message, innerException)
 {
     SourceComponent = source;
     Index = token.Index;
     PgnToken = token;
 }
Example #3
0
 public PGNException(string message, PGNToken token, ParserSource source, Exception innerException)
     : base(message, innerException)
 {
     SourceComponent = source;
     Index           = token.Index;
     PgnToken        = token;
 }
Example #4
0
 public PGNException(string message, int index, string token, ParserSource source, Exception innerException)
     : base(message, innerException)
 {
     SourceComponent = source;
     Index = index;
     Token = token;
 }
Example #5
0
 public PGNException(string message, PGNToken token, ParserSource source = ParserSource.Parser)
     : base(message)
 {
     SourceComponent = source;
     Index           = token.Index;
     PgnToken        = token;
 }
Example #6
0
 public PGNException(string message, int index, string token, ParserSource source, Exception innerException)
     : base(message, innerException)
 {
     SourceComponent = source;
     Index           = index;
     Token           = token;
 }
        public ActionResult CreateParsingSource(ParserSource source)
        {
            if (db.Categories.Any(cat => cat.Id == source.CategoryId) &&
                db.Markets.Any(m => m.Id == source.MarketId) &&
                !db.ParserSources.Any(s => s.Url == source.Url))
            {
                db.ParserSources.Add(source);
                db.SaveChanges();

                return(RedirectToAction("Sources"));
            }

            ViewBag.ErrorMessage = "You typed wrong ids or URL!";
            return(View("Error"));
        }
Example #8
0
        public double Calculate(string input)
        {
            Token EofToken = new Token {
                Type = TT.EOF
            };
            var lexer = new CalculatorLexer(input);

            Src = new ParserSource <Token>(lexer, EofToken, lexer.Src.SourceFile)
            {
                TokenTypeToString = tt => ((TT)tt).ToString()
            };
            var result = ExprSequence();

            Src.Match((int)TT.EOF);
            return(result);
        }
Example #9
0
        public double Calculate(string input)
        {
            var lexer = new CalculatorLexer(input);

            _tokens.Clear();
            Token t;

            while (((t = lexer.NextToken()).Type != TT.EOF))
            {
                if ((t.Type != TT.Space))
                {
                    _tokens.Add(t);
                }
            }
            _src = new ParserSource <Token>(_tokens, new Token {
                Type = TT.EOF
            })
            {
                TokenTypeToString = TokenTypeToString
            };
            return(Expr());
        }
Example #10
0
        private static async Task <IEnumerable <Product> > ParseAsync(ParserSource source)
        {
            // Download web request
            string url          = source.Url;
            string responceBody = await(new HttpDownloader(url, null, null).GetPageAsync());

            // Create an appropriate parser
            IClassParser <ParserInput, Product> parser;

            if (source.ParserId == 0)
            {
                parser = new HTMLParser <ParserInput, Product>(responceBody);
            }
            else
            {
                parser = new JsonParser <ParserInput, Product>(responceBody);
            }

            // Create an input
            ParserInput input = new ParserInput(source, source.Market);

            return(parser.Parse(input));
        }
        public ActionResult CreateParserSource(ParserSource parserSource)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    parserSourceRepository.Add(parserSource);
                    marketRepository.Save();
                    return(RedirectToAction("AdminPanel"));
                }
            }
            catch (DataException)
            {
                //log
            }

            SelectList markets    = new SelectList(marketRepository.GetAll(), "Id", "Name");
            SelectList categories = new SelectList(categoryRepository.GetAll(), "Id", "Name");

            ViewBag.Markets    = markets;
            ViewBag.Categories = categories;

            return(View(parserSource));
        }