Parsing refers to the action by software of breaking an artifact into its constituent elements and capturing the relationship between those elements.

learn more… | top users | synonyms (1)

10
votes
8answers
1k views

Is this code good enough, or is it stinky? Parsing a file.

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace DotNetLegends { public class LogParser { /// <summary> ...
10
votes
4answers
737 views

LL(1) tokenizer for LISP

I am trying to write a LISP interpreter in C#, so I started with a tokenizer. I haven't finished it yet (have to handle floating point numbers, symbols), but I already rewrote it two times because I ...
8
votes
4answers
4k views

Simplify splitting a String into alpha and numeric parts

Requirement: Parse a String into chunks of numeric characters and alpha characters. Alpha characters should be separated from the numeric, other characters should be ignored. Example Data: Input ...
7
votes
3answers
464 views

Coding style in C

I'm a C# programmer and I would like to start getting better at coding in C. I wrote a function which reads a space delimiters settings file (supports comments / and #). The code works fine. But from ...
7
votes
2answers
610 views

Please help me find the bottleneck in my code

I'm making a scripting language parser and it's shaping up well but it takes is about 30ms to do 30 or so odd/even checks. Profiler tells me that it's taking most of the time in the ...
6
votes
2answers
1k views

Same code to parse int, float, decimal?

I have a method to parse strings. It can be used to parse a float using a specific culture and then get a new string with a specific out-culture. The same applies to ints, doubles and decimals. The ...
6
votes
1answer
370 views

I need help scrubbing this code down, parsing a file.

Note: This file is out of my hands. I cannot change the format or type of file I have to parse. Here is some sample data that I'm trying to parse. This is information for just one player: ...
6
votes
2answers
427 views

Are there any ways to improve my HTTP request path parser?

I have written a method to tokenize HTTP request paths such as /employee/23/edit. protected void compile(String path){ int mark=0; for(int i=0; i<path.length(); ++i){ ...
5
votes
3answers
332 views

Is there any way to improve (shorten) this F# code?

I have a very good grasp of the syntax and features of F# as well as some of the concepts that mesh well with the language. However, I do not have enough experience writing it to feel comfortable that ...
5
votes
2answers
123 views

Critiques on a trivially easy to use Python CSV class

I have been working on a project where I needed to analyze multiple, large datasets contained inside many CSV files at the same time. I am not a programmer but an engineer so I did a lot of searching ...
5
votes
1answer
411 views

Handling parsing failure in Scala without exceptions

I have a Scala (Play!) application that must get and parse some data in JSON from an external service. I want to be able to gently handle failure in the response format, but it is becoming messy. What ...
5
votes
3answers
318 views

Is this query-string parser bug-free?

I tried to implement a definitive, reliable URL query string parser that handles every corner case: it tries to be efficient by avoiding regex it takes full URLs or just query strings (as long as ...
5
votes
1answer
538 views

Parse Java source code

I have a bunch of simple interfaces like this one (pretty enough formed, but not guarantee) package com.example.sources; import com.google.gwt.resources.client.ClientBundle; import ...
5
votes
3answers
382 views

Javascript Object Placement / String Parsing Method

This JS function is intended to retrieve or place a value into an object with the nested keys as a string. For example var obj = {a: {b: [4]}}; parse_obj_key(obj, "a.b.0") should equal 4. ...
4
votes
2answers
414 views

Parsing URL segments

The .htaccess file redirects all requests to this file and the $_REQUEST['path'] variable contains the url after the base url. $url = ''; $urlSegments = []; $resource = ''; $action = ''; $parameters ...
4
votes
2answers
356 views

Code review - parse a query to arrays

I have a query like this "abc=1, def=2, ghi=3" and I need to parse it into arrays like this keys = [abc, def, ghi] and values = [1,2,3] currently my code is like this String[] terms = ...
4
votes
1answer
84 views

Is my PHP script/embed remover robust?

The goal of this question: Your goal here is to find a security hole in my code which allows a user to create input that contains a script doing anything they want, without that script being stopped ...
4
votes
2answers
2k views

Better way to parse XML in Python

I'm sure there must be a better / simpler way of doing this.... The aim of this code is to return an object which contains all of the movies. Where attributes are not found, they need to return ...
4
votes
1answer
80 views

Char* hex string to BYTE Array

The idea is that i want any size string to put the corresponding hex value into a byte array. I've seen a million ways to do it. Some of them didn't look to clean. My needs are speed over memory, so ...
4
votes
1answer
220 views

Using Parsec for lexing&parsing

I'm creating list of Tokens from input [Char] stream using Parsec v3. The definition of Token looks like this: data Token = CharKeyword | OpeningBracket | Identifier String | Natural Int As result ...
3
votes
1answer
356 views

Best way to make parser code more readable and efficient?

I am optimizing the variable parser for my programming language, and also trying to make it more readable and concise (precedence: readabl e& concise > efficient). What is the best way to improve ...
3
votes
2answers
108 views

How would one more elegantly parse data from XML using Ruby and Nokogiri?

I have a method that parses XML into an array of hashes. Here is the original XML: <rowset name="skillqueue" key="queuePosition" ...
3
votes
4answers
131 views

download an image from a webpage

I originally posted this on stackoverflow and was recommended that I post here, so I apologize if you see this twice:) I am trying to write a python script that download an image from a webpage.on ...
3
votes
2answers
146 views

A simple compiler for a language called Jack

Below is the code for a compiler I created for a language called Jack. This compiler is one of the projects for the book "The Elements of Computing Systems" (http://www1.idc.ac.il/tecs/plan.html) ...
3
votes
4answers
537 views

URI parsing and handling class

I wrote a simple class to deal with parsing and handling URIs for the project I'm currently working on, since it relies a lot on that functionality (eg the Router class and some HTML helpers). Here is ...
3
votes
2answers
215 views

Custom parser for named parameters in prepared statement

I'm creating a small extension to the JDBC API, with the hope of automating some common tasks and avoid boilerplate code. One of its features will be a basic support for named parameters in prepared ...
3
votes
3answers
138 views

Parsing Placeholders as SQL Arguments in PHP

I am trying to find a good way of parsing SQL arguments, the way I am accomplishing it now seems like it can use a lot of improvement. I am trying to convert arguments that are split apart by ', & ...
3
votes
3answers
565 views

73 Lines of Mayhem - Parse, Sort and Save to CSV in PHP CLI

Inside of a folder named txt I have 138 text files (totaling 349MB) full of email addresses. I have no idea (yet) how many addresses there are. They are separated from one another by line breaks. I ...
3
votes
2answers
208 views

Text parser implemented as a generator

I often need to parse tab-separated text (usually from a huge file) into records. I wrote a generator to do that for me; is there anything that could be improved in it, in terms of performance, ...
3
votes
1answer
152 views

Substitution of different occurrences of a string with changing patterns

I need to parse an invalid JSON string in which I find many repetitions of the same key, like the following snippet: [...] "term" : {"Entry" : "value1", [.. other data ..]}, "term" : {"Entry" : ...
3
votes
2answers
186 views

QJson: Yet another Json parser and serializer for Qt, but with additional features

I wrote QJson, a utility class in/for Qt, I need you to take a look at. It is both a JSON parser and serializer, but with extended funcionality (going beyond the JSON specification) (see first ...
3
votes
1answer
204 views

DnD dice roll parser

Some time ago I've written a small parser (about 250 LoC) which is capable of executing the four arithmetic operators +-*/ as well as a dice-roll operator, NdM, which "rolls a dice", DnD style. The ...
3
votes
1answer
198 views

Unicode parsing in PHP

Firstly, apologies if this is not the correct type of question for here, I had it on the stackoverflow but it was closed with a suggestion I post here. I’m in the process of converting from Latin 15 ...
3
votes
2answers
2k views

Parsing JSON with JavaScript

I need to write some JavaScript code that will take a JSON string, parse it, and return the names of the most-deeply nested properties. For example, for this input: var json = "{\ foo: {\ bar: ...
3
votes
1answer
85 views

How to make this BigRational parsing method more efficient?

I'm using the BigRational beta off the BCL CodePlex (bcl.codeplex.com), and I realized it had no parsing method. So I tried to write one. However, it's quite inefficient (5.5ms for a 254 character ...
3
votes
1answer
211 views

Parsing Wikipedia data in Python

I'm new to python and would like some advice or guidance moving forward. I'm trying to parse wikipedia data into something uniform that I can put into a database. I've looked at wiki parsers but from ...
3
votes
2answers
316 views

Joining url path components intelligently

I'm a little frustrated with the state of url parsing in python, although I sympathize with the challenges. Today I just needed a tool to join path parts and normalize slashes without accidentally ...
3
votes
1answer
72 views

C# expression evaluator review request

I successfully created an expression evaluator in C#, and I would like to know if it works well, and what I can do to improve it. class ExpressionEvaluator2 { public enum Token { ...
3
votes
3answers
335 views

Python Game Log Parser

Please review my Log parser for general problems. I am planning to move all of the log reading code into a class and rearrange things on the OO side to make it easier to understand. I hobbled the ...
3
votes
0answers
30 views

A c++ PEG parser generator

Last Weekend I wrote a c++ PEG packrat parser generator and would love to get some feedback on the code and/or syntax. I currently use the << operator for defining grammar expressions and ...
3
votes
1answer
51 views

Have I missed some obvious XSS vulnerabilities?

As the question states: have I missed some obvious security vulnerabilities in this code? Particularly interested in XSS... I'm trying to create something more robust that strip_tags, but simpler ...
3
votes
1answer
189 views

JQuery Promise Interface for a (very) simple JSON Parser

I have written a parser function that returns a JQuery Promise. You can see from the code that this is the top level parser and it delegates out to two other more specific parsers. At the minute it ...
2
votes
3answers
147 views

Is this the right way to read every line?

I am never to sure when it comes to ifstream and reading lines. I am often confused with the good(), bad(), eof() and so on. Could anyone tell me if I am doing it right? int parseLine(std::ifstream ...
2
votes
3answers
217 views

Best way to improve Compiler Code?

What is the best way to considerably decrease the size of the following code without sacrificing functionality, and to make it more readable, and well, make it look professional? class Compiler { ...
2
votes
4answers
169 views

Speedily Read and Parse Data

As of now, I am using this code to open a file and read it into a list and parse that list into a string[]: string CP4DataBase = "C:\\Program\\Line Balancer\\FUJI DB\\KTS\\KTS - CP4 - Part Data ...
2
votes
2answers
117 views

Pair Programming matrix: room for improvement?

At work, we have a "pair programming ladder" where you can keep track of who is pairing with whom (based on check-ins). The idea is to promote "promiscuous pairing" where each developer eventually ...
2
votes
2answers
122 views

Can you guys look at my java project and give me some tips?

So I feel like I'm a good coder, but that's from my point of view. Can you take a look at my code and give me some tips or criticize me on my code. Or give me some tips or things to add or make things ...
2
votes
1answer
623 views

Code to Parse dollars and cents?

I've written code to parse dollars and cents entered by the user. The value returned is the total number of cents. For example: f('$1.50') = 150 f('1.5') = 150 f('0') = 0 f('1000') = 1000 ...
2
votes
2answers
87 views

String parser review

So the task is that a string being passed to one of my methods looks like this <DIV><GKY><UID><END> it is generated this way from another program, so it will always have that ...
2
votes
1answer
205 views

PEG parser in Python

Any suggestions to make this code clearer, more Pythonic, or otherwise better? I'm open to changes to the design as well as the code (but probably won't drop features or error checking since ...

1 2