parsing

Parsing T-SQL to Parameterize a Query

The application I am currently working on generates a lot of SQL inline queries. All generated SQL is then handed off to a database execution class. I want to write a parsing service for the data execution class that will take a query like this: SELECT field1, field2, field3 FROM tablename WHERE foo=1 AND bar="baz" and turn it into so...

How can I extract a line or row?

How can I extract the whole line in a row, for example, row 3. These data are saved in my text editor in linux. Here's my data: 1,julz,kath,shiela,angel 2,may,ann,janice,aika 3,christal,justine,kim 4,kris,allan,jc,mine I want output like: 3,christal,justine,kim ...

C#/.NET Lexer Generators

I'm looking for a decent lexical scanner generator for C#/.NET -- something that supports Unicode character categories, and generates somewhat readable & efficient code. Anyone know of one? EDIT: I need support for Unicode categories, not just Unicode characters. There are currently 1421 characters in just the Lu (Letter, Uppercase)...

Query Parse error in shopping kart application

In my shopping cart app, I execute a query using: 44: @mysql_query("insert into cart(cookieId, itemId, qty) values('" . GetCartId() . "', $itemId, $qty)"); But when I view the webpage, I get the following error: Parse error: parse error, unexpected T_STRING, expecting '{' in H:\Program Files\EasyPHP 2.0b1\www\beta\cart.php on line 44 ...

Parsing and generating Microsoft Office 2007 files (.docx, .xlsx, .pptx)

Hello, I have a web project where I must import text and images from a user-supplied document, and one of the possible formats is Microsoft Office 2007. There's also a need to generate documents in this format. The server runs CentOS 5.2 and has PHP/Perl/Python installed. I can execute local binaries and shell scripts if I must. We use...

String to Int in java - Likely bad data, need to avoid exceptions.

Seeing as Java doesn't have nullable types, nor does it have a TryParse(), how do you handle input validation without throwing an exceptions? The usual way: String userdata = /*value from gui*/ int val; try { val = Integer.parseInt(userdata); } catch (NumberFormatException nfe) { // bad data - set to sentinel val = Integer.MIN...

How do I find character positions in ANTLR 2?

I have a simple grammar, and have produced a pair of c# classes using antlr 2.7.7. When the parser finds an error with a token, it throws an exception; I want to find out how many characters into a parsed stream the token came. How do I do that? ...

Search then Extract

I have here a multiple data, I want to search a name and date, if I typed JULIUS CESAR as name then the whole data about JULIUS will be extracted.? What if i want only to extract information? This file was save in texteditor(linux). # Record number: 1 Date: 08-Oct-08 Time: 23:45:01 Name: JULIUS CESAR Address: BAGUIO CITY, Philippines I...

?? Dynamic ?? parser

Does there exist a parser that generates an AST/parse tree at runtime? Kind of like a library that would accept a string of EBNF grammar or something analogous and spit out a data structure? I'm aware of antlr, jlex and their ilk. They generate source code which could do this. (like to skip the compile step) I'm aware of Boost::Spirit...

Logparser (Microsoft's one) or similar for Unix?

I've been looking for quite some time for an application that fills the same role as Logparser, an awesome piece of technology, but for Unix. Does anyone know of something this? (I've looked at Splunk but its an overkill, a simple command line is all I really need) Note: Being able to make SQL queries on random logs, is great and much m...

Argument-parsing helpers for C/UNIX

I know of the following: the venerable getopt(3) the extended getopt_long glibc's argp parser for unix-style argument vectors popt from the GNOME project (or its spiritual successor in Glib) I'm sure there's more that I haven't used or even heard of; a quick Google search reveals Gopt, argtable, and Optlist. Personally, I like argp ...

What is the easiest way to parse an INI file in Java?

I am writing a drop-in replacement for a legacy application in Java. One of the requirements is that the ini files that the older application used have to be read as-is into the new Java Application. The format of this ini files is the common windows style, with header sections and key=value pairs, using # as the character for commenti...

Why can't .NET parse a date string with a timezone?

.NET throws an exception trying to parse a datetime string in this format: Fri, 10 Oct 2008 00:05:51 CST Convert.ToDateTime("Fri, 10 Oct 2008 00:05:51 CST") results in an exception: The string was not recognized as a valid DateTime. There is a unknown word starting at index 26 Character 26 obviously being the start of "CST" ...

How to parse a .xfa file

Hoping that someone has some info on how to parse a xfa file. I can parse csv or xml files just fine, but an xfa one has come along and I'm not familar with the format. Looks like tab delimited body with column metadata at the top. Anyone dealt with these before or can give me a steer on how to parse them? I use vb.net but the language...

How to parse a string to an int in C++?

What's the C++ way of parsing a string (given as char *) into an int? Robust and clear error handling is a plus (instead of returning zero). ...

PHP: Best way to extract text within parenthesis?

What's the best/most efficient way to extract text set between parenthesis? Say I wanted to get the string "text" from the string "ignore everything except this (text)" in the most efficient manner possible. So far, the best I've come up with is this: $fullString = "ignore everything except this (text)"; $start = strpos('(', $fullStrin...

How to parse a command line with regular expressions?

I want to split a command line like string in single string parameters. How look the regular expression for it. The problem are that the parameters can be quoted. For example like: "param 1" param2 "param 3" should result in: param 1, param2, param 3 ...

How do you convert a C++ string to an int?

How do you convert a C++ string to an int? Assume you are expecting the string to have actual numbers in it ("1", "345", "38944", for example). Also, let's assume you don't have boost, and you really want to do it the C++ way, not the crufty old C way. ...

Can you recommend a Java library for reading (and possibly writing) CSV files?

Can you recommend a Java library for reading, parsing, validating and mapping rows in a comma separated value (CSV) file to Java value objects (JavaBeans)? ...

How do I parse a base query (à la Google Data) in Java?

I have a system where I query a REST / Atom server for documents. The queries are inspired by GData and look like : http://server/base/feeds/documents?bq=[type in {'news'}] I have to parse the "bq" parameter to know which type of documents will be returned without actually doing the query. So for example, bq=[type = 'news'] ...