parsing

How does backtracking affect the language recognized by a parser?

≯℡__Kan透↙ 提交于 2021-02-18 22:26:49
问题 Not a school related question, but it comes up in the Dragon Book (Compilers: Principles, Techniques, and Tools) in an exercise: The grammar: S ::= aSa | aa generates all even length strings of a's except for the empty string. a) Construct a recursive-descent parser with backtracking for this grammar that tries the alternative aSa before aa. Show that the procedure for S succeeds on 2, 4, or 8 a's, but fails on 6 a's. b) What language does your parser recognize? I'm stumped. It seems like if

How does backtracking affect the language recognized by a parser?

[亡魂溺海] 提交于 2021-02-18 22:26:07
问题 Not a school related question, but it comes up in the Dragon Book (Compilers: Principles, Techniques, and Tools) in an exercise: The grammar: S ::= aSa | aa generates all even length strings of a's except for the empty string. a) Construct a recursive-descent parser with backtracking for this grammar that tries the alternative aSa before aa. Show that the procedure for S succeeds on 2, 4, or 8 a's, but fails on 6 a's. b) What language does your parser recognize? I'm stumped. It seems like if

On complexity of recursive descent parsers

浪子不回头ぞ 提交于 2021-02-18 20:32:58
问题 It's known that recursive descent parsers may require exponential time in some cases; could anyone point me to the samples, where this happens? Especially interested in cases for PEG (i.e. with prioritized choices). 回答1: It's because you can end up parsing the same things (check the same rule at the same position) many times in different recursion branches. It's kind of like calculating the n-th Fibonacci number using recursion. Grammar: A -> xA | xB | x B -> yA | xA | y | A S -> A Input:

How can I parse a string into appropriate arguments for child_process.spawn?

限于喜欢 提交于 2021-02-18 19:58:32
问题 I want to be able to take a command string, for example: some/script --option="Quoted Option" -d --another-option 'Quoted Argument' And parse it into something that I can send to child_process.spawn : spawn("some/script", ["--option=\"Quoted Option\"", "-d", "--another-option", "Quoted Argument"]) All of the parsing libraries I've found (e.g. minimist, etc.) do too much here by parsing it into some kind of options object, etc. I basically want the equivalent of whatever Node does to create

Gpx parser or GPX documentation

瘦欲@ 提交于 2021-02-18 17:14:04
问题 I'm developing an iOS 5 application. I want to develop a GPX parser but I'm wondering if there is one developed before I start to developing it. Do you know if there is an Objective-c GPX parser? 回答1: Have a look at: http://terrabrowser.googlecode.com/svn/trunk/ There you will find GPSFileParser.m and GPSFileParser.h which may help you. 回答2: I have been working on the gpx-api for a little while. It will read gpx files and has a data model that is useable (in my opinion). 回答3: There is no

Help with Imgur API and VB.NET - Image POST

删除回忆录丶 提交于 2021-02-18 17:10:23
问题 I'm trying to send an image to Imgur's server. Everything went fine and I'm getting the URL of the image from the parser but when I'm trying to open it on the web browser, I'm not getting the image... only a "broken image" icon. I think it's a problem in the convertion to the byte array.... but I don't get it. please let me know/fix my code. Dim image As Image = image.FromFile(OpenFile.FileName) Dim ms As New MemoryStream() ' Convert Image to byte[] image.Save(ms, System.Drawing.Imaging

Help with Imgur API and VB.NET - Image POST

拜拜、爱过 提交于 2021-02-18 17:09:32
问题 I'm trying to send an image to Imgur's server. Everything went fine and I'm getting the URL of the image from the parser but when I'm trying to open it on the web browser, I'm not getting the image... only a "broken image" icon. I think it's a problem in the convertion to the byte array.... but I don't get it. please let me know/fix my code. Dim image As Image = image.FromFile(OpenFile.FileName) Dim ms As New MemoryStream() ' Convert Image to byte[] image.Save(ms, System.Drawing.Imaging

Help with Imgur API and VB.NET - Image POST

点点圈 提交于 2021-02-18 17:09:29
问题 I'm trying to send an image to Imgur's server. Everything went fine and I'm getting the URL of the image from the parser but when I'm trying to open it on the web browser, I'm not getting the image... only a "broken image" icon. I think it's a problem in the convertion to the byte array.... but I don't get it. please let me know/fix my code. Dim image As Image = image.FromFile(OpenFile.FileName) Dim ms As New MemoryStream() ' Convert Image to byte[] image.Save(ms, System.Drawing.Imaging

Help with Imgur API and VB.NET - Image POST

人走茶凉 提交于 2021-02-18 17:09:19
问题 I'm trying to send an image to Imgur's server. Everything went fine and I'm getting the URL of the image from the parser but when I'm trying to open it on the web browser, I'm not getting the image... only a "broken image" icon. I think it's a problem in the convertion to the byte array.... but I don't get it. please let me know/fix my code. Dim image As Image = image.FromFile(OpenFile.FileName) Dim ms As New MemoryStream() ' Convert Image to byte[] image.Save(ms, System.Drawing.Imaging

Using R to parse out Surveymonkey csv files

青春壹個敷衍的年華 提交于 2021-02-17 19:01:24
问题 I'm trying to analyse a large survey created with surveymonkey which has hundreds of columns in the CSV file and the output format is difficult to use as the headers run over two lines. Has anybody found a simple way of managing the headers in the CSV file so that the analysis is manageable ? How do other people analyse results from Surveymonkey? Thanks! 回答1: You can export it in a convenient form that fits R from Surveymonkey, see download responses in 'Advanced Spreadsheet Format' 回答2: What