public async Task <(ListCell Images, string Raw)> Interact(int dx, int dy)
        {
            Console.WriteLine($"sending {dx} {dy}");
            await _interactorProcess.StandardInput.WriteLineAsync($"{dx} {dy} {ListParser.Serialize(_state)}");

            Console.WriteLine("sent");

            while (true)
            {
                var output = await _interactorProcess.StandardOutput.ReadLineAsync();

                if (string.IsNullOrEmpty(output))
                {
                    continue;
                }
                Console.WriteLine($"STDOUT: {output}");
                if (!output.StartsWith("+++"))
                {
                    continue;
                }
                var resultingData = output.Substring("+++".Length);
                var result        = SetInteractionResult(resultingData);
                Console.WriteLine("FLAG: " + result.Flag.Value);
                return(result.Image, resultingData);
            }
        }
        public void CopyAllFilesInADirectory_CopiesTheFiles()
        {
            _configs = ConfigFileHandler.LoadConfiguration();
            List <string> targetFolders = ListParser.GetSection(TV_FOLDERS, _configs);

            FileProcessor.CopyAllFilesInADirectory("N:\\Torrents\\complete", targetFolders);
        }
Beispiel #3
0
        public void CanParseLists(string parameterName, Type underLyingType, List <string> stringValues, object typedValue)
        {
            ListParser listParser = new ListParser(underLyingType, new SingleValueParser(underLyingType));

            ParameterInfo parameterInfo = typeof(ParameterClass).GetMethod("List").GetParameters()
                                          .Single(x => x.Name == parameterName);

            AppSettings appSettings = new AppSettings();

            CommandParameterInfo commandParamterInfo = new CommandParameterInfo(parameterInfo, appSettings);

            commandParamterInfo.SetValue(new CommandArgument()
            {
                Name           = parameterName,
                Description    = "description",
                MultipleValues = true,
                Values         = stringValues
            });

            IList parsedValues = listParser.Parse(commandParamterInfo);

            parsedValues.Should().HaveCount(stringValues.Count);

            parsedValues.Should().AllBeOfType(underLyingType);

            for (int i = 0; i < stringValues.Count; i++)
            {
                parsedValues[i].Should().Be(((IList)typedValue)[i]);
            }
        }
Beispiel #4
0
        public static bool Parse(SyntaxContext context, int position)
        {
            var list     = context.list;
            var offset   = 0;
            var index    = position;
            var count    = 0;
            var isMissed = false;

            if (!ParserHelper.IsOperator(list[index], "-"))
            {
                return(false);
            }
            else
            {
                // ignored
            }
            offset += 1;
            index   = position + offset;
            while (ParenParser.Parse(context, index))
            {
                ;
            }
            while (TableIParser.Parse(context, index))
            {
                ;
            }
            while (TableSParser.Parse(context, index))
            {
                ;
            }
            while (ListParser.Parse(context, index))
            {
                ;
            }
            while (PropertyParser.Parse(context, index))
            {
                ;
            }
            while (IndexParser.Parse(context, index))
            {
                ;
            }
            while (CallParser.Parse(context, index))
            {
                ;
            }
            if (!list[index].isRightValue)
            {
                return(false);
            }
            else
            {
                // ignored
            }
            offset += 1;
            index   = position + offset;
            context.Insert(position, ExpressionCreator.CreateNegate(list, position, offset));
            context.Remove(position + 1, offset);
            return(true);
        }
Beispiel #5
0
        public Contact SearchContact(string name)
        {
            var contactsToList = ListParser.ConvertListBoxToListOfContacts(_contacts.Items);

            var contact = contactsToList.FirstOrDefault(c => c.GetName() == name);

            return(contact);
        }
 private void Release_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
 {
     if (!_loading)
     {
         _configs = ListParser.Set("RELEASE", Release.Text, _configs);
         UpdateSource();
     }
 }
        public InteractionResult SetInteractionResult(string raw)
        {
            var resultingAst = new AstParser(new FunctionDeclarationsFactory()).Parse(raw);
            var result       = ParseInteractionResult((ListCell)ListParser.ParseAsList(resultingAst));

            _state = result.State;
            return(result);
        }
 private void Branch_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
 {
     if (!_loading)
     {
         _configs = ListParser.Set("BRANCH", Branch.Text, _configs);
         UpdateSource();
     }
 }
