parsing

What grammar based parser-generator tools exist for ruby?

What open source (preferably gem-based) parser-generator options do I have in Ruby? I've used (flex&bison)|(lex&yacc) from C in the past, and I'm comfortable with BNF-style specifications. I've heard of treetop, but it looks a bit alien and verbose compared to yacc... Purpose: I want to convert my text markup language to a BNF and ge...

parsing file ruby

I have a file with data like this: 01 JUL something something something 445 something else 01 JUL whatever everwa3 lklkj 445 something else 02 JUL ljkjlkj ljkljlkj lkjkjlk 500 lkjkj 02 JUL ljlkjklj lkjkjlkj lkjkj ...

CSSOMParser in gwt client side

What i would like to do is to read an css file from a GET request on the client side, and then i would like to parse it to check all the classes. The problem is that I need to implement CSSOMParser for that, and here are the imports import org.w3c.dom.css.CSSRule; import org.w3c.dom.css.CSSRuleList; import org.w3c.dom.css.CSSStyleR...

PDF parsing file trailer

It is not clear from the PDF ISO standard document (PDF32000-2008) whether a comment may follow the startxref keyword: startxref Byte_offset_of_last_cross-reference_section %%EOF The standard does seem to imply that comments may appear anywhere: 7.2.3 Comments Any occurrence of the PERCENT SIGN (25h) outside a string or stre...

PHP Fomatting Regex - BBCode

To be honest, I suck at regex so much, I would use RegexBuddy, but I'm working on my Mac and sometimes it doesn't help much (for me). Well, for what I need to do is a function in php function replaceTags($n) { $n = str_replace("[[", "<b>", $n); $n = str_replace("]]", "</b>", $n); } Although this is a bad example in case someo...

string parsing help

I've got a string like this: #################### Section One #################### Data A Data B #################### Section Two #################### Data C Data D etc. I want to parse it into something like: $arr( 'Section One' => array('Data A', 'Data B'), 'Section Two' => array('Data C', 'Data D') ) At first I tri...

Nokogiri Not Parsing File

Edit: I figured out the answer. The problem was namespaces. The following code got it to work: @doc.xpath("xmlns:msms_pipeline_analysis/@date").to_s. I'd put this down as the answer, but this question has been closed. I'm using Nokogiri to parse pepXML files from different peptide search engines. I have two pepXML files, both of which a...

Excel layout for hierarchical data

I am working on an excel bulk upload feature which has to be parsed using Java API. My problem is designing its layout. The data is hierarchical with 4 levels and one to many relationship at each level. 1-other data for node 1 -2-other data for node 2 -3-other data for node 3 -4-other data for node 4 And this repeats e.g. -...

vb.net and html parsing

Currently I'm using the IHTMLDocument2 and IHTMLElementCollection to parse HTML, is there some way to parse it using some sort of xpath/selectors, something like elements = find_html_elements("a .link[rel=100]") ? ...

PHP: calling a child tag simplexml

Trying to parse a YouTube feed using PHP simplexml_load_file(); I am able to access other tags pretty simply using $xml->id; When I try to access <openSearch:totalResults> with $xml->openSearch->totalResults; I don't get any results ...

A MySQL schema parser in Java?

Hi all, Does anyone know whether there is a java library for parsing a MySQL schema? In code I want to be able to determine the tables and fields specified in a schema. Or will I need to write my own? Thanks Richard. Edit: Just want to avoid re-inventing the wheel unnecessarily :) ...

parser error in aspx page(.net 2.0) after converting from website to web application

I have a website I recently converted from website to web application Project . When I compile It compiles Successfuly but when I run the code I get this error Parser Error Message: Could not load type 'DApplause.Logon'. Source Error: Line 1: <%@ Page Language="vb" AutoEventWireup="true" CodeBehind ="Logon.aspx.vb" inherits="DApp...

Android: SaxParser problems using ISO-8859-1 encoding

Hi all! Im facing some problems on xml parsing with android. The problem is that the xml from the server comes in "ISO-8859-1" set with setEncoding (i get <?xml version="1.0" encoding="ISO-8859-1"?>) format and the android device seems that its ignoring that encoding. For example this is part of the original xml that comes from the serv...

PHP making input from web form case insensitive?

So I have some code here that takes user input from a standard web form: if (get_magic_quotes_gpc()) { $searchsport = stripslashes($_POST['sport']); $sportarray = array( "Football" => "Fb01", "Cricket" => "ck32", "Tennis" => "Tn43", ); if(isset($sportarray[$searchsport])){ header("Location: ".$sportarray[$searchsport].".html"); die; } ...

Parser problem - Else-If and a Function Declaration

A quick, fun question - What is the difference between a function declaration in C/C++ and an else-if statement block from a purely parsing standpoint? void function_name(arguments) { [statement-block] } else if(arguments) { [statement-block] } Looking for the best solution! =) Edit: Thanks for the insight guys. I was actually ...

XML parsing to plist iPhone SDK

Hi, guys. Could you, please, help me with parsing of this XML code: <?xml version="1.0" encoding="utf-8"?> <stuff> <parts> <part id='327'> <name>Logitech MX500</name> <serial>618163558491989</serial> <account>ASDALSKD</account> <number>987 789 456</number> <alarm>alarm...

Parsing some particular statements with antlr3 in C target

Hello all! I have some questions about antlr3 with tree grammar in C target. I have almost done my interpretor (functions, variables, boolean and math expressions ok) and i have kept the most difficult statements for the end (like if, switch, etc.) 1) I would like interpreting a simple loop statement: repeat: ^(REPEAT DIGIT stmt); ...

How can I parse a string into a hash using keywords in Perl?

I have a string where different predefined keywords introduce different data. Is there a way to do that using clever use of regexp, or something? Here is an example: Keywords can be "first name: " and "last name: ". Now I want to parse: "character first name: Han last name: Solo" into { "first name: " => "Han ", "last name: " => "So...

Bash script: regexp reading numerical parameters from text file

Greetings! I have a text file with parameter set as follows: NameOfParameter Value1 Value2 Value3 ... ... I want to find needed parameter by its NameOfParameter using regexp pattern and return a selected Value to my Bash script. I tried to do this with grep, but it returns a whole line instead of Value. Could you help me to find ...

Are there any libraries for parsing "number expressions" like 1,2-9,33- in Java

Hi, I don't think it is hard, just tedious to write: Some small free (as in beer) library where I can put in a String like 1,2-9,33- and it can tell me whether a given number matches that expression. Just like most programs have in their print range dialogs. Special functions for matching odd or even numbers only, or matching every numb...