Tag: parsing

在哪里可以找到LR(1)解析器生成器的_simple_,易于理解的实现?

在哪里可以找到LR(1)解析器生成器的简单(尽可能但不简单!)实现? 我不是在寻找性能,只是能够生成LR(1)状态(项目集)。 C ++,C#,Java和Python都适合我。

理解开放封闭原则

当我遇到以下代码时,我正在重构 一个简单的脚本文件解析器的旧代码: StringReader reader = new StringReader(scriptTextToProcess); StringBuilder scope = new StringBuilder(); string line = reader.ReadLine(); while (line != null) { switch (line[0]) { case ‘$’: // Process the entire “line” as a variable, // ie add it to a collection of KeyValuePair. AddToVariables(line); break; case ‘!’: // Depending of what comes after the ‘!’ […]

Httplistener和文件上传

我正在尝试从我的网络服务器检索上传的文件。 当客户端通过webform(随机文件)发送文件时,我需要解析请求以获取文件并进一步处理它。 基本上,代码如下: HttpListenerContext context = listener.GetContext(); HttpListenerRequest request = context.Request; StreamReader r = new StreamReader(request.InputStream, System.Text.Encoding.Default); // this is the retrieved file from streamreader string file = null; while ((line = r.ReadLine()) != null){ // i read the stream till i retrieve the filename // get the file data out and break the loop […]