parsing

Parsing JSON DateTime from Newtonsoft's JSON Serializer

I've serialized an object using Newtonsoft's JSON serializer, and the DateTime has come through as: /Date(1237588418563+0000)/ When I $.evalJSON() on that, it is an object but I can't find any normal Date methods like toUTCString on it. Any ideas what I can do with this? ...

Regexp for matching numbers and units in an HTML fragment?

I'm trying to make a regexp that will match numbers, excluding numbers that are part of other words or numbers inside certain html tags. The part for matching numbers works well but I can't figure out how to find the numbers inside the html. Current code: //number regexp part var prefix = '\\b()';//for future use var baseNumber = '((\\...

Reading and parsing integers from a text file

I'm trying to get a line of integers from a text file and parse them into separate variables. The text file is set up like this: ID:HP:MP:STR:WIS:SPD:GOLD:XP 0:100:50:10:5:12:5:10 I want to split them with the : symbol in between each. One of the problems I'm having with this is being able to read the file line by line as strings, par...

Storing results into a record trouble

Hi I am parsing an XML file and storing the results in a record, but am having some trouble. Im trying to store the results (content of my XML tags) into the fields of my record.. My record (at the moment there is only 1 set of XML elements). I think that the Parser.curconten is causing the problem... Type TXMLAlert=Record alert...

Getting the value of href attributes in all <a> tags on a html file with Python

I'm building an app in python, and I need to get the URL of all links in one webpage. I already have a function that uses urllib to download the html file from the web, and transform it to a list of strings with readlines(). Currently I have this code that uses regex (I'm not very good at it) to search for links in every line: for line...

How can I parse code to build a compiler in Java?

Hey, I need to write a compiler. It's homework at the univ. The teacher told us that we can use any API we want to do the parsing of the code, as long as it is a good one. That way we can focus more on the JVM we will generate. So yes, I'll write a compiler in Java to generate Java. Do you know any good API for this? Should I use reg...

What is the best tool for creating a Java extension?

Our project group is working on a Java language extension and we have been trying to figure out what tool we should use for this purpose. The extension will primarily consist of a modification of the concurrency model used in Java. We have been looking at two tools so far: Polyglot and Javacc. Javacc seems to be a bit more easy to use, b...

How to extract the attachments from an IMAP message?

Hi, how do I extract all attachments from an IMAP message? I use Objective-C and Cocoa, but are happy for generic tutorials, code or hints, too. Regards ...

How do I make my own parser for java/jsf code?

Hi I'd like to make my own 'parser', e.g: computing (4+(3-4^2))*2 or parsing java,jsf,html code. In fact I did something like this but I feel it's not good. Is there anything good for me? I've tried to read more, but I'm bit confused, LL, LR, AST,BNF,javacc yacc etc :). I'm not sure which way to go, when I would like to compute 4+... ...

How to parse a remote website and create a link on every single word for a dictionary tooltip?

I want to parse a random website, modify the content so that every word is a link (for a dictionary tooltip) and then display the website in an iframe. I'm not looking for a complete solution, but for a hint or a possible strategy. The linking is my problem, parsing the website and displaying it in an iframe is quite simple. So basicall...

C++ Parser/Model for Java

I was wondering if anyone knows of existing C++ parsers/code models that can be used programmatically in Java. I'm looking for something similar to the Eclipse CDT that can be used as a library from Java (and that does not rely upon Eclipse). Thanks in advance. ...

how to tokenize/parse string literals from javascript source code

I am working on a program in C# that needs to load some javascript code, parse it and do some processing to the string literals found in the code (such as overwrite them with something else). My problem is that I'm having a difficult time devising an elegant way to actually find the string literals in the javascript code in the first pl...

Can ANTLR generate a parser class that is final?

I'm using ANTLR 3.1 and ANTLRWorks to generate a parser class in Java. The parser performs better if I mark the generated class with the Java final keyword. The problem is: I am adding this keyword manually after each time I re-generated the code from the ANTLR grammar. Is there anyway, in the grammar, of telling ANTLR to add the final k...

Building Elsa on windows

How would I build elsa under windows? http://www.eecs.berkeley.edu/~smcpeak/elkhound/sources/elsa/ A visual studio would be preferable or something I can link with using visual studio, ...

Building Predictive Parser and parsing table

Hello, I'm trying to build a parser for the following grammar (dragon book ex. 4.4.1 pg. 231) S->0S1|01 So first I left factored the grammar (eliminate ambiguity for deciding which rule to choose) and the result: S->0S' S'->0S|1 And constructing the parsing table yielded (apologies for the formatting the table html markup was removed...

Pascal - Re: Uses

I have the following program which very nearly works but is producing the following error when I try and compile, I have no idea how to fix it! any ideas? Forms, mainform in 'mainform.pas'... "unit1.pas(9): , or ; expected but 'IN' found; "project1 could not compile unit1.pas unit Unit1; interface uses Windows, Messages, SysUt...

Convert complex bool condition from string to bool in .NET

I need to parse complex expresion from string to bool. It can only contain: * boolean values (true/false), * parenthesis, * AND/OR operands (&&, ||) Eg: bool.Parse("((true || false) && (false || false)) || (true || false)" Any idea how to achieve this? ...

How to parse an ISO formatted date in Flex (AS3)?

How can I parse an ISO date string into a date object in Flex (AS3)? e.g. 2009-12-08T04:23:23Z 2009-12-08T04:23:23.342-04:00 etc... ...

MGrammar grammar and variable declaration

I'm sure I'll get told to do it another way, but for specific reasons it has to be done this way. If it didn't, I wouldn't be stuck :-P The scripting language I'm working on has to accept variables defined like this: Variables: x(1), y("hi"); This is a requirement. I wrote a small grammar before that would let me define them like t...

C#: HtmlDocument object has no constructor?

What's up with that? It seems the only way to get an working HtmlDocument object is copying the Document property of an mshtml/webbrowser control. But spawning that is sloooooooooooow. I'd like to avoid writing my own HTML parser and HtmlAgilityPack is copyleft. Are there other sources of getting an instantiated HtmlDocument that I can ...