parsing

Can anyone help me convert this ANTLR 2.0 grammar file to ANTLR 3.0 syntax?

I've converted the 'easy' parts (fragment, @header and @member declerations etc.), but since I'm new to Antlr I have a really hard time converting the Tree statements etc. I use the following migration guide. The grammar file can be found here.... Below you can find some examples where I run into problems: For instance, I have prob...

What's the best C++ JSON parser?

I've seen the C++ JSON links on www.json.org but would like some feedback on which parser people prefer - for reliability, speed and ease of use. Thanks, Sam ...

What's the diference between the different XML parsing libraries in PHP5?

The original question is below, but I changed the title because I think it will be easier to find others with the same doubt. In the end, a XHTML document is a XML document. It's a beginner question, but I would like to know which do you think is the best library for parsing XHTML documents in PHP5? I have generated the XHTML from HTML...

Alternative to deprecated javax.servlet.http.HttpUtils.parseQueryString?

I am looking to parse a URL to obtain a collection of the querystring parameters in Java. To be clear, I need to parse a given URL(or string value of a URL object), not the URL from a servlet request. It looks as if the javax.servlet.http.HttpUtils.parseQueryString method would be the obvious choice, but it has been deprecated. Is the...

Best way to parse RSS/Atom feeds with PHP

I'm currently using Magpie RSS but it sometimes falls over when the RSS or Atom feed isn't well formed. Are there any other options for parsing RSS and Atom feeds with PHP? ...

Best way to search large file for data in .net

I am working on a project where I search through a large text file (large is relative, file size is about 1 Gig) for a piece of data. I am looking for a token and I want a dollar value immediately after that token. For example, this is the token 9,999,999.99 So here's is how I am approaching this problem. After a little analysis...

Finding invocations of a certain function in a c++ file using python

I need to find all occurrences of a function call in a c++ file using python, and extract the arguments for each call. I'm playing with the pygccxml package, and extracting the arguments given a string with the function call is extremely easy: from pygccxml.declarations import call_invocation def test_is_call_invocation(call): if c...

Read 64 bit integer string from file

We have a file that has a 64 bit integer as a string in it. How do we scanf() or otherwise parse this numeric string into an unsigned 64 bit integer type in C++ ? We are aware of things like %lld etc., but a lot of ways to do this parse seem to break compiles under different compilers and stdlibs. The code should compile under gcc and ...

What parameter parser libraries are there for C++?

I'd like to pass parameters to my C++ program in the following manner: ./myprog --setting=value Are there any libraries which will help me to do this easily? See also http://stackoverflow.com/questions/189972/argument-parsing-helpers-for-c-unix/191821 ...

How can I extract URL and link text from HTML in Perl?

I previously asked how to do this in Groovy. However, now I'm rewriting my app in Perl because of all the CPAN libraries. If the page contained these links: <a href="http://www.google.com"&gt;Google&lt;/a&gt; <a href="http://www.apple.com"&gt;Apple&lt;/a&gt; The output would be: Google, http://www.google.com Apple, http://www.ap...

Which parser generator to teach my students?

I am teaching (with others) a relatively introductory course in computer science for IT professionals without a background in CS. Since I developed the course materials on automata and grammars, I am also responsible for teaching about compilers and compiler construction. Years ago, when I studied compilation in college, all our example...

How can I fix my regex to not match too much with a greedy quantifier?

Hi everyone! I have the following line: "14:48 say;0ed673079715c343281355c2a1fde843;2;laka;hello ;)" I parse this by using a simple regexp: if($line =~ /(\d+:\d+)\ssay;(.*);(.*);(.*);(.*)/) { my($ts, $hash, $pid, $handle, $quote) = ($1, $2, $3, $4, $5); } But the ; at the end messes things up and I don't know why. Shouldn't th...

Scala combinator parsers - distinguish between number strings and variable strings

Hi, I'm doing Cay Horstmann's combinator parser exercises, I wonder about the best way to distinguish between strings that represent numbers and strings that represent variables in a match statement: def factor: Parser[ExprTree] = (wholeNumber | "(" ~ expr ~ ")" | ident) ^^ { case a: wholeNumber => Number(a.toInt) case a: Stri...

Quick & Dirty way to update "IDs" in a string formatted as XML (C#)

For a one-shot operation, i need to parse the contents of an XML string and change the numbers of the "ID" field. However, i can not risk changing anything else of the string, eg. whitespace, line feeds, etc. MUST remain as they are! Since i have made the experience that XmlReader tends to mess whitespace up and may even reformat your ...

How to parse a month name (string) to an integer for comparison in C#?

I need to be able to compare some month names I have in an array. It would be nice if there were some direct way like: Month.toInt("January") > Month.toInt("May") My Google searching seems to suggest the only way is to write your own method, but this seems like a common enough problem that I would think it would have been already imp...

How to parse a search term into the various question types?

I am writing an internal application where we let users to do a few different types of queries. The application allows users to search a database by either of the following keys: employeeId name (first or last) companyId status (workingFullTime, sickLeave, maternityLeave, etc) The brute force way is to simply make one webform for e...

Evaluating expressions inside C++ strings: "Hi ${user} from ${host}"

I'm looking for a clean C++ way to parse a string containing expressions wrapped in ${} and build a result string from the programmatically evaluated expressions. Example: "Hi ${user} from ${host}" will be evaluated to "Hi foo from bar" if I implement the program to let "user" evaluate to "foo", etc. The current approach I'm thinking ...

We have a graphical designer, now they want a text based designer. Suggestions?

I'm sorry I could not think of a better title. The problem is the following: For our customer we have created (as part of a larger application) a graphical designer which they can use to build "scenario's". These scenario's consist of "Composites" which in turn consist of "Commands". These command objects all derive from CommandBase a...

Grammar Writing Tools

I am trying to write a grammar in EBNF (barring a really good reason, it has to be EBNF) and am looking for a couple of utilities for it - if there's a GUI interface that can make one, that would be great, but the thing I'm looking for most is something that can check the grammar, for instance to see if it is LALR(n), and if so, what the...

Microsoft XML Parser 3.0

There is an application where I work that uses the Microsoft XML parser 3.0. I couldn't find any documentation about it and that's becoming a problem, because we cannot use this web application with Firefox, Safari and etc. Am I wrong? Can we install the XML parser 3.0 in different browsers? Who can i find a documentation about it? ...