parsing

Roll your own NMEA parser or use an open source GPS parser?

I do a lot of location aware computing, often incorporating GPS. I have my own little simple NMEA parser that doesn't do anything special - just transforms the GPS specific sentences into usable numbers, flags, and so forth. However, there is a lot of active development done on projects such as GPSD and Gypsy. If GPS were a simple mat...

Deserialisation/parsing of a custom message format

Hi, I am currently looking into writing a fast deesrialisation/parsing of a custom message format which are similar to BNF syntax. There are maybe 50 different objects involved. The grammar of the objects contains a recursive definition which is the biggest problem for me at the moment. Do you know any good examples or would you write yo...

Need help with PHP DOM XPath parsing table

I just recently read about the DOM module in PHP and now I'm trying to use it for parsing a HTML document. The page said that this was a much better solution than using preg but I'm having a hard time figuring out how to use it. The page contains a table with dates and X number of events for the date. First I need to get the text (a da...

Parsing and formatting search results

Search: Scripting+Language Web+Pages Applications Results: ...scripting language originally...producing dynamic web pages. It has...graphical applications....purpose scripting language that is...d creating web pages as output... Suppose I want a value that represents the amount of characters to allow as padding on eit...

Equation parsing in Python

How can I (easily) take a string such as 'sin(x)*x^2' which might be entered by a user at runtime and produce a python function that could be evaluated for any value of x? Does anyone know of any libraries or modules that takes care of this sort of thing? ...

How to use NSScanner?

Hi, I've just read Apple's docu of NSScanner. I'm trying to get the integer of that string: @"user logged (3 attempts)". I can't find any example, how to scan within parentheses. Any ideas? Here's the code: NSString *logString = @"user logged (3 attempts)"; NSScanner *aScanner = [NSScanner scannerWithString:logString]; [aScanner sca...

parser: parsing formulas in template files

I will first describe the problem and then what I currently look at, in terms of libraries. In my application, we have a set of variables that are always available. For example: TOTAL_ITEMS, PRICE, CONTRACTS, ETC (we have around 15 of them). A clients of the application would like to have certain calculations performed and displayed,...

Treetop SGF Parsing

I am currently trying to write a Treetop grammar to parse Simple Game Format files, and have it mostly working so far. However, there are a few questions that have come up. I am unsure how to actually access the structure Treetop generates after a parse. Is there a better way to handle capturing all characters than my chars rule? Ther...

Open webpage and parse it using JavaScript

Hello ll, I know JavaScript can open a link in a new window but is it possible to open a webpage without opening it in a window or displaying it to the user? What I want to do is parse that webpage for some text and use it as variables. Is this possible without any help from server side languages? If so, please send me in a direction ...

Parsing Dates with PHP

i am trying to write a program but i have no idea what to with parsing a date in this format into into a date stamp Jan 15 2005 12:00AM i do not care about the 12:00AM as all the records have that 12:00AM appended to them. ...

JavaMail Question or Bug?

I have a question about Java Mail and how it works with streams. In Java Mail 1.4.1 there is a MimeMessage constructor that accepts a stream. My understanding is that I could pass a stream to this constructor and it would parse it for me into a MimeMessage. I wrote 2 tests to prove this. The first test sends in a stream that contains...

When is an ambiguous grammar or production rule OK? (bison shift/reduce warnings)

There are certainly plenty of docs and howtos on resolving shift/reduce errors. The bison docs suggest the correct solution is usually to just %expect them and deal with it. When you have things like this: S: S 'b' S | 't' You can easily resolve them like this: S: S 'b' T | T T: 't' My question is: Is it better to leave the gram...

iPhone RSS thumbnail

I have a simple RSS reader. Stories are downloaded, put into a UITableView, and when you click it, each story loads in a UIWebView. It works great. Now though, I'd like to incorporate an image on the left side (like you'd see in the YouTube app). However, since my app pulls from an RSS feed, I can't simply specify image X to appear in ro...

How do I generate sentences from a formal grammar?

What's a common way of generating sentences from a grammar? I want an algorithm that's sort of the opposite of a parser. That is, given a formal context-free grammar (say LL), I want to generate an arbitrary sentence that conforms to that grammar. I use sentence here to mean any valid body of text, so it can actually be a whole program ...

How would you go about parsing markdown?

You can find the syntax here. The thing is, the source that follows with the download is written in perl. Which I have no intentions of honoring. It is riddled with regex and it relies on MD5 hashes to escape certain characters. Something is just wrong about that! I'm about to hard code a parser for markdown and I'm wonder if someone h...

Get file name from URL

In Java, given a java.net.URL or a String in the form of http://www.example.com/some/path/to/a/file.xml , what is the easiest way to get the file name, minus the extension? So, in this example, I'm looking for something that returns "file". I can think of several ways to do this, but I'm looking for something that's easy to read and sh...

How to parse a tab-separated line of text in Ruby?

I find Ruby's each function a bit confusing. If I have a line of text, an each loop will give me every space-delimited word rather than each individual character. So what's the best way of retrieving sections of the string which are delimited by a tab character. At the moment I have: line.split.each do |word| ... end but that is not ...

How to access 'row' and 'column' of nodes when parsing XML

In C#, is there a way to work out an XmlNode's position in the original XML 'text', when the document is loaded from a file or string? I want to be able to report problems with an XML document that I am processing. e.g: "Error in foo.xml - value of attribute 'pet' must be a species of fluffy mammal, at line 27, column 13 [snippet of o...

C# doubt, finding the datatype

I have the following variables: string str1 = "1"; string str2 = "asd"; string str3 = "3.5"; string str4 = "a"; Now I need to find the data type of each string i.e. the data type to which it can be converted if quotes are removed. Here is what I would like each variable to convert to: str1 - integer str2 - string str3 - doubl...

Python parsing

I'm trying to parse the title tag in an RSS 2.0 feed into three different variables for each entry in that feed. Using ElementTree I've already parsed the RSS so that I can print each title [minus the trailing )] with the code below: feed = getfeed("http://www.tourfilter.com/dallas/rss/by_concert_date") for item in feed: print rep...