parsing

How to do this - python dictionary traverse and search

I have nested dictionaries: {'key0': {'attrs': {'entity': 'p', 'hash': '34nj3h43b4n3', 'id': '4130'}, u'key1': {'attrs': {'entity': 'r', 'hash': '34njasd3h43b4n3', 'id': '4130-1'}, u'key2': {'attrs': {'entity': 'c', ...

Implementing parser for escape sequences

I'm want to parse a custom string format that is persisting an object graphs state. This is ASP.Net scenario and I wanted something easy to use on the client (javascript) and server (c#). I have a format something like {Name1|Value1|Value2|...|ValueN}{Name2|Value1|...}{...}{NameN|...}. In this format I have 3 delimiters, {, }, and |. Fu...

is SFig language syntax efficient and clear (and better than Spring-Framework's XML DSL)?

ADDENDUM EDIT: Have not accepted an answer to this as there has not been any feedback from experienced Spring Framework developers. I've been working on a replacement DSL to use for Spring-Framework applicationContext.xml files (where bean initialization and dependency relationships are described for loading up into the Sprin...

I'm having a helluva time with data importing (PHP MySQL)

I'm building an app that pulls data in from an excel .csv file and applying various levels of formatting, moving and mapping. Most everything is figured out except for one hitch with cleaning the data. Here is an example of the data from Excel: GREAT PERFORMANCES,GREAT PERFORMANCES,57744 ROUND LAKE RD,NEW YORK,NY "GUASTAVINO'S, INC",...

Find Unique Characters in a File

I have a file with 450,000+ rows of entries. Each entry is about 7 characters in length. What I want to know is the unique characters of this file. For instance, if my file were the following; Entry ----- Yabba Dabba Doo Then the result would be Unique characters: {abdoy} Notice I don't care about case and don't need to order...

Parsing files to set data of an object - a design question

I recently had to write some code which parsed a file to set data in an object. As there were several objects and corresponding files involved here, I decided to separate the parsing code out. So I then had one class for parsing the files, CommandFileParser, and two classes per file/object type: one for the actual object itself and one ...

Best way to parse a string to a float with both "," and "." as fraction separator? (For a number < 5)

This is kind of related to my previous question, but not really. I have an input of which I don't know the culture. So it can both use ',' and '.' as separator for the fraction. The number will never be >5 though, so we can be rather sure if there's a separator, it will be for the fraction. I was looking at the TryParse method. It accep...

Convert > to HTML entity equivalent within HTML string

I'm trying to convert all instances of the > character to its HTML entity equivalent, >, within a string of HTML that contains HTML tags. The furthest I've been able to get with a solution for this is using a regex. Here's what I have so far: public static readonly Regex HtmlAngleBracketNotPartOfTag = new Regex("(?:<[^>]*(?:>|$...

JavaScript parser in Python

There is a JavaScript parser at least in C and Java (Mozilla), in JavaScript (Mozilla again) and Ruby. Is there any currently out there for Python? I don't need a JavaScript interpreter, per se, just a parser that's up to ECMA-262 standards. A quick google search revealed no immediate answers, so I'm asking the SO community. ...

Developing a simple parser

My day job includes working to develop a Pascal-like compiler. I've been working all along on optimizations and code generation. I would also like to start learning to build a simple parser for the same language. I'm however, not really sure how to go about this. Flex and Bison seem to be the choice. But, isn't it possible to write a p...

Yacc Problem: Make Data available in next Non Terminal

Hi! I want to make some variables I generate in b available in c: a : b c { ...some code...} A simple example: b : X { int result = 0; } | Y { int result = 1; } so I can, later on in c say: c : D { printf(result + 1); } | E { printf(result + 2); } Is there any chance to do that? Any help would really be apprecia...

Fastest way to determine whether a string contains a real or integer value

I'm trying to write a function that is able to determine whether a string contains a real or an integer value. This is the simplest solution I could think of: int containsStringAnInt(char* strg){ for (int i =0; i < strlen(strg); i++) {if (strg[i]=='.') return 0;} return 1; } But this solution is really slow when the string is lon...

Best Rails HTML Parser

Hi everyone, I know that Hpricot is still a standard but I remember hearing about a faster more expressive HTML parser for Ruby. Does anybody know what it's called and if it is worth switching to from Hpricot?? Thanks in advance ...

To parse an XML file in java whose path is to be got dynamically

Hi, I have a class Test in C:/proj/test_xml/Test.java. Given parser.parse("test.xml"); I need a way to parse test.xml whether it is in current directory, proj or in C:/ Also, the solution should not make use of java.io Thanks ...

NULL token in JavaCC

I have strange problem with token < NULL: "null" > in my JavaCC parser. In expression like String IsNullClause(): { String res = ""; } { <IS> {res += " IS ";} [<NOT> {res += " NOT ";} ] <NULL> {res += " NULL ";} { return res; } } parser doesn't see NULL token and throws exception that "null" expected. If I chang...

Finding statement pattern in c++ file

I have a macro that looks like this: #define coutError if (VERBOSITY_SETTING >= VERBOSITY_ERROR) ods() where ods() is a class that behaves similarly to cout, and VERBOSITY_SETTING is a global variable. There are a few of these for different verbosity settings, and it allows the code to look something like this: if (someErrorCon...

Fastest way to retrieve a <title> in PHP

I'm doing a bookmarking-system and looking for the fastest (easiest) way to retrive a page 's title with PHP. It would be nice to have something like $title = page_title($url) Thanks in advance! =) ...

Parsing unsupported date formats in via Cocoa's NSDate

With the Cocoa framework how can I parse @"2008-12-29T00:27:42-08:00" into an NSDate object? The standard -dateWithString: doesn't like it. ...

XML Parser for C

Can you suggest some of the best XML Parser for C ? ...

How does a Java compiler parse typecasts?

A simple expression like (x) - y is interpreted differently depending on whether x is a type name or not. If x is not a type name, (x) - y just subtracts y from x. But if x is a type name, (x) - y computes the negative of y and casts the resulting value to type x. In a typical C or C++ compiler, the question of whether x is a type or...