Questions tagged [parsing]

Parsing is the process of analysing a string of symbols, either in natural language or in computer languages, conforming to the rules of a formal grammar.

Filter by
Sorted by
Tagged with
47
votes
1answer
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: ...
15
votes
2answers
6k 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 (+, -...
11
votes
3answers
9k 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. ...
4
votes
1answer
121 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 ...
20
votes
3answers
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 ...
5
votes
1answer
193 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 ...
34
votes
6answers
5k 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 ...
23
votes
2answers
1k 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
2answers
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
2answers
2k views

Markdown to HTML

...
10
votes
1answer
395 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 ...
5
votes
1answer
376 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: ...
12
votes
2answers
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
2answers
176 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 ...
9
votes
1answer
4k views

Equation parser and solver

I wrote this equation parser and solver, I feel like it is well documented and tested: ...
9
votes
1answer
8k 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. ...
4
votes
3answers
307 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 ...
2
votes
1answer
566 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
1answer
159 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
1answer
282 views

Deserializing a customly formatted string

The component receives a serialized message as a string and a serialized schema as a string. The ...
27
votes
5answers
5k 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 ...
7
votes
1answer
1k views

Code from “Write Yourself a Scheme in 48 Hours” tutorial

I recently went through this Haskell tutorial. I'd be interested in any thoughts or comments at all, in terms of improving the structure, order, haskell conventions, or that long, kind of ugly eval ...
5
votes
3answers
451 views

Nested switches vs domain specific parser

I'm working on an application which has a defined and immutable (for our purposes) communication protocol. One of the features is that users on the controlling terminal can enter text commands that in ...
23
votes
3answers
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 ...
10
votes
2answers
5k 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 ...
8
votes
2answers
268 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
2answers
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 ...
7
votes
2answers
121 views

Put it in a bucket

You're running a jeans company. Your system is collecting detailed orders' data, but it's a bit archaic and it's storing the number of units ordered per size in a delimited string with 20 "fields", ...
5
votes
1answer
7k views

Parse a config-file and add to command-line-arguments using argparse in Python

I am trying to parse the command line arguments using argparse, and if the user specifies a yaml file for the config-file, add those arguments to the args from argparse ...
3
votes
1answer
424 views

File parsing and data management

This is part of a two-part post (Part 2). Here, I have two recent projects that parse a file. The first uses a loop that's kind of hard to follow, and the second uses "modes" to decide what to do. ...
2
votes
3answers
119 views

File parsing and data management - follow-up

This is part of a two-part post (Part 1). Here, I have two recent projects that parse a file. The first uses a loop that's kind of hard to follow, and the second uses "modes" to decide what to do. ...
1
vote
1answer
1k views

Parsing JSON in one go using state machine solution

I need to parse a simple JSON string (flat JSON, no hierarchy) for keys and values, and there is a system constraint that I cannot use any built-in JSON library and can only read a string once due to ...
14
votes
5answers
7k 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
1answer
685 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 ...
11
votes
2answers
167 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
2answers
500 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 ...
9
votes
3answers
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 ...
8
votes
1answer
277 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… ...
8
votes
3answers
1k 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
3answers
1k 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
2answers
328 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 ...
7
votes
1answer
26k views

Parse strings and convert the value to .java types

Below is a generic code for parsing strings (read from file for example) and converting them to .java types, such as primitives (and their wrappers), java.io.File, Enum etc. There is also possible to ...
6
votes
2answers
1k views

Calculate food company sales for the year

I am working on a Python project where a food processing company is trying to calculate its total sales for the year. Python has to read from a text file where its divided into for categories split by ...
6
votes
3answers
214 views

Custom integer parser optimized for performance

I want an integer parser so fast it risks discovering time travel. I'm stuck in C# for a language, but that doesn't mean I can't try to use c++. So I wrote the following: The best I could do ...
6
votes
2answers
3k views

Extract the title from a webpage using the python 3 standard lib

The aim of this module is to extract the title from possibly broken hypertext. Without using any awesome third party modules like bs4 or ...
6
votes
2answers
142 views

Compact command line argument parser : Revisited

This question is a follow up to my previous one which can be found here. The user dfhwze suggested me to look into compiler construction and recommended me to write a lexer and a parser that would ...
5
votes
2answers
109 views

Matching maximal nodes with velocities

I have written a code which works very good for small data-files (see below). The data file 'WSPL.dat' which I want to evaluate has a size of 2.6 GB and the data file 'VELOC.dat' has a size of 4.3 GB....
5
votes
4answers
7k views

Data type detection for a CSV file parser

I am building a CSV file parser, and in order to get the appropriate Object to represent different data types found on the parsed files, I wrote the following function: ...
5
votes
2answers
8k views

Numeric expression parser - calculator

In particular, if someone could describe a better way to go from the tokenized list to the Expression tree, it would be super helpful. I would like to get rid of the casting in the parser but am not ...
4
votes
2answers
476 views

Parsing Gaussian 09 output for energy statement on one or more files and reformat it to a table

I am a computational chemist working with the program Gaussian 09. After I manually check the output(s) I want to create a summary for easier processing of the obtained values. Also avoid opening all ...