Beispiel #9
0
        public void List_IncludesRange()
        {
            ListParser parser = new ListParser();
            string     list   = "(def l (list [0 4]))";

            ListNode node = (ListNode)parser.Parse(list);

            Assert.IsTrue(node.Children[2] is ListNode);
        }
Beispiel #10
0
        public void List_MixedList()
        {
            ListParser parser = new ListParser();
            string     list   = "(a (b c) () 1 ok 2)";

            ListNode node = (ListNode)parser.Parse(list);

            Assert.AreEqual(6, node.Children.Count);
        }
Beispiel #11
0
        public void List_ListOfTwoLists()
        {
            ListParser parser = new ListParser();
            string     list   = "(() ())";

            ListNode node = (ListNode)parser.Parse(list);

            Assert.IsTrue(node.Children.Count == 2);
        }
Beispiel #12
0
        public void List_ListOfOneIdentifier()
        {
            ListParser parser = new ListParser();
            string     list   = "(a)";

            ListNode node = (ListNode)parser.Parse(list);

            Assert.IsTrue(node.Children.Count == 1);
        }
Beispiel #13
0
        public void List_EmptyList()
        {
            ListParser parser = new ListParser();
            string     list   = "()";

            ListNode node = (ListNode)parser.Parse(list);

            Assert.IsTrue(node.Children.Count == 0);
        }
Beispiel #14
0
        public void GettingEverythingTest()
        {
            var provider = new PlanProvider(TestPlanUrl);
            var ids      = ListParser.GetAll(provider);

            Assert.Equal("14", ids["classes"]["1gt"]);
            Assert.Equal("14", ids["teachers"]["J.Frańczuk (Fr)"]);
            Assert.Equal("39", ids["rooms"]["oh3"]);
        }
        private void UpdateSource()
        {
            string branch  = ListParser.Get("BRANCH=", _configs);
            string release = ListParser.Get("RELEASE=", _configs);
            string build   = ListParser.Get("BUILD=", _configs);
            string deploymentSourcePath = ListParser.Get("SOURCE-PATH=", _configs);

            Source.Text = deploymentSourcePath + "\\" + branch + "\\" + release + "." + build;
        }
Beispiel #16
0
        public void GettingClassesTest()
        {
            var provider = new PlanProvider(TestPlanUrl);
            var classes  = ListParser.GetClasses(provider);

            Assert.NotEmpty(classes);
            Assert.Equal("1", classes["1a"]);
            Assert.Equal("24", classes["3bt 3"]);
        }
Beispiel #17
0
        public void List_ListOfTwoIdentifiers()
        {
            ListParser parser = new ListParser();
            string     list   = "(a b)";

            ListNode node = (ListNode)parser.Parse(list);

            Assert.AreEqual(2, node.Children.Count);
        }
Beispiel #18
0
        public void GettingTeachersTest()
        {
            var provider = new PlanProvider(TestPlanUrl);
            var teachers = ListParser.GetTeachers(provider);

            Assert.NotEmpty(teachers);
            Assert.Equal("13", teachers["M.Filipowski (Fm)"]);
            Assert.Equal("22", teachers["A.Harkot (Ha)"]);
            Assert.Equal("11", teachers["K.Czochra (Cr)"]);
        }
Beispiel #19
0
        public void GettingRoomsTest()
        {
            var provider = new PlanProvider(TestPlanUrl);
            var rooms    = ListParser.GetRooms(provider);

            Assert.NotEmpty(rooms);
            Assert.Equal("22", rooms["17"]);
            Assert.Equal("33", rooms["sg10"]);
            Assert.Equal("50", rooms["217"]);
        }
Beispiel #20
0
		static void Main(string[] args) {
			AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes())
				.Where(x => x.IsSubclassOf(typeof(Builtin)))
				.ForEach(x => ((Builtin) Activator.CreateInstance(x)).Define());
			
			var ptree = ListParser.Parse(File.ReadAllText("aarch64.isa"));
			ptree = MacroProcessor.Rewrite(ptree);
			var defs = Def.ParseAll(ptree).Select(InferRuntime).ToList();
			BuildDisassembler(defs);
			BuildInterpreter(defs);
			BuildRecompiler(defs);
		}
