Example #1
0
        static void Main(string[] args)
        {
            parser p = new parser();
            game   g = p.parse(args[0]);

            g.socialPlanner();
        }
Example #2
0
        /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/

        /** Parse the grammar specification from standard input.  This produces
         *  sets of terminal, non-terminals, and productions which can be accessed
         *  via static variables of the respective classes, as well as the setting
         *  of various variables (mostly in the emit class) for small user supplied
         *  items such as the code to scan with.
         */
        protected static void parse_grammar_spec()
        {
            parser parser_obj;

            // create a parser and parse with it
            parser_obj = new parser();
            try
            {
                if (opt_do_debug)
                {
                    parser_obj.debug_parse();
                }
                else
                {
                    parser_obj.parse();
                }
            }
            catch (Exception e)
            {
                // something threw an exception.  catch it and emit a message so we
                //  have a line number to work with, then re-throw it
                lexer.emit_error("Internal error: Unexpected exception");
                throw e;
            }
        }
Example #3
0
        /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/

        /// <summary>Parse the grammar specification from standard input.  This produces
        /// sets of terminal, non-terminals, and productions which can be accessed
        /// via static variables of the respective classes, as well as the setting
        /// of various variables (mostly in the emit class) for small user supplied
        /// items such as the code to scan with.
        /// </summary>
        protected internal static void  parse_grammar_spec()
        {
            parser parser_obj;

            /* create a parser and parse with it */
            parser_obj = new parser();
            try
            {
                if (opt_do_debug)
                {
                    parser_obj.debug_parse();
                }
                else
                {
                    parser_obj.parse();
                }
            }
            catch (System.Exception e)
            {
                /* something threw an exception.  catch it and emit a message so we
                 * have a line number to work with, then re-throw it */
                lexer.emit_error("Internal error: Unexpected exception");
                Console.WriteLine("Internal Error: {0}", e.ToString());
                Console.WriteLine(e.StackTrace);
                throw e;
            }
        }
        void Button1Click(object sender, EventArgs e)
        {
            try{
                string patharch=tabControl1.SelectedTab.Name;
                StreamReader archivo=new StreamReader(patharch);
                sc=new Scanner(archivo);
                parse = new parser(sc);
                parse.parse();
                archivo.Close();
                MessageBox.Show("Proceso de Compilación Finalizado.");
                richTextBox1.Text=sc.errores+parse.errores;
                generacionCodigo.generadorCodigo generador=new generacionCodigo.generadorCodigo();
                Type tipo=generador.iniciarConstruccion(parse.raiz);

                object ptInstance = Activator.CreateInstance(tipo, new object[0]);

                tipo.InvokeMember("main",
                                    BindingFlags.InvokeMethod,
                                    null,
                                    ptInstance,
                                    new object[0]);
                button4.Enabled=true;
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.ToString());
            }
        }
Example #5
0
 public watch( string TITLE, parser PARSER, int SECONDS, Form1 FORM )
 {
     m_title         = TITLE;
     m_parser        = PARSER;
     m_form          = FORM;
     m_timer         = new Timer();
     m_timer.Interval = SECONDS * 1000;
     m_timer.Tick    += new EventHandler(timerTick);
     m_timer.Start();
 }
Example #6
0
        public Stream Parse(Stream source)
        {
            var p = new parser();

            p.js           = js;
            p.needJsTag    = NeedJsTag;
            p.sso          = ScriptObject;
            p.source       = source;
            p.encoding     = Encoding;
            p.exportReturn = ExportReturnValue;
            p.mergeJS      = MergeJS;
            p.Start();
            p.target.Position = 0;
            return(p.target);
        }
Example #7
0
        static void Main(string[] args)
        {
            //create the extractor class and set the repo name.
            RepoChecker.ICommitExtractor extractor = new RepoChecker.CommitExtractor();
            extractor.RepoName = "dolot3/GitHubBrowser";

            //create the parser to parse the returned data.
            parser theParser = new parser(extractor);

            //get the list of repos
            List <RepoData> thelist = theParser.GetFormattedValues();

            //crude output.
            Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(thelist));
        }
Example #8
0
        public static Expression fromString(System.String s)
        {
            Expression result;

            try
            {
                parser p = new parser(new scanner(new System.IO.StringReader(s)));
                result = (Expression)p.parse().value_Renamed;
            }
            catch (System.Exception e)
            {
                System.Console.Out.WriteLine("parse error");
                result = new Variable("error");
            }
            return(result);
        }
