parsing

Parsing a datafile in python (2.5.2)

I have a message definition file that looks like this struct1 { field="name" type="string" ignore="false"; field="id" type="int" enums=" 0="val1" 1="val2" "; } struct2 { field = "object" type="struct1"; ... } How can I parse this into a dictionary with keys 'struct1, struct2' and values should be a list of dictionaries, eac...

Is there anything like PPI or Perl::Critic for C?

PPI and Perl::Critic allow programmers to detect certain things in the syntax of their Perl programs. Is there anything like it that will tokenize/parse C and give you a chance to write a script to do something with that information? ...

Prefixing MySQL Tables or Many MySQL databases?

So, first things first, I'm a student. I'm developing an application where other students can have access to a MySQL database. Basically, I wanted to spare the students the need to search for hosting or even installing MySQL on their computers. Another plus is the fact that they can present their works to the class just by browsing a web...

Should I use a parser/lexer for this?

I'd like to know if a tool like ANTLR would be appropiate for parsing these rules or it's overkill and I should make my own parser. This is for parsing someone else's format, so I can't change it. It's for fun and to practice, so don't fret too much. These are rules to describe phonetic changes in languages. I'll quote the original auth...

Can I parse relative times with JodaTime?

I'd love to be able to parse relative strings like now and yesterday and get JodaTime DateTimes. Is it possible? DateTimeFormat.forPattern and doesn't seem to support English relative times and I don't know of any other parsing options in JodaTime. I should add that I'm using scala-time but can easily drop down to the actual JodaTime cl...

Capture multiple lines using Regular Expression (.Net)

I am trying to write a regular expression that can parse the text between < p >< /p > tags. There will be up to 3 lines of text in a row. I thought this might be possible using the (?= search ahead feature. The code that I am currently using to get one line is as follows. <p>([^']*?)<[/]p Is it possible to have one regular expressi...

How do I parse a string representing a nested list into an actual list?

Say I have a string representing some nested lists and I want to convert it into the real thing. I could do this, I think: exec "myList = ['foo', ['cat', ['ant', 'bee'], 'dog'], 'bar', 'baz']" But in an environment where users might be supplying the string to execute this could/would be a bad idea. Does anybody have any ideas for a ti...

Parsing text file (100+ MB) and sending data over network

I have a requirement to parse a huge text file and send parts of this file to be added as seperate rows in Content Manager. what is the best way of parsing and then update the DB? I also would need identify certain tokens within this text file. Please suggest what language should I use to code this requirement. Thanks ...

How to get surrounding method in Java source file for a given line number

I have a line number of a Java source file and want to get the sourounding method for that line number programatically. I looked into ANTLR which didn't help me much. Janino (http://www.janino.net) seems promising, I would scan and parse (and if necessary compile) the code. Then I could use JDI and ReferenceType.locationsOfLine(int li...

Parsing a Custom Search Criteria Grammar in C#

In a C# app, I would like users to be able to enter search criteria in this kind of format: (Name = 'Fred' OR Name = 'Jim') AND Age > 30 What I need is some way to parse the input so I can test potential search matches against the criteria. I did experiment with Malcolm Crowe's compiler tools for .NET years ago, but I'm wondering if t...

Parsing XML via jQuery, nested loops

I am using jQuery to parse XML on my page using $.ajax(). My code block is below and I can get this working to display say each result on the XML file, but I am having trouble because each section can have MORE THAN ONE and im trying to print ALL grades that belong to ONE STUDENT. Here is an example of the XML. <student num="505"> ...

Return type of "|" in Scala's parser combinators

I was reading Bernie Pope's slides on "Parser combinators in Scala". He quotes the method signature type of the "alternative" combinator |: def | [U >: T](q: => Parser[U]): Parser[U] and asks, "Homework: why doesn’t | have this type instead?" def | [U](q: => Parser[U]): Parser[Either[T,U]] ...

Give me an example of Unicode XML parsing using PugiXML

I have tried to find some code for this job in the tutorials and by googling, no luck. If someone has used PugiXml, could you please help me out ? My main trouble is Unicode, otherwise the library is very easy to use. Thanks in advance. ...

Parsing a custom string-generating-pattern syntax

Background: I'm developing a custom regex-like syntax for URL filenames. It will work like this: User writes a pattern, something like "[a-z][0-9]{0,2}", and passes it as input It is parsed by the program and translated into the set of permutations it represents i.e. 'a', 'a0', 'a00' ... 'z99' These patterns will vary in complexity, ...

BEGINNER: extracting subsets of data

Hello, this seems to be an easy task really, but being completely new to the world of programming, I have problems with the following task: I have a huge file which has the following format: track type= wiggle name09 variableStep chrom=chr1 34 5 36 7 54 8 variableStep chrom=chr2 33 4 35 2 78 7 this is text with the word random in...

How to map XML schemas to C/C++ code?

What the best way to map XML schemas to C/C++? Here is an example: ------ C/C++ ----- struct zone { char *var_name; float var_value; }; ------ XML ----- <xs:element name="zone"> <xs:complexType> <xs:sequence> <xs:element name="Var_name" type="xs:string"/> <xs:element name=...

Basics of Haskell compiling

I'm working on the 2nd Euler's problem, but for now I'm just trying to define the Fibonacci sequence. Currently, I have my Fib function defined as Fib 0 = 0 Fib 1 = 1 Fib x = Fib (x - 1) + Fib (x - 2) Because I want the program to depend on my keyboard input, I used main = do putStrLn "Enter desired Fibonacci index: " ...

WordPress plugin tag not parsing in <script> block

I'm using the following code in one of my WordPress plugin files: else if($filetype == 'swf'){ print <<<EOT <script type="text/javascript" language="javascript"> jQuery(document).ready(function(){ var embed = '<div>[kml_flashembed movie="$img" /]</div>'; jQuery("#header").prepend(jQuery(embed)); }); </script> <style type="text/css"> #$h...

How do I parse partial HTML?

I'm trying to parse some HTML with DOM in PHP, but I'm having some problems. First, in case this change the solution, the HTML that I have is not a full page, rather, it's only part of it. <!-- This is the HTML that I have --><a href='/games/'> <div id='game'> <img src='http://images.example.com/games.gif' width='300' height='137' borde...

python - urrlib2 request https site - getting 400 error

Hi... using the following snip of code to access a url with a post. i can get it using wget and the following: wget --post-data 'p_calling_proc=bwckschd.p_disp_dyn_sched&p_term=201010' https://spectrumssb2.memphis.edu/pls/PROD/bwckgens.p%5Fproc%5Fterm%5Fdate for some reason, i'm having an issue with my python text, in that i get a er...