parsing

Using pyparsing to parse a word escape-split over multiple lines

I'm trying to parse words which can be broken up over multiple lines with a backslash-newline combination ("\\n") using pyparsing. Here's what I have done: from pyparsing import * continued_ending = Literal('\\') + lineEnd word = Word(alphas) split_word = word + Suppress(continued_ending) multi_line_word = Forward() multi_line_word << ...

Regex to get value within tag

I have a sample set of XML returned back: <rsp stat="ok"> <site> <id>1234</id> <name>testAddress</name> <hostname>anotherName</hostname> ... </site> <site> <id>56789</id> <name>ba</name> <hostname>alphatest</hostname> ... </site> </rsp> I want to extract everything within <name></name> but not ...

Parse players currently in lobby

I'm attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined). Note that Samual has rejoined. [Sun Nov 15 14:12:50 2009] [GAME: Tower Defense Join Fast!] player [Samual|192.168.1.115] joined the ga...

What's the difference between a parser and a scanner?

I already made a scanner, now I'm supposed to make a parser. What's the difference? ...

How do I strip all the html out of database records, than create an xml file?

Hello! Im trying to figure out a way to strip out all html tags from records in a database, then create xml? Any ideas? Built on asp.net 2.0 with sql server ...

How do you make a parser from a yacc file?

I'v been given the following yacc file. How do I make a parser out of it? Do I have to make a scanner first? /* C-Minus BNF Grammar */ %token ELSE %token IF %token INT %token RETURN %token VOID %token WHILE %token ID %token NUM %token LTE %token GTE %token EQUAL %token NOTEQUAL %% program : declaration_list ; declaration_list : d...

Programmatically parse and edit C++ Source Files

Hi, I want to able programmatically parse and edit C++ source files. I need to be able to change/add code in certain sections of code (i.e. in functions, class blocks, etc). I would also (preferably) be able to get comments as well. Part of what I want to do can be explained by the following piece of code: CPlusPlusSourceParser cp = n...

Special Ocassion parser in JAVA

Hey guys, I am working on a date parser in Java. Just wanted some information on if there is any java library which could parse special occasions like for example if I give input as: Christmas or new year, it returns a date for this. Thanks in advance. Regards, Pranav ...

C#: How to split this string

I have some strings, entered by users, that may look like this: ++7 7++ 1++7 1+7 1++7+10++15+20+30++ Those are to mean: Anything up to and including 7 Anything from 7 and up 1 and 7 and anything inbetween 1 and 7 only 1 to 7, 10 to 15, 20 and 30 and above I need to parse those strings into actual ranges. That is I need to create ...

Is there a C header parser tool for wrapper generation like gccxml?

I need to write a few c header wrappers for a new programming language and would like something like gccxml but without the full dependency on gcc and the problems it gives on a windows system. Just needs to read C not C++. Output in any format is okay as long it is fully documented. Need it for Curl, SQLite, GTK2, SDL, OpenGL, Win32 A...

Time stamp parsing from the beginning of a string in C#

Hi all, I am working on re-writing an existing Java software solution in .NET. At one point, the Java solution reads a time stamp at the beginning of a string, simply like this: SimpleDateFormat dateFormat = new SimpleDateFormat(timeFormat); dateFormat.setLenient(false); try { timeStamp = dateFormat.parse(line); } catch (ParseExce...

Java: cannot parse and display non-utf8 characters read from an http request

Hello, I'm using Java to parse this request http://ajax.googleapis.com/ajax/services/search/web?start=0&amp;rsz=large&amp;v=1.0&amp;q=rz+img+news+recordid+border which has as a result this (truncated for the sake of brevity) JSON file: {"responseData":{"results": <...> "visibleUrl":"www.coolcook.net", "cacheUrl":"http://www.google....

parse log file - using java and plot graph

I am writing a log analyzer program which is supposed to plot a graph on search string against time after parsing log file(s). I am currently clueless about how would I parse and store the log file so that it could be processed to create multiple outputs, now I am parsing the entire log file all the time and process to do this – any sugg...

LUA 'plain' string.gsub

Hi, I've hit s small block with string parsing. I have a string like: footage/down/temp/cars_[100]upper/cars[100]_upper.exr and I'm having difficulty using gsub to delete a portion of the string. Normally I would do this lineA = footage/down/temp/cars_[100]_upper/cars_[100]_upper.exr lineB = footage/down/temp/cars_[100]_upper/ ne...

What's the most Pythonic XHTML/HTML parser/generator/template module that supports DOM like access?

It should be able to create, modify and read X/HTML in a highly object oriented way that still feels DOM like but is not obese, and is really Pythonic. Preferably it would deal with malformed HTML too, but we can skip this for templates. For example, I'd like to do this: >> from someAmazingTemplate import * >> html = Template('<html><h...

parse quoted string into tokens in javascript

I need to parse expression like 'a' 'b' 'cd ef' three tokens how can this be done in javascript?par ...

How to turn this into a parser

If I just add on to the following yacc file, will it turn into a parser? /* C-Minus BNF Grammar */ %token ELSE %token IF %token INT %token RETURN %token VOID %token WHILE %token ID %token NUM %token LTE %token GTE %token EQUAL %token NOTEQUAL %% program : declaration_list ; declaration_list : declaration_list declaration | declarat...

How to pass a .plist file with php?

Can i pass a plist file with php and kind of get it into an array, like the $_POST[''] so i could call $_POST['body'] and get the string that has the <key> body ? ...

Stop and continue while evaluation an expression tree

At the office, we've applied simple Domain Specific Languages (DSLs) to several problem domains we encountered. Basically, we parse (lex/yacc) the custom script into an expression tree. Every node in the expression tree has an .evaluate() method that gets called recursively, until the program is done. Nice, and simple as pie. Which is ...

Problem parsing XML output (PHP/JQuery)

I scratch my head in frustration, but I can't find the answer. I'm new to Ajax and I'm trying this easy script: Here's my code: JAVASCRIPT: $(document).ready(function(){ $("#toggle_album").click(function () { $.post('backend/load_album_thumbnails.php', { text: 'my string', number: 23 }, function(xml...