Example #9
0
        public ActionResult UpdateFeeds()
        {
            channel ch = Db.channels.Where(c => c.isCurrent == true).FirstOrDefault();

            if (ch != null)
            {
                parser p = new parser();
                p.parseAllFeeds();
                //channel chan = Pars.channels.Where(c => c.title == user.currentChannel.title).FirstOrDefault();
                if (ch != null)
                {
                    //  user.currentChannel.item = ch.item;
                }
            }

            return(RedirectToAction("RSSIndex"));
        }
Example #10
0
        public void layout()
        {
            parser   Parser = new parser();
            TreeNode root   = Parser.getTree("../../source.txt");

            if (Parser.error.isError == false)
            {
                DrawingVisual  visual = new DrawingVisual();
                DrawingContext dc     = visual.RenderOpen();

                DrawTree.DisplayTree(root, dc, Test);

                //Pen drawingPen = new Pen(Brushes.Black, 2);

                Test.AddVisual(visual);
                dc.Close();
            }
        }
Example #11
0
        private static void Main()
        {
            string[] items_of_menu =
            {
                "Задание 1.1. (Де)Сериализация бинарного дерева (XML).",
                "Задание 1.2. (Де)Сериализация бинарного дерева (Бинарная).",
                "Задание 2. Разархивация архива.",
                "Выход."
            };

            create_b_ser_file();
            create_xml_ser_file();

            while (true)
            {
                var case_number = print.Menu(0, items_of_menu);
                switch (case_number)
                {
                case 1: {
                    main_reader_class reader = new main_reader_class("input_xml_ser.xml");
                    reader.start();
                    break;
                }

                case 2: {
                    main_reader_class reader = new main_reader_class("input_b_ser.dat");
                    reader.start();
                    break;
                }

                case 3: {
                    parser _parser = new parser("Current.zip");
                    _parser.start();
                    break;
                }

                case 4: {
                    return;
                }
                }
            }
        }
Example #12
0
        public void GetFormattedValues_Test()
        {
            //Arrange
            List <RepoData> expected;

            Mock <ICommitExtractor> mockExtractor = new Mock <ICommitExtractor>();

            mockExtractor.Setup(m => m.GetCommitsRaw()).Returns(getTestRawValues());

            parser theFormatter = new parser(mockExtractor.Object);

            //act
            expected = theFormatter.GetFormattedValues();

            //assert
            Assert.Equal(3, expected.Count);
            Assert.Equal("dolot3", expected[0].Committer);
            Assert.Equal("Added interface", expected[1].Message);
            Assert.Equal("07/21/2020 14:39:00", expected[2].CommitDate);
        }
Example #13
0
    public string acceptMessage(string json_array)
    {
        parser            parseador = new parser();
        jsonAcceptMessage res;

        System.Diagnostics.Debug.WriteLine("JSON: " + json_array);



        Peticion  peticion     = JsonConvert.DeserializeObject <Peticion>(json_array);
        hl7parser parseadorhl7 = new hl7parser();

        System.Diagnostics.Debug.WriteLine("ACESO DESDE FUERA, SE RECIBIO Y DECODIFICO ");


        SoapHeader.AuthenticationToken = peticion.Token;
        if (peticion != null)
        {
            if (SoapHeader == null)
            {
                res = new jsonAcceptMessage(false, "Permiso Denegado");
                return(JsonConvert.SerializeObject(res));
            }

            if (!SoapHeader.IsUserCredentialsValid(SoapHeader))
            {
                res = new jsonAcceptMessage(false, "Permiso Denegado");
                return(JsonConvert.SerializeObject(res));
            }
            else
            {
                parseadorhl7.getPeticion(peticion.Mensaje);
                res = new jsonAcceptMessage(true, "OK");
                return(JsonConvert.SerializeObject(res));
            }
        }
        res = new jsonAcceptMessage(false, "No Hubo recepcion");
        return(JsonConvert.SerializeObject(res));
    }
Example #14
0
        //
        // GET: /RSS/
        public ActionResult RSSIndex()
        {
            int     userid = (int)Session["userid"];
            RSSUser user   = Db.users.Where(c => c.Id == userid).FirstOrDefault();
            parser  Pars   = new parser();

            if (user != null)
            {
                user.subscriptions  = Db.channels.Where(c => c.userId == user.Id).ToList();
                user.currentChannel = Db.channels.Where(c => c.isCurrent == true).FirstOrDefault();
                user.categories     = Db.categories.Where(c => c.userId == user.Id).ToList();

                user.currentCategory = Db.categories.Where(c => c.isCurrent == true).FirstOrDefault();
            }

            Pars.channels = user.subscriptions;
            if (user.currentChannel != null)
            {
                //user.currentChannel.item = Db.articles.Where(a => a.channelId == user.currentChannel.id).ToList();
                if (user.currentChannel.item.Count == 0)
                {
                    Pars.parseOneFeed(user.currentChannel.title);
                    channel ch = Pars.channels.Where(c => c.title == user.currentChannel.title).FirstOrDefault();
                    if (ch != null)
                    {
                        user.currentChannel.item = ch.item;
                    }

                    user.currentArticle = (string)Session["currentarticle"];
                }
            }
            if (user.currentChannel == null)
            {
                user.currentChannel = new channel();
            }


            return(View("RSSIndex", user));
        }
