parsing

How can I catch everything after the underscore in a filepath with JavaScript?

How can I catch everything after the last underscore in a filename? ex: 24235235adasd_4.jpg into 4.jpg Thanks again! ...

Problem filtering an Array into multiple Tableviews (based on SeismicXML)

I've taken the Seismc XMl example and adjusted it to my needs, I've added a tab bar controller with multiple tabs each with a TableView, so far so good, I now want to filter the main TableView, so that different info appears in each of the TableViews based on category. I've created a class for each filter "type" in the app delegate, and...

Parsing with DCGs in Scheme (without Prolog)?

Lots of Prolog-in-Scheme implementations are out there. E.g. Kanren, Schelog. Apparently in "Paradigms of AI Programming" Norvig implements Prolog-to-Lisp compiler in Lisp in order to use Definite Clause Grammars. But is there a simpler cleaner way? Maybe some clever use of amb to avoid implementing a full "Prolog"? What is the easiest...

Parsing Peculiar Newlines

I'm sure this is something very simple that I'm screwing up, but here goes: I'm trying to parse a log file that is generally formatted in UNICODE (and I'll freely admit that I don't generally know much about UNICODE, but the first two bytes of the file are 0xFFFE, and there's a zero between every other character). The peculiar part i...

parsing recursive structures in scala

I'm trying to contruct a parser in scala which can parse simple SQL-like strings. I've got the basics working and can parse something like: select id from users where name = "peter" and age = 30 order by lastname But now I wondered how to parse nested and classes, i.e. select name from users where name = "peter" and (age = 29 or age ...

Question about building a symbol table with a yacc parser

If my yacc parser encounters the following code: int foo(int a, int b) should it add int a and int b as attributes of foo? The way I have it now, it enters a and b as separate table entries. ...

Convert fraction to float?

Kind of like this question, but in reverse. Given a string like 1, 1/2, or 1 2/3, what's the best way to convert it into a float? I'm thinking about using regexes on a case-by-case basis, but perhaps someone knows of a better way, or a pre-existing solution. I was hoping I could just use eval, but I think the 3rd case prevents that. ...

Parse error: syntax error, unexpected $end in E:\xampp\htdocs\announcements\announcement.php on line 143

I get this error message Parse error: syntax error, unexpected $end in E:\xampp\htdocs\announcements\announcement.php on line 143 Line 143 is the last line of the PHP file. When I comment out $htmlcode=<<<eod <div>$question</div> <div>$option1 $option2 $option3 $option4</div><br/> eod; echo $htmlcode; The error is...

Nearest thing to PyParsing in PHP

I'm looking for a PHP library that provides similar functionality to PyParsing, a simple but powerful parsing engine for Python. Does anyone have a suggestion? I want create a wiki-syntax parsing and a search expression parsing without re-inventing the wheel... Thanks ...

Parsing to RPN two equations give same notation but have different answers

I've wrote a parser in PHP that converts a string representation of an equation to RPN based on feedback from an earlier question. Whilst testing it I found two different equations that parse to the same thing in RPN. Because they end up as the same thing in RPN when you solve them you get the same answer. 3 + 4 * 8 / (1 -5) 3 + 4 * 8 ...

Recursive Descent Parser for C

I'm looking for a parser for C. Here is what I need: Written in C (not C++). Handwritten (not generated). BSD or similarly permissive license. Capable of nontrivially parsing itself (can be a subset of C). It can be part of a project as long as it's decoupled so that I can pull out the parser. Is there an existing parser that fulfi...

Parsing X-amf mime type data

I have intercepted x-amf data being posted to a website from my computer by a flash application. I have the collected POST data in hex form. While some of it has translated directly to text, the rest is showing wierd symbols which probably means they're flash objects. How do I parse this data to get meaningful output outta it? Basically...

Resolving a shift/reduce conflict in an LALR parser

I've been using PLY to build up a parser for my language, however I've got a shift/reduce conflict that's causing me some trouble. My language has generic types with a syntax ala C++ templates. So right now I have rules like: expression : expression LESS expression %prec COMPARISON expression : template template : NAME ...

Am I incorrectly using atoi?

I was having some trouble with my parsing function so I put some cout statements to tell me the value of certain variables during runtime, and I believe that atoi is incorrectly converting characters. heres a short snippet of my code thats acting strangely: c = data_file.get(); if (data_index == 50) cout << "50 digit 0 = '" << c <<...

Is there a library for reading /var/spool/mail/ files?

How does one parse the mail files generated on a Linux system using Java? I mean, I want to be able to extract the From, To, Timestamp and Subject of the various emails inside the file. Any suggestions? ...

XML parsing and usage

Hi, I'm building a conforming and validating XML parser in C++ and trying to make it light-weight for use in pocket pc. At the beginning I decided to add some "events" to my parser like SAX does, informing about elements, processing instructions, etc. This events are taken by a derived class that builds the DOM tree of the xml. My do...

When is it wise to use regular expressions with HTML?

While it's absolutely true that regexp are not the right tool to fully parse HTML documents, I am seeing a lot of people blindly disregarding any question about regexp if they as much as see a single HTML tag in the proposed text. Since we see a lot of examples of regexp not being the right tool, I ask your opinion on this: what are th...

Escaping characters in large XML files

I have large XML files of 100s of MB. Are there any utilities that can parse XML files and escape special charaters in strings without opening the entire file into memory at once? Thanks ...

Shift Reduce Conflict

import java_cup.runtime.*; import java.io.*; import java.util.*; /* Preliminaries to set up and use the scanner. */ parser code {: SMPLLexer lexer; public SMPLParser (SMPLLexer lex) { super(lex); lexer = lex; } public void report_error(String message, Object info) { System.err.println(messag...

HTML scraper to remove and modify html pages?

I need a HTML scraper or a DOM editor. I know the question has been asked many times, and the answer is HTML agility pack. But it doesn't look any good to me. I tried to removed a simple form element, but it removed only the <form> tag and leaved all other tags inside it, also it leaved the </form> tag. I used the PHP Simple HTML DOM Par...