Beispiel #21
0
 public static IEnumerable <(int, int)> ToPixelList(ListCell image)
 {
     return(ListParser.EnumerateList(image).Cast <PairCell>().Select(
                pair =>
     {
         checked
         {
             var x = (int)((NumberCell)pair.Item1).Value;
             var y = (int)((NumberCell)pair.Item2).Value;
             return (x, y);
         }
     }));
 }
Beispiel #22
0
 public Tree<CellBase> Parse(string input) {
     var alternationParser = new AlternationParser();
     var cells = new ListParser("td", alternationParser, false);
     var rows = new ListParser("tr", cells, true);
     var tables = new ListParser("table", rows, true);
     var items = new ListParser("li", alternationParser, false);
     var lists = new ListParser("ul", items, true);
     alternationParser.ChildParsers = new [] {tables, lists};
     var root = new CellBase(string.Empty, "div");
     var result = new TreeList<CellBase>(root);
     foreach (Tree<CellBase> branch in tables.Parse(new LexicalAnalyzer(input))) result.AddBranch(branch);
     return result;
 }
Beispiel #23
0
        public void ParseMixedList()
        {
            const string MixedListMarkup = "* Point one\r\n* Point two\r\n## Step 1\r\n## Step 2\r\n## Step 3\r\n* Point three\r\n** Sub point 1\r\n** Sub point 2\r\n";

            DomDocument         document           = new DomDocument();
            IBlockElementParser blockElementParser = new ListParser();

            blockElementParser.Parse(new TextileAuthoringEngine(), document, MixedListMarkup);

            HtmlAuthoringDomElementVisitor visitor = new HtmlAuthoringDomElementVisitor();

            visitor.Visit(document);

            //
            // Root unordered list

            /*UnorderedList rootUnorderedList = document.ChildElements[0] as UnorderedList;
             *
             * Assert.IsNotNull(rootUnorderedList);
             * Assert.AreEqual(3, rootUnorderedList.ChildElements.Count);
             *
             * //
             * // List item
             * ListItem listItem = rootUnorderedList.ChildElements[1] as ListItem;
             *
             * Assert.IsNotNull(listItem);
             * Assert.AreEqual(2, listItem.ChildElements.Count);
             *
             * //
             * // Ordered list
             * OrderedList orderedList = listItem.ChildElements[1] as OrderedList;
             *
             * Assert.IsNotNull(orderedList);
             * Assert.AreEqual(3, orderedList.ChildElements.Count);
             *
             * //
             * // One more list item
             * listItem = rootUnorderedList.ChildElements[2] as ListItem;
             *
             * Assert.IsNotNull(listItem);
             * Assert.AreEqual(2, listItem.ChildElements.Count);
             *
             * //
             * // Unordered list
             * UnorderedList unorderedList = listItem.ChildElements[1] as UnorderedList;
             *
             * Assert.IsNotNull(unorderedList);
             * Assert.AreEqual(2, unorderedList.ChildElements.Count);*/
            Assert.AreEqual("<ul><li></li><li><ol><li></li><li></li><li></li></ol></li><li><ul><li></li><li></li></ul></li></ul>",
                            visitor.Html);
        }
Beispiel #24
0
        public void ParseMultilevelList()
        {
            const string MultilevelListMarkup = "# one\r\n## aye\r\n## bee\r\n## see\r\n# two\r\n## x\r\n## y\r\n# three\r\n";

            DomDocument         document           = new DomDocument();
            IBlockElementParser blockElementParser = new ListParser();

            blockElementParser.Parse(new TextileAuthoringEngine(), document, MultilevelListMarkup);

            HtmlAuthoringDomElementVisitor visitor = new HtmlAuthoringDomElementVisitor();

            visitor.Visit(document);

            //
            // Root ordered list

            /* OrderedList rootOrderedList = document.ChildElements[0] as OrderedList;
             *
             * Assert.IsNotNull(rootOrderedList);
             * Assert.AreEqual(3, rootOrderedList.ChildElements.Count);
             *
             * //
             * // First list item, which contains two child items - TextBlock and OrderedList
             * ListItem item = rootOrderedList.ChildElements[0] as ListItem;
             *
             * Assert.IsNotNull(item);
             * Assert.AreEqual(2, item.ChildElements.Count);
             *
             * //
             * // The ordered list contains 3 items
             * OrderedList orderedList = item.ChildElements[1] as OrderedList;
             *
             * Assert.IsNotNull(orderedList);
             * Assert.AreEqual(3, orderedList.ChildElements.Count);
             *
             * //
             * // Second list item, which contains two child items as well
             * item = rootOrderedList.ChildElements[1] as ListItem;
             *
             * Assert.IsNotNull(item);
             * Assert.AreEqual(2, item.ChildElements.Count);
             *
             * //
             * // The ordered list contains 2 items
             * orderedList = item.ChildElements[1] as OrderedList;
             *
             * Assert.IsNotNull(orderedList);
             * Assert.AreEqual(2, orderedList.ChildElements.Count);*/
            Assert.AreEqual("<ol><li><ol><li></li><li></li><li></li></ol></li><li><ol><li></li><li></li></ol></li><li></li></ol>",
                            visitor.Html);
        }
