Parsing binary sums / products are easy, but I'm having troubles defining a grammar that parses
a + b * c + d + e
as
sum(a, prod(b, c), d, e)
My initial (naive) attempt generated 61 shift / reduce conflicts.
I'm using java cup (but I suppose a solution for any other parser generator would be easily translated).
...
In all of the standard specifications for programming languages, why is it that you cannot directly translate the lexical analysis/layout to a grammar that is ready to be plugged into and working?
I can understand that it would be impossible to adapt it for the likes of Flex/Bison, Lex/Yacc, Antlr and so on, and furthermore to make it ...
Good morning -
I'm interested in seeing an efficient way of parsing the values of an heirarchical text file (i.e., one that has a Title => Multiple Headings => Multiple Subheadings => Multiple Keys => Multiple Values) into a simple XML document. For the sake of simplicity, the answer would be written using:
Regex (preferrably in PHP)...
Hello,
I am writing an application that allows a user to enter a boolean expression. I need the ability to evaluate the entered boolean expression at runtime and am looking for both a parser and a expressoin validator.
Parser
The parser needs to take a boolean expression as a string and return true/false.
Example:
string expression...
I need to count the number of images (in this case 1 image). Apparently using "len()"?
Here is HTML:
<div class="detail-headline">
Fotogaléria
</div>
<div class="detail-indent">
<table id="ctl00_ctl00_ctl00_containerHolder_mainContentHolder_innnerContentHolder_ZakazkaControl_ZakazkaObrazky1_ObrazkyDataList" cellspa...
I have the following line in a CSV file that's giving me issues when parsing:
312,'997639',' 2','John, Doe. "J.D." ',' ','2000 ',' ','Street ','City ','NY','99999','','2010-02-17 19:12:04','2010-02-17 19:12:04';
I'm parsing with the following par...
How can i retrieve categoryname from given xml file using php
<categories>
<category categoryid="1100" categoryname="Baby Clothing" categorylevel="1">
<category categoryid="1101" categoryname="Dresses" categorylevel="2">
</category>
<category categoryid="1102" categoryname="Trousers & Jeans" categorylevel="2">
</category>
<categor...
While reading a date column from a .csv file which is of 'dd/mm/yyyy hh:mi:ss am' format through javacode. I declared the variable as Long in javacode. how to parse in the javacode.
...
I am looking for a java library/class to parse clean URL's and get all the properties like query, port, host , domain, subdomain etc. Essentially most of the functionality that java.net.URI does but even for clean URLs. I am guessing since this is a pretty common requirement, there might be some libraries already built to handle this. He...
I have a chunk of text like:
<b>First content</b> followed by <b>second content</b>
OR
"First content" and then "second content"
And I want to create an array that looks:
[1] => "First content"
[2] => "second content"
From either example, where I get the content between two tags. I've figured out how to get the first instances, bu...
does anyone know if there's a class out there that parses courier mailboxes (ie: courier imap mail server)? returning lists, and parsing individual messages?
this is not a protocol issue, i'm not interested in connecting to a remote mail-server. rather, i'm interested in manipulating the local mail-server via filesystem.
In particular,...
Hi all. I am building a template parser.
The template parser works like this:
Tokenize (make for each part of the template code a token)
Parse
Use my ParserHelper class. You can add rules for this system, and then it checks the token list for a valid grammar.
Add / change some tokens for extra functionality
Compile (translate to php ...
I'm playing with Python imaplib (Python 2.6) to fetch emails from GMail. Everything I fetch an email with method http://docs.python.org/library/imaplib.html#imaplib.IMAP4.fetch I get whole email. I need only text part and also parse names of attachments, without downloading them. How this can be done? I see that emails returned by GMail ...
Hi All, From here, I am trying to get data from stock quote for every 10 mins interval.
I used WebClient for downloading the page content and for parsing I used regular expressions. It is working fine for other urls. For the Particular URL, my parsing code not working.
I think it is the problem with javascript, When I load the page in...
I have this code/function method as part of a class in php:
function defaulthome(){
$fp = null;
$err ='';
$xml_parser = xml_parser_create();
$rss_parser = new Rssparser();
xml_set_object($xml_parser,&$rss_parser);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_c...
I need to read UML diagrams that are serialized into XMI. Is there any library that would allow me to conveniently read UML XMI - by conveniently I mean having some methods to iterate over classes/packages/methods/attributest etc. in model.
I tried EMF, but I am unable to find any tutorial that would show how to import XMI containing UM...
I'm trying to read files and create a hashmap of the contents, but I'm having trouble at the parsing step. An example of the text file is
put 3
returns 3
between
3
pargraphs 1
4
3
#foo 18
****** 2
The word becomes the key and the number is the value. Notice that the spacing is fairly erratic. The word isn't always a word (which does...
I have a page that looks like this:
Company A<br />
123 Main St.<br />
Suite 101<br />
Someplace, NY 1234<br />
<br />
<br />
<br />
Company B<br />
456 Main St.<br />
Someplace, NY 1234<br />
<br />
<br />
<br />
Sometimes there are two rather than three "br" tags separating the entries. How would I use BeautifulSoup to parse throug...
I'm looking to find a specific attribute of a specific tag in an HTML document using PHP DOMDocument.
Specifically, there is a div with a unique class set, and only a single span inside of it. I need to retrieve the style attribute of that span tag.
Example:
<div class="uniqueClass"><span style="text-align: center;" /></div>
For th...
How would I parse for the word "hi" in the sentence "hi, how are you?"
or in parse for the word "how" in "how are you?"?
example of what I want in code:
String word = "hi";
String word2 = "how";
Scanner scan = new Scanner(System.in).useDelimiter("\n");
String s = scan.nextLine();
if(s.equals(word)) {
System.out.println("Hey");
}
if(s....