Tag: parsing

C#方法重载决议不select具体的generics覆盖

这个完整的C#程序说明了这个问题: public abstract class Executor<T> { public abstract void Execute(T item); } class StringExecutor : Executor<string> { public void Execute(object item) { // why does this method call back into itself instead of binding // to the more specific "string" overload. this.Execute((string)item); } public override void Execute(string item) { } } class Program { static […]

从textarea获取每一行

<textarea> put returns between paragraphs for linebreak add 2 spaces at end indent code by 4 spaces quote by placing > at start of line </textarea> $text = value from this textarea; 如何: 1)从这个textarea( $text )获取每一行,并使用foreach()处理它们? 2)将<br />添加到每行的结尾,除了最后一行? 3)把每一行扔到一个数组中。 重要 – textarea内的文本可以是多语言的。 试图使用: $text = str_replace('\n', '<br />', $text); 但它不起作用。 谢谢。

为什么不这reinterpret_cast编译?

我明白reinterpret_cast是危险的,我只是做这个来testing它。 我有以下代码: int x = 0; double y = reinterpret_cast<double>(x); 当我尝试编译程序时,它给我一个错误说 invalid cast from type 'float' to type 'double 这是怎么回事? 我以为reinterpret_cast是你可以用来将苹果转换成潜艇的stream氓演员,为什么这个简单的演员不能编译?

如何识别语法是LL(1),LR(0)还是SLR(1)?

如何识别文法是LL(1),LR(0)还是SLR(1)? 任何人都可以请解释它使用这个例子,或任何其他的例子? X→Yz | 一个 Y→bZ | ε Z→ε

如何获得一个URL中的最后一个斜杠后的一切?

我怎样才能提取Python中的URL中的最后一个斜杠之后? 例如,这些url应该返回以下内容: URL: http://www.test.com/TEST1 returns: TEST1 URL: http://www.test.com/page/TEST2 returns: TEST2 URL: http://www.test.com/page/page/12345 returns: 12345 我试过urlparse,但是这给了我完整的path文件名,如page/page/12345 。

LL(1),LR(1),LR(0),LALR(1)语法的例子?

对于一些主要的语法分析algorithm(LL(1),LR(1),LR(0),LALR(1)),是否有一个很好的在线资源? 我发现了许多属于这些家庭的个人语法,但是我知道没有很好的资源,在那里有人写了大量的例子语法。 有谁知道这样的资源?

确定绝对或相对URL

我有一个string中的相对或绝对url。 我首先需要知道它是绝对的还是相对的。 我该怎么做呢? 然后,我想要确定该url的域是否在允许列表中。 以下是我的允许列表,例如: string[] Allowed = { "google.com", "yahoo.com", "espn.com" } 一旦我知道它的相对或绝对,我认为它相当简单: if (Url.IsAbsolute) { if (!Url.Contains("://")) Url = "http://" + Url; return Allowed.Contains(new Uri(Url).Host); } else //Is Relative { return true; }

什么是一个新的程序员会理解的parsing?

我是一名获得计算机科学学位的大学生。 我的很多同学真的没有做很多的编程。 他们已经完成了课堂作业,但是说实话,这些问题并没有真正教会你如何编程。 我还有其他几个学生问我如何parsing问题,而我也不太清楚如何向他们解释。 最好是开始一行一行地寻找子串,或者只是给他们更复杂的关于使用适当的词法分析等来创build令牌,使用BNF和所有其他的东西的讲座? 当我试图解释它们的时候,他们从来都不太明白。 什么是最好的方法来解释这一点,而不会混淆它们或阻止他们实际尝试。

将JSONstring转换为JSON对象c#

我有这个string存储在我的数据库中: str = "{ "context_name": { "lower_bound": "value", "upper_bound": "value", "values": [ "value1", "valueN" ] } }" 这个string已经是JSON格式,但是我想把它转换成JObject或者JSON对象。 JObject json = new JObject(); 我试过了json = (JObject)str; 投但它没有工作,所以我该怎么做呢?

无法从程序集中加载“SlowCheetah.Xdt.TransformXml”任务

在我的解决scheme的两个项目中安装了慢Cheeath(v。2.5.10.3)后,我收到以下错误: "The "SlowCheetah.Xdt.TransformXml" task could not be loaded from the assembly C:\Users \User\AppData\Local\Microsoft\MSBuild\SlowCheetah\v2.5.10.2\SlowCheetah.Xdt.dll. Could not load file or assembly 'file:///C:\Users\User\AppData\Local\Microsoft\MSBuild \SlowCheetah\v2.5.10.2\SlowCheetah.Xdt.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a […]