parsing

What is the decimal separator symbol in JavaScript?

A thought struck me as I was writing a piece of JavaScript code that processed some floating point values. What is the decimal point symbol in JavaScript? Is it always .? Or is it culture-specific? And what about .toFixed() and .parseFloat()? If I'm processing a user input, it's likely to include the local culture-specific decimal separ...

populating data from xml file to a sqlite database using python

Hi all, I have a question related to some guidances to solve a problem. I have with me an xml file, I have to populate it into a database system (whatever, it might be sqlite, mysql) using scripting language: Python. Does anyone have any idea on how to proceed? Which technologies I need to read further? Which environments I have to i...

Unable to parse Java MIME mail message

I'm creating java MIMEMessage object from input stream. It is getting constructed properly without any problem. I'm also able to fetch body and attachments. But the problem is, when I receive some emails with some different formating, like from iPhone or from Blackberry, my parsing fails. I'm parsing Java MIMEMessage by myself. Here I...

parseRequest returning no items

i'm using the commons.fileupload .. when i try to parse the request i get no items from it which later leads to a null pointer exception... as far as i understand, this happens because "Why is parseRequest() returning no items? This most commonly happens when the request has already been parsed, or processed in some other way. Since th...

XML Library for C/C++

Hey I'm looking for an XML parser for C/C++, just a parser which I give a string as an argument and it returns me a parsed document represented by a class/struct. The problem is that I am compiling it for the ARM9 processor and I need really just simple code no ./configure and stuff like that and no specific Makefile, just some files wh...

lexers / parsers for (un) structured text documents

There are lots of parsers and lexers for scripts (i.e. structured computer languages). But I'm looking for one which can break a (almost) non-structured text document into larger sections e.g. chapters, paragraphs, etc. It's relatively easy for a person to identify them: where the Table of Contents, acknowledgements, or where the main...

Why am I getting unexpected results from chained calls to map?

I'm using Getopt::Lucid to process CLO and I've run into an interesting and unexpected problem. The following code: push @clo_spec, map { Switch($_) } qw(-c -m -s -p), map { Switch($_) } qw(--help --man --usage --version), map { Switch($_) } qw(--debug --verbose), map { Param($_) } keys ...

How can I tell Bison I also expect reduce-reduce conflicts?

My C#-ish toy grammar now has its first reduce-reduce conflicts! I'm so proud of me. It seems all right to me, however (I switched off to a GLR parser for the occasion). The problem is, while I know the %expect directive can shut up Bison about shift/reduce conflicts, I can't find the equivalent for reduce/reduce conflicts. So what shou...

A good C alternative for Boost.Program_options?

Any good alternative written in C to replace Boost.Program_options? Given it's able to parse: Short options like -h Long options like --help --input-file Parse repeated keys/options Accepts key-value pairs: --mysql=/usr/lib Parsing environmental variables and XML/INI files is optional. ...

Parse query string in JavaScript

I need to parse the query string www.mysite.com/default.aspx?dest=aboutus.aspx. How do I get the dest variable in JavaScript? ...

Opening remote documents in Python

from xml.dom.minidom import parse, parseString datasource = open('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml') dom = parse(datasource) print dom ... the above code throws an IOError: 2, 'No such file or directory'. Python doesn't read remote doc like PHP? What do I need to change in the code to make it read the XML ...

ASF+SDF environment : GLR Parser

Is it possible to write code in order to store intermediate values in user specified data structures in the ASF+SDF environment GLR Parser I would like compile the input source code in stages and have the output of each stage stored in a temporary dump file...like GCC does. Is this possible? ...

What is the algorithm for parsing expressions in infix notation?

I would like to parse boolean expressions in PHP. As in: A and B or C and (D or F or not G) The terms can be considered simple identifiers. They will have a little structure, but the parser doesn't need to worry about that. It should just recognize the keywords and or not ( ). Everything else is a term. I remember we wrote simple ari...

Ruby String Integer Scanning

Is there a Ruby equivalent of the Java Scanner? If I have a string like "hello 123 hi 234" In Java I could do Scanner sc = new Scanner("hello 123 hi 234"); String a = sc.nextString(); int b = sc.nextInt(); String c = sc.nextString(); int d = sc.nextInt(); How would you do this in Ruby? ...

Parsing name and address information with differing number of spaces

I have a comma delimited text file. The 5th field on each line contains the name and address information. The name is separated from the street information by a '¬' character. The same character also separates the city|state|zip. A sample field would be: "¬BOL¬MICKEY M MOUSE¬123 TOMORROW LANE¬ORLANDO FL 12345-6789¬¬¬¬EOL¬" I need to sep...

Nested JSON objects - do I have to use arrays for everything?

Is there any way to have nested objects in JSON so I don't have to make arrays out of everything? For my object to be parsed without error I seem to need a structure like this: {"data":[{"stuff":[ {"onetype":[ {"id":1,"name":"John Doe"}, {"id":2,"name":"Don Joeh"} ]}, {"othertype":[ {"id":2,"company":...

Is there something similar to WebClient.DownloadString in Java?

I want to download the html source code of a site to parse some info. How do I accomplish this in Java? ...

sort csv by column

Hi! I want to sort a CSV table by date. Started out being a simple task: import sys import csv reader = csv.reader(open("files.csv"), delimiter=";") for id, path, title, date, author, platform, type, port in reader: print date I used Python's CSV module to read in a file with that structure: id;file;description;date;author;pla...

How can I ignore some elements in <p> with Perl's HTML::TreeBuilder?

I have to parse this HTML: <p> <strong>abc:</strong> asfkjsdg </p> $para contains the value of the element <p>. I am using HTML::TreeBuilder. $para->as_text gives me abc:asfkjsdg How can I get only: asfkjsdg ...

Regex that matches Camel and Pascal Case

I'm about to write a parser for a language that's supposed to have strict syntactic rules about naming of types, variables and such. For example all classes must be PascalCase, and all variables/parameter names and other identifiers must be camelCase. For example HTMLParser is not allowed and must be named HtmlParser. Any ideas for a r...