Beispiel #25
0
 public Tree<Cell> Parse(string input)
 {
     var alternationParser = new AlternationParser();
     var cells = new ListParser("td", alternationParser, false, makeTreeCell);
     var rows = new ListParser("tr", cells, true, makeTreeCell);
     var tables = new ListParser("table", rows, true, makeTreeCell);
     var items = new ListParser("li", alternationParser, false, makeTreeCell);
     var lists = new ListParser("ul", items, true, makeTreeCell);
     alternationParser.ChildParsers = new [] {tables, lists};
     var result = makeTreeCell(string.Empty);
     result.Value.SetTag("div");
     foreach (var branch in tables.Parse(new LexicalAnalyzer(input))) result.Add(branch);
     return result;
 }
        public static ListFactory GetListFactory(ISchema schema, QueryType queryType, IDataRecord header)
        {
            ColumnCacheKey cacheKey = GetCacheKey(schema, queryType, header);

            return(listMap.GetOrAdd(cacheKey, k =>
            {
                BufferCache buffer = GetBuffer(k.Schema);
                ListParser parser = new ListParser(buffer, queryType);
                ListResult result = parser.Parse(k.Header);

                QueryCompiler compiler = new QueryCompiler();

                return compiler.Compile(result);
            }));
        }
Beispiel #27
0
        public void List_IncludesGarbage()
        {
            ListParser parser = new ListParser();
            string     list   = "(kdi i4ji 4k)";

            ListNode node;

            try
            {
                node = (ListNode)parser.Parse(list);
            }
            catch
            {
                return;
            }
            Assert.Fail("Should throw garbage exception");
        }
        private void SaveSettings()
        {
            string branch               = Branch.Text;
            string release              = Release.Text;
            string build                = Build.Text;
            string serviceTargetPath    = ServiceWebsite.Text;
            string websiteTargetPath    = ClientWebsite.Text;
            string crmServiceTargetPath = CrmWebsite.Text;

            _configs = ListParser.Set("BRANCH", branch, _configs);
            _configs = ListParser.Set("RELEASE", release, _configs);
            _configs = ListParser.Set("BUILD", build, _configs);
            _configs = ListParser.Set("SERVICE-TARGET-PATH", serviceTargetPath, _configs);
            _configs = ListParser.Set("WEBSITE-TARGET-PATH", websiteTargetPath, _configs);
            _configs = ListParser.Set("CRM-SERVICE-TARGET-PATH", crmServiceTargetPath, _configs);

            ConfigFileHandler.SaveConfiguration(_configs);
        }
Beispiel #29
0
        public Tree <CellBase> Parse(string input)
        {
            var alternationParser = new AlternationParser();
            var cells             = new ListParser("td", alternationParser, false);
            var rows   = new ListParser("tr", cells, true);
            var tables = new ListParser("table", rows, true);
            var items  = new ListParser("li", alternationParser, false);
            var lists  = new ListParser("ul", items, true);

            alternationParser.ChildParsers = new [] { tables, lists };
            var root   = new CellBase(string.Empty, "div");
            var result = new TreeList <CellBase>(root);

            foreach (Tree <CellBase> branch in tables.Parse(new LexicalAnalyzer(input)))
            {
                result.AddBranch(branch);
            }
            return(result);
        }
