Questions tagged [parsing]
Use this tag for code that parses its input, or that is source for a parser generator such as yacc or lex.
1,319
questions
85
votes
11
answers
12k
views
Nesting versus GOTO: which is better to avoid?
In Java they're not really known as GOTO statements and are rather referred to as Branching Statements, but I find that the former term is a bit more indicative of ...
49
votes
1
answer
7k
views
Yet another C++ JSON parser
This is a framework for a JSON parser I put together last night.
Any comments appreciated.
JsonLexer.l: Breaks the input into lexemes
JsonParser.y: Understands the language syntax
JsonParser.h: ...
40
votes
4
answers
4k
views
Someone thinks poorly of my server log parser
I have just been informed that the following code written by me is extremely poor. I have absolutely no idea why. It is memory efficient, and looks clean to me. But still the feedback is very poor. I ...
38
votes
6
answers
6k
views
Parser written in PHP is 5.6x faster than the same C++ program in a similar test (g++ 4.8.5)
I'm absolutely dumbfounded by this. I was trying to demonstrate to myself how much faster C++ is than even modern PHP. I ran a simple CSV parsing program in both that have the same output. The CSV ...
34
votes
3
answers
12k
views
Using default None values in Python when assigning split() to a tuple
Let's say I want to parse audio track information into two variables like this:
'2/15' -> track = 2, num_tracks = 15
...
32
votes
2
answers
7k
views
Lexer+Parser code for my "Reedoo" programming language
I've been working on my own programming language, as a hobby for the past couple of months now, called Reedoo. It is implemented in pure C++ 11 and uses only the libraries that come with C++; no ...
31
votes
6
answers
84k
views
Parsing console application arguments [closed]
In our console app, the parsing of application arguments is done like so:
...
31
votes
1
answer
2k
views
Using argparse module within cmd interface
I've created an application that uses a cmd interface. It has multiple levels, and the number of available commands and their complexity is growing. As such, I need to generalise argument parsing - of ...
28
votes
6
answers
28k
views
Validating opening and closing bracket pairs
I have refactored one of my old homework assignments (mainly to utilize std::stack and some C++11), and I'm still having trouble making it less repetitive.
It ...
27
votes
5
answers
11k
views
High performance txt file parsing
EDIT2: There is a summary below of the findings with new improved code and run time results achieved.
Multi threaded follow up has been posted here.
I find, in my daily programming, that text-file ...
27
votes
2
answers
3k
views
A header-only linear-time C++11 PEG parser generator supporting left-recursion and grammar ambiguity
I've rewritten my original parser generator to a header-only library which uses templates and functionals for better type safety and clarity. The generated parser creates an abstract syntax tree which ...
26
votes
4
answers
3k
views
Convert Bitmap Font to Texture Atlas
I wanted to render the textures that comprise a bitmap font glyph onto the screen directly as an Image in libGDX. When you make a bitmap font using a program (such ...
26
votes
4
answers
8k
views
Filtering a large (50gb+) JSON lines file matching CIDR's
I'm trying to speed up a Python script that reads a large log file (JSON lines, 50gb+) and filter out results that match 1 of 2000 CIDR ranges.
Logfile
20 million lines
...
26
votes
4
answers
4k
views
Poor man's JIT using nested lambdas
While answering this code review question, I came up with a way to convert an equation given at runtime to a std::function<double(double)> that would evaluate ...
24
votes
3
answers
7k
views
Converting an IP
I've written a DNS tool in Node and would like to know if there's a better and more efficient way of handling the conversion from an IP to a long. I'm not too good at bitwise just yet and would like ...
24
votes
2
answers
2k
views
parcel: a JSON parsing library in C
I've created a JSON parsing library in C, and would like some feedback on it (feel free to submit a pull request on GitHub). Any and all suggestions are acceptable, but I would prefer if reviews were ...
23
votes
8
answers
6k
views
Optimize custom double.parse()
In my company's code, they use double.tryParse() which is quite good but sets too much security for our needs. As we sometimes have to parse a few billion strings, ...
23
votes
5
answers
22k
views
Parsing CSV to specific format
I've written this code to read CSV files written in a specific format. I would like to gather some feedback on where it could be improved. I'm trying to get into the Test-Driven-Development ideology ...
23
votes
3
answers
3k
views
Parsing log files of HearthStone: The log reading API
I'm still working on a parser that can parse log entries from a game called HearthStone, the overall idea is that it will read the log file live when the game is running, parses the log file and show ...
22
votes
5
answers
4k
views
Parse webpage and save fetched images to a directory
I had a task for a programmer position which I failed. I am a newbie programmer and I accept that. The only problem is that employer never told me what the actual problem with the code is. So maybe ...
22
votes
3
answers
3k
views
Look 'ma, I can read code
I have put together a naive implementation of a VB6/VBA parser, and I'd like to see if the CR community sees the same things as I see can be improved with this code, before I start refactoring.
I've ...
21
votes
5
answers
2k
views
An OEIS Lookup tool in Python
I'm from PPCG so I was making an esolang and I decided to write it in Python. Eventually it went from an esolang to an OEIS (Online Encyclopedia of Integer Sequences) lookup tool. I'm very new to ...
21
votes
5
answers
22k
views
Simple lexer in C++
I haven't written anything in C++ in a couple of years, so I have both forgotten a lot and also wasn't exposed to the modern C++. I am working on a toy programming language and while other parts are ...
20
votes
3
answers
1k
views
Who's using what where - turning code into symbols
The Rubberduck project is coming along pretty nicely, and for the next version the parsing strategy is getting yet another revision, and this time around it really feels like it's done right.
Or is ...
18
votes
5
answers
7k
views
Program that removes comments from C and C++ programs
I have downloaded the latest version of the Linux kernel and I want to perform thorough analysis on it. I want to start by eliminating comments from all the source and header files that belong to it. ...
18
votes
5
answers
4k
views
Speeding up thousands of string parses
I have a mapping application which takes string arguments in the form of string arrays. I parse these and then perform an action on the map. One of these is ...
18
votes
2
answers
2k
views
C-style language lexer for a syntax highlighter
I'm working on implementing a syntax highlighter for a simple text editor I've been working on. To do this, I need a simple lexer for various languages (I don't need a full one - I'm only interested ...
17
votes
7
answers
2k
views
Parsing a file for a game
Is this code good enough, or is it stinky?
...
16
votes
2
answers
3k
views
A completely overkill BrainFuck lexer/parser
I'll need to build a syntax tree (AST) for Rubberduck, but since VBA has dozens of tokens and complex rules, I needed a simpler language to play with first, so I thought BrainFuck would be a perfect ...
16
votes
1
answer
3k
views
House number parsing
I have 2 functions used for parsing a house number and I think these can both be improved.
Any suggestions?
input:
45a - 47b
or
...
16
votes
2
answers
29k
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 ...
15
votes
5
answers
8k
views
Finding longest word in a string
I was working on a problem from Coderbyte. The challenge was to write a function that takes in a string and returns the longest word in the string. If two words are the same size then it asks to ...
15
votes
4
answers
2k
views
How to shorten this terrible HTTP header parser?
I am trying to read a line ending in \r\n from a Handle. This is an HTTP header.
I’m fairly new to functional programming, so I ...
15
votes
2
answers
2k
views
Markdown to HTML
...
15
votes
2
answers
7k
views
Evaluating arithmetic expressions
I have written some simple code for evaluating expressions. However, I am not sure how well I am following conventions (this is my first time trying to).
Specs for problem:
All binary operators (+, -...
15
votes
2
answers
338
views
My recursive parser is wet behind the ears (well, it's not DRY at least)
I have an issue opened on GitHub since mid-November, to refactor & DRY up the Rubberduck Parser module (the idea is to model the code in a VBA project or code ...
14
votes
3
answers
13k
views
Parsing ARP cache in C
How can I make this better?
...
14
votes
4
answers
2k
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 ...
14
votes
2
answers
920
views
HTTP request path parser
I have written a method to tokenize HTTP request paths such as /employee/23/edit:
...
14
votes
2
answers
2k
views
Parsing Z80 assembler in C++
I'm just starting with C++ (I have worked with C for more than a year) and as a first program I wanted to write a cleaner version of my Z80 assembler I had written in C before, this time trying to do ...
14
votes
3
answers
5k
views
Lexer for C- in Python
I am currently taking a compilers course where we are designing a compiler for C- (which is a subset of C). Our first step was the lexer and I have written that but I believe that it is not very "...
14
votes
2
answers
573
views
I think I might be having a regex nightmare
I've been working on the Rubberduck (an add-in for the VBA Editor /"VBE"), specifically here the VBA.Parser namespace. Here's how I ended up implementing ...
14
votes
1
answer
20k
views
Boolean expression parser
I was trying to write some of the Haskell list functions into Java, and I realized that one of the key strengths for many of the functions was the ability to pass in a boolean expression. I decided to ...
14
votes
1
answer
788
views
Rubberduck VBA Parser, Episode IV: A New Hope
My home-made wannabe-a-parser was wet behind the ears, so I started seriously looking into more mature alternatives, and ended up adding a dependency to the ANTLR lexer/parser generator tool, and ...
13
votes
3
answers
5k
views
13
votes
4
answers
59k
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 ...
13
votes
3
answers
13k
views
ini file parser in C++
Please review my ini file parser (and potentially some general config file formats).
The data structure used is a section, see below. Does that seem a good approach?
I was wondering about the name. ...
13
votes
3
answers
23k
views
Math expression solver
I've recently stumbled upon an interesting challenge for me:
You should develop C application, that solves math expressions. Operations such as (+,-,*,/) should be supported, as well as (cos, sin, ...
13
votes
1
answer
44k
views
Parse complex text files using Python
I'm looking for a simple way of parsing complex text files into a pandas DataFrame. Below is a sample file, what I want the result to look like after parsing, and my current method.
Is there any way ...
13
votes
1
answer
180
views
#TODO Remove duplication in XML parsing
I have to modify the number of points in this XML in order to test the performance of another program of mine. Here is an example of the XML I have to modify.
performance.xml:
...