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.
120
questions
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 ...
5
votes
1
answer
220
views
Overhauled tokenizer for markargs
In the previous post I've started writing a tokenizer for my imaginary programming language (which I decided to name markargs; trivia at the end of the post).
Problem definition:
Read the line and ...
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: ...
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 ...
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 (+, -...
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. ...
5
votes
1
answer
196
views
Replacing Uri with a more convenient class
I needed some data structure for holding Uris so I thought I try the Uri class. It quickly turned out that it's very impractical because:
it's missing an implicit ...
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
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 ...
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 ...
15
votes
2
answers
2k
views
Markdown to HTML
...
12
votes
2
answers
4k
views
More efficient way to retrieve data from JSON
I am using the jsmn JSON parser (source code) to get extract data from a JSON string. jsmn stores the data in tokens that just point to the token boundaries in the JSON string instead of copying the ...
10
votes
2
answers
194
views
Of Procedures and Variables: never enough nodes
Building on my ANTLR tree listener, I'm now starting to see how the whole thing is coming together.
As I proceed to implement the numerous Node classes I'm going ...
10
votes
1
answer
431
views
Python - basis of a parser library
This is a followup of sorts to this question: link. 'Of sorts' because, as pointed out in the comments, this question should have been asked first.
I'm writing a parser library in Python, mostly for ...
9
votes
1
answer
10k
views
Creating truth table from a logical statement
This code creates a truth table from a statement in logic. The statement is input as a string, and it is identified as a tautology if it is true for all true and false combinations of the variables.
...
9
votes
1
answer
6k
views
Equation parser and solver
I wrote this equation parser and solver, I feel like it is well documented and tested:
...
5
votes
4
answers
5k
views
`atof` implementation
I have implemented the atof function. Here is my implementation
...
5
votes
1
answer
467
views
Python parser for attributes in a HAML template
I'm working on a feature for the HamlPy (Haml for Django) project:
About Haml
For those who don't know, Haml is an indentation-based markup language which compiles to HTML:
...
4
votes
3
answers
549
views
Parse 2D matrix, 2 versions
I'm writing a little C program that computes matrices (for learning purpose). The matrix is fed through arguments in the following form : "{{43,543.324,34},{43,432,87}}"
The user doesn't give the ...
4
votes
1
answer
601
views
Basic recursive descent parser in C
The purpose of this code is to evaluate simple integer expressions that make use of the C arithmetic and bitwise operators while respecting C operator precedence and parenthesis. I wrote this code ...
3
votes
1
answer
716
views
Type converter framework (v2)
This is the second version of my type converter framework.
The the previous one can be found here: Type creator service & framework
In this version I mostly implemented what @Dmitry Nogin ...
2
votes
1
answer
293
views
Parser Combinators in OO C
In trying to understand and use the Parser Combinator concept, I've coded up as close an analogue as I could manage within the constraints of the C language.
C doesn't have first-class functions or ...
1
vote
1
answer
324
views
Deserializing a customly formatted string
The component receives a serialized message as a string and a serialized schema as a string. The ...
1
vote
1
answer
65
views
Advent of Code 2020 - Day 3: tobogganing down a slope
Previous: Advent of Code 2020 - Day 2: validating passwords
Problem statement
I decided to take a shot at Advent of Code 2020 to exercise my Rust knowledge. Here's the task for Day 3:
Day 3: ...
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 ...
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 ...
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 ...
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 ...
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 ...
12
votes
1
answer
590
views
C++ Parsing with chain of responsibility
The task was to create the parser for the string input, that would return the std::vector< int > of parsed numeric results and the type of given input (e.g. numbers, division by zero error, out of ...
11
votes
3
answers
2k
views
Parsing expression with exponents and evaluating
I'm programming a basic command line calculator in java that can parse expressions and evaluate them, does not handle brackets yet.
For example an expression: \$9+9/2^2*5-1\$.
At this point I can ...
11
votes
2
answers
204
views
Using state transitions to filter C comments
This is my second attempt at K&R 1-23,
Write a program to remove all comments from a C program. Don't forget
to handle quoted strings and character constants properly. C comments
don't nest....
10
votes
2
answers
1k
views
Simple parser using Flex and C++
This is an alternative parser based on the specifications from this question. Briefly stated, the input file is a text file which has at least 33 fields separated by semicolons.
If the fourth field ...
10
votes
5
answers
2k
views
Using TryXXX pattern to avoid exceptions
I have been using the TryXXX and GetXXX pattern lately to give clients a choice whether to trap an exception or to read a boolean. An example of this concept would be ...
10
votes
4
answers
542
views
Improving the readability and efficiency of parser code
Recently, I had a test and I wrote this code, but they didn't like my code because it was "deplete and nested".
In order to improve my skills, what would be good ways to make this more readable and ...
10
votes
2
answers
9k
views
Parsing cron expression
I'm building my own scheduler and I took the first step by creating a cron expression parser.
To test it I used this expression to cover each case. (I guess the 52W is wrong but this doesn't matter ...
9
votes
3
answers
1k
views
Match a simple balanced language
I apologise if the title is not very descriptive. If someone can recommend a clearer one I'll edit it. I have an exercise question as:
The language L={anbn} where n ≥ 1, is a language of all words ...
9
votes
2
answers
910
views
Serializing JSON data coming from two URLs in the same object
I have two URLs (urlA and urlB) and both the URL gives me a JSON response back in the same JSON format. Below is my JSON string ...
8
votes
2
answers
953
views
JVM bytecode instruction struct with serializer & parser
I am writing a java class file parsing & serialization library. As part of that i needed to implement a structure for the JVM bytecode instructions as well as come up with a way to parse & ...
8
votes
1
answer
657
views
HTML Parser (using SAX)
Got bored writing a review on an HTML parser and decided I wanted to try.
So I threw this together to see I could parse an Amazon page.
...
8
votes
2
answers
329
views
Log messages parser
I've been studying Haskell for some time, but I have never used it for real. So, I started following the CIS 194 Course from UPenn. I resolved the second homework but I'm not fully satisfied with the ...
8
votes
1
answer
1k
views
Mathematical expression evaluator (C++)
I'm new to C++ and I decided to experiment with the language, by writing a mathematical expression evaluator, using the Shunting-Yard algorithm. A design choice that may stand out as weird is the fact ...
8
votes
2
answers
2k
views
Parsing Wikipedia table with Python
I am new to Python and recently started exploring web crawling. The code below parses the S&P 500 List Wikipedia page and writes the data of a specific table into a database.
While this script is ...
8
votes
2
answers
524
views
Command line parser only with switches (if-less)
I've been playing around with C# 7 and created this if-less and switch-only command-line parser. What do you think of it? Can it be made more C# 7 or otherwise ...
8
votes
3
answers
2k
views
Calculator using tokens of numbers and operators
Lately there has been some questions regarding calculators, where the response typically has suggested simplifying the logic and using either abstract syntax tree or token lists (like I did myself in ...
8
votes
3
answers
2k
views
Parsing oscilloscope binary data
I wrote a simply parser for Tektronix's internal binary file format .isf. The code is supposed to read in the file and return the header data as well as the actual ...
8
votes
1
answer
904
views
A little integer parser vs clean code
I was said to post this as a new question. I improved my code from:
Little part of the string to integer parser vs Clean Code
However I think that it break SRP as it parses, iterates through string ...
8
votes
2
answers
296
views
Splitting plain text dictionary data to multiple files
I have a plain text file with the content of a dictionary (Webster's Unabridged Dictionary) in this format:
...
8
votes
1
answer
298
views
Markdown to HTML, again
I made another markdown parser. (original, this one on github). Look, I'm not crazy (sorta), I just like making markdown parsers…
...
7
votes
2
answers
284
views
Test if string is numeric
I want to implement the following function:
...