Beispiel #30
0
        public Tree <Cell> Parse(string input)
        {
            var alternationParser = new AlternationParser();
            var cells             = new ListParser("td", alternationParser, false, makeTreeCell);
            var rows   = new ListParser("tr", cells, true, makeTreeCell);
            var tables = new ListParser("table", rows, true, makeTreeCell);
            var items  = new ListParser("li", alternationParser, false, makeTreeCell);
            var lists  = new ListParser("ul", items, true, makeTreeCell);

            alternationParser.ChildParsers = new [] { tables, lists };
            var result = makeTreeCell(string.Empty);

            result.Value.SetTag("div");
            foreach (var branch in tables.Parse(new LexicalAnalyzer(input)))
            {
                result.Add(branch);
            }
            return(result);
        }
        private static InteractionResult ParseInteractionResult(ListCell input)
        {
            var results = ListParser.EnumerateList(input).ToList();
            var flag    = (NumberCell)results[0];
            var state   = results[1];
            var image   = (ListCell)results[2];

            if (results.Count > 3)
            {
                Console.WriteLine("WARNING: more than 3 results");
            }

            return(new InteractionResult
            {
                Flag = flag,
                State = state,
                Image = image
            });
        }
        private void LoadSettings()
        {
            string websiteTargetPath    = ListParser.Get("WEBSITE-TARGET-PATH=", _configs);
            string serviceTargetPath    = ListParser.Get("SERVICE-TARGET-PATH=", _configs);
            string crmServiceTargetPath = ListParser.Get("CRM-SERVICE-TARGET-PATH=", _configs);
            string branch  = ListParser.Get("BRANCH=", _configs);
            string release = ListParser.Get("RELEASE=", _configs);
            string build   = ListParser.Get("BUILD=", _configs);
            string deploymentSourcePath = ListParser.Get("SOURCE-PATH=", _configs);

            _loading            = true;
            Branch.Text         = branch;
            Release.Text        = release;
            Build.Text          = build;
            ServiceWebsite.Text = serviceTargetPath;
            ClientWebsite.Text  = websiteTargetPath;
            CrmWebsite.Text     = crmServiceTargetPath;
            Source.Text         = deploymentSourcePath + "\\" + branch + "\\" + release + "." + build;
            _loading            = false;
        }
        public Parsers()
        {
            // Create inline parsers
            LineBreakParser = new LineBreakParser();
            BacktickParser = new BacktickParser();
            InlineCodeParser = new InlineCodeParser();
            EscapedCharParser = new EscapedCharParser();
            EntityParser = new EntityParser();
            StrWithEntitiesParser = new StrWithEntitiesParser(this);
            EscapedStringParser = new EscapedStringParser(this);
            AutolinkParser = new AutolinkParser(this);
            AutolinkEmailParser = new AutolinkEmailParser(this);
            RawHtmlParser = new RawHtmlParser();
            LinkLabelParser = new LinkLabelParser(this);
            LinkDestinationParser = new LinkDestinationParser(this);
            LinkTitleParser = new LinkTitleParser(this);
            LinkReferenceParser = new LinkReferenceParser(this);
            LinkParser = new LinkParser(this);
            ImageParser = new ImageParser(this);
            ImageReferenceParser = new ImageReferenceParser(this);
            LinkDefinitionParser = new LinkDefinitionParser(this);
            EmphasisParser = new EmphasisParser(this);
            InlineParser = new InlineParser(this);
            CommonMarkInlineParser = new CommonMarkInlineParser(this);

            // Create block parsers
            IndentedCodeParser = new IndentedCodeParser();
            LazyParagraphContinuationParser = new LazyParagraphContinuationParser();
            BlockQuoteParser = new BlockQuoteParser();
            ATXHeaderParser = new ATXHeaderParser();
            FencedCodeParser = new FencedCodeParser();
            HtmlBlockParser = new HtmlBlockParser();
            SetExtHeaderParser = new SetExtHeaderParser();
            HorizontalRuleParser = new HorizontalRuleParser();
            ListParser = new ListParser();
        }
Beispiel #34
0
 private List<ast.Declaration> DeclarationList()
 {
     var parser = new ListParser(Input, ErrorReporter);
     return parser.ParseList<ast.Declaration, PunctuationToken>(Declaration, "}");
 }
Beispiel #35
0
 // List parsing with sub-parsers.
 private List<ast.ClassDeclaration> ClassDeclarationList()
 {
     var parser = new ListParser(Input, ErrorReporter);
     return parser.ParseList(ClassDeclaration);
 }
Beispiel #36
0
 private List<ast.IStatement> StatementList()
 {
     var parser = new ListParser(Input, ErrorReporter);
     return parser.ParseList<ast.IStatement, PunctuationToken>(Statement, "}");
 }