Example #15
0
        public static Expression fromFileName(System.String s, System.String filename)
        {
            System.String content = "";
            Expression    result;

            try
            {
                //UPGRADE_TODO: Constructor 'java.io.FileInputStream.FileInputStream' was converted to 'System.IO.FileStream.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileInputStreamFileInputStream_javalangString'"
                System.IO.FileStream infile = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                //UPGRADE_TODO: The differences in the expected value  of parameters for constructor 'java.io.BufferedReader.BufferedReader'  may cause compilation errors.  "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'"
                //UPGRADE_WARNING: At least one expression was used more than once in the target code. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1181'"
                System.IO.StreamReader filereader = new System.IO.StreamReader(new System.IO.StreamReader(infile, System.Text.Encoding.Default).BaseStream, new System.IO.StreamReader(infile, System.Text.Encoding.Default).CurrentEncoding);

                System.String nextline = "";
                while (nextline != null)
                {
                    content  = content + "\n" + nextline;
                    nextline = filereader.ReadLine();
                }
            }
            catch (System.Exception e)
            {
                System.Console.Out.WriteLine("error while reading input");
                result = new Variable("error");
            }

            try
            {
                parser p = new parser(new scanner(new System.IO.StringReader(s + content)));
                result = (Expression)p.parse().value_Renamed;
            }
            catch (System.Exception e)
            {
                System.Console.Out.WriteLine("parse error");
                result = new Variable("error");
            }
            return(result);
        }
Example #16
0
        //
        // GET: /RSS/
        public ActionResult RSSIndex()
        {
            int userid = (int)Session["userid"];
            RSSUser user = Db.users.Where(c => c.Id == userid).FirstOrDefault();
            parser Pars = new parser();

            if (user != null)
            {
                user.subscriptions = Db.channels.Where(c => c.userId == user.Id).ToList();
                user.currentChannel = Db.channels.Where(c => c.isCurrent == true).FirstOrDefault();
                user.categories = Db.categories.Where(c => c.userId == user.Id).ToList();

                user.currentCategory = Db.categories.Where(c => c.isCurrent == true).FirstOrDefault();
            }

            Pars.channels = user.subscriptions;
            if (user.currentChannel != null)
            {
                //user.currentChannel.item = Db.articles.Where(a => a.channelId == user.currentChannel.id).ToList();
                if (user.currentChannel.item.Count == 0)
                {
                    Pars.parseOneFeed(user.currentChannel.title);
                    channel ch = Pars.channels.Where(c => c.title == user.currentChannel.title).FirstOrDefault();
                    if (ch != null)
                    {
                        user.currentChannel.item = ch.item;
                    }

                    user.currentArticle = (string)Session["currentarticle"];

                }

            }
            if (user.currentChannel == null) { user.currentChannel = new channel(); }

            return View("RSSIndex", user);
        }
Example #17
0
        public ActionResult UpdateFeeds()
        {
            channel ch = Db.channels.Where(c => c.isCurrent == true).FirstOrDefault();

            if (ch != null)
            {
                parser p = new parser();
                p.parseAllFeeds();
                //channel chan = Pars.channels.Where(c => c.title == user.currentChannel.title).FirstOrDefault();
                if (ch != null)
                {
                  //  user.currentChannel.item = ch.item;
                }
            }

            return RedirectToAction("RSSIndex");
        }
Example #18
0
 It should be pretty obvious what this parser can and cannot do. If anyone reading this is a JSON buff (is there such a thing?) please feel free to expand and modify the parser to be more compliant. Currently I am using the .NET System.Convert namespace functions for parsing the data itself. It parses strings and numbers, which was all that I needed of it, but unless the formatting is supported by System.Convert, it may not incorporate all proper JSON strings. Also, having never written a JSON parser before, I don't doubt that I could improve the efficiency or correctness of the parser. It serves my purpose, and hopefully will help you with your project! Let me know if you make any improvements :) 
Example #19
0
	internal tokenizer(parser Parser, string str, eParserSyntax syntax)
	{
		mString = str;
		mLen = str.Length;
		mSyntax = syntax;
		mPos = 0;
		mParser = Parser;
		NextChar();
		// start the machine 
	}
Example #20
0
 public Downloader(int paralelism, parser parserFunc, dbSave dbSaveFunc)
 {
     this.semaphore  = new SemaphoreSlim(paralelism);
     this.parserFunc = parserFunc;
     this.dbSaveFunc = dbSaveFunc;
 }
Example #21
0
        async Task <List <BalanceClient> > GenerateTemplateGrid(int Cols)
        {
            GLReportTemplate template;
            var templateCache = api.GetCache(typeof(GLReportTemplate));

            if (templateCache != null)
            {
                template = (GLReportTemplate)templateCache.Get(AppliedTemplate);
            }
            else
            {
                template = new GLReportTemplate()
                {
                    _Name = AppliedTemplate
                };
                await api.Read(template);
            }
            if (template == null || template.RowId == 0)
            {
                return(null);
            }

            var reportline = await api.Query <GLReportLine>(template);

            var items = new TemplateDataContext();
            var TemplateReportlist = items.TemplateReportlist;

            TemplateReportlist.Capacity = reportline.Length;

            var newBalance = new List <BalanceClient>(reportline.Length);

            var  SumContext = new TemplateSumContext(Cols);
            var  colCount = PassedCriteria.selectedCriteria.Count;
            bool AnyHidden = false;
            int  i, j;

            for (j = 0; (j < reportline.Length); j++)
            {
                var line    = reportline[j];
                var amounts = new long[colCount];
                if (line._Accounts != null && !line._ExpressionSum)
                {
                    var SumAccounts = PropValuePair.GenereteWhereElements("Account", typeof(string), line._Accounts);
                    foreach (var balSum in balanceClient)
                    {
                        if (balSum.AccountTypeEnum > GLAccountTypes.CalculationExpression && AccountSum.IsIncluded(SumAccounts, balSum.AccountNo))
                        {
                            balSum.SumUpAmount(amounts);
                        }
                    }
                    if (Skip0Account)
                    {
                        bool found = false;
                        for (i = 0; (i < Cols); i++)
                        {
                            if (amounts[i] != 0)
                            {
                                found = true;
                                break;
                            }
                        }
                        if (!found)
                        {
                            continue;
                        }
                    }
                }
                if (line._InvertSign)
                {
                    for (i = 0; (i < Cols); i++)
                    {
                        amounts[i] = -amounts[i];
                    }
                }
                if (line._SaveTotal != 0)
                {
                    SumContext.CalcMethod.AddSum(line._SaveTotal, amounts);
                }
                if (line._Hide)
                {
                    AnyHidden = true;
                }

                var newBalanceCol = new BalanceClient(amounts);
                newBalanceCol.Acc._Name = line._Text;
                newBalance.Add(newBalanceCol);
                TemplateReportlist.Add(new TemplateDataItems(newBalanceCol, hdrData, line)
                {
                    Masterfontsize = template._FontSize
                });
            }

            // Now we will take all expressions and update.
            var pars = new parser(SumContext);

            for (j = 0; (j < TemplateReportlist.Count); j++)
            {
                var item = TemplateReportlist[j];
                var line = item.line;
                if (line._ExpressionSum)
                {
                    var InvertSign = line._InvertSign;
                    var e          = pars.parse(line._Accounts, Uniconta.Script.ValueType.Double);
                    if (e != null)
                    {
                        var amounts = item.blc.amount;
                        for (i = 0; (i < Cols); i++)
                        {
                            SumContext.CurIndex = i;
                            var val = NumberConvert.ToLong(e.Value());
                            amounts[i] = !InvertSign ? val : -val;
                        }
                        if (line._SaveTotal != 0)
                        {
                            SumContext.CalcMethod.AddSum(line._SaveTotal, amounts);
                        }
                    }
                }
            }

            if (AnyHidden)
            {
                for (i = TemplateReportlist.Count; (--i >= 0);)
                {
                    if (TemplateReportlist[i].line._Hide)
                    {
                        TemplateReportlist.RemoveAt(i);
                    }
                }
            }

            AccountName.Visible         = AccountNo.Visible = false;
            Text.Visible                = true;
            dgBalanceReport.ItemsSource = TemplateReportlist;
            templateReportData          = new object[] { items, hdrData, PassedCriteria.ObjBalance, null };
            return(newBalance);
        }