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
2 votes
0 answers
9 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 ...
2 votes
2 answers
37 views

Parse a text file, and map to an out-of-scope POJO

I need to parse a file, with a standard formatting: ...
  • 121
0 votes
0 answers
39 views

Parse string from the byte array of a video file

I read in MP4 files with my program. To determine the codec, you have to look at the ‘mdat’ block whose content I wrote in a text file so you can see. The standard doesn't seem to be too strict, ...
  • 207
3 votes
1 answer
233 views

Processing lines of a file with various space-separated fields of strings, hex addresses, and integer addresses

I have a plain text file which contains lines with fields below: ...
  • 183
1 vote
1 answer
61 views

Parsing an XML tree of categories

I have parse function which is parsing tree of categories. I've written it in simplest way possible and now struggling with refactoring it. Every nested loop is doing the same stuff but appending ...
  • 21
2 votes
1 answer
44 views

Iterate over a process' maps file

The following logic provides iteration over /proc/<PID>/maps for a Linux process. What I'm primarily (though not solely) interested in for this review is ...
1 vote
1 answer
70 views

Parsing: Сollecting data from a book site

A task: Сollect data from the site in the following format: book; user; book_rating; comment_rating; publication_date; comment For one book at once several pages of ...
  • 57
2 votes
1 answer
45 views

Improvement for parsing LTL grammer

I'm new here. I wrote the following code to parse the linear temporal logic(LTL) formula and evaluate it with respect to a trace. But I'm totally not happy with my code because I think the complexity ...
2 votes
1 answer
21 views

parsing source code to generate documentation of an open source program (StreetComplete, an OpenStreetMap editor) - 1180 lines of Kotlin script

All help welcomed! I posted a big chunk of code here - but feel free to review only a small section. I will use answers to improve this deployed open source software. About the code This code works. ...
3 votes
2 answers
852 views

Password Validation Class

I created a class designed to validate passwords based on user defined criteria. Each PasswordValidator object objects a minimum and maximum password length, a character blacklist, as well as ...
2 votes
2 answers
88 views

Python function that parses a long string as key-value pairs for logging

I noticed I tend to use many if-conditions in my code, and I know there is a way to simplify this with one-liners. The function is iterating through configuration dictionaries so that I can log ...
  • 23
0 votes
0 answers
19 views

Parser for Context-Free Languages in Scheme

...
2 votes
1 answer
91 views

Commented Parser Combinators in Lisp-style C

I've attempted to remedy the issues outlined in the answer to my previous question. I've added several hundred blank lines to better illustrate the grouping of functions and generally make things look ...
  • 1,948
2 votes
1 answer
120 views

Parser Combinators in C redux

A few more rewrites down the line from my previous question, this is the C version 11 based on the PostScript prototype version 12. The PostScript version is shorter, but it's some crazy ass ...
  • 1,948
2 votes
0 answers
48 views

Parse a document and returning uniqueness and total number occurrences

I am parsing a document and returning (1) uniqueness, and (2) total number occurrence. I believe my code can still be subjected to review. I would like a review of my code as I have even made it too ...
0 votes
1 answer
65 views

Function to perform a logical NOT in a string

I am using "tinyexpr", a cute library that can solve mathematical formulas in a string and I extended it such that it does logical operations with two operands as well. However I wasn't sure ...
  • 1,375
1 vote
2 answers
71 views

Parse string using character value for Unicode characters

I added the getCValue method to reduce the cyclomatic complexity, but the cyclomatic complexity still persists. How can I reduce it? Can I change this code using ...
2 votes
1 answer
78 views

Text splitter using Regular Expressions in Python

I have been provided a text splitter class that will take a text input and use re.sub to make replacements when matches are found and also splits sentences up and stores them in a list. I had an idea ...
5 votes
0 answers
51 views

Menu Parser in C

This is a simple program that parses a menu specification and creates a menu tree. Why? I want to create a menu application, where the user can select an entry in the menu, and either a submenu can ...
  • 151
0 votes
0 answers
35 views

I am building a container of differently typed variables with names for easy parsing and usage in Rust

I am new to Rust and trying to learn more about it. I want to have some kind of container that can store parameters (variables, values, constants) of varying types together with a name. This container ...
  • 101
1 vote
2 answers
92 views

Reading 12-bit words from 32-bit stream

I have a device (ADC) that stores its samples in a 32-bit buffer and each sample is a 12-bit word : I needed an algorithm to read those samples to a container (say ...
  • 771
2 votes
2 answers
90 views

Regex and pandas to read forecast sky condition string

DataFrame methods to parse the sky condition from a terminal aerodrome forecast. A line in a taf can report zero-eight cloud layers. Cloud layers are required in predominate lines, and optional in ...
8 votes
2 answers
685 views

Markup Language Parser in C++

I'm new to C++ and decided to write a parser for a markup language. I chose org-mode because it seemed relatively straightforward. parsertest.cpp ...
4 votes
1 answer
83 views

Python script for zlib decompression

I'm looking for feedback/improvement on code that I wrote. It's a function that scans a file for zlib headers and returns the header, offset, and decompressed data. In main, below the function, I use ...
4 votes
1 answer
120 views

Parsing an IP routing report with half a million lines into a PANDAS dataframe

I have a file that has around 440K lines of data. I need to read these data and find the actual "table" in the text file. Part of the text file looks like this. ...
3 votes
1 answer
104 views

Fetch CSV file into PANDAS and send report of Spotify statistics

I'm relatively new and self taught in Python. I've written this code which gets a CSV file from a website, plays around with the data then creates an email with information gleaned. I know this is too ...
  • 33
3 votes
1 answer
104 views

Processing a binary file with buffer length tags

I am trying to process a very large binary file using MappedByteBuffer from java.nio package. This is how the data looks like in the file: ...
  • 33
6 votes
0 answers
197 views

Parsing indented text into a tree structure in C#

My goal is to take an input stream (text file), and then parse it into a tree node based on each line's indentation. My rules are Lines can be indented using either tabs or spaces, but the file must ...
4 votes
1 answer
190 views

Haskell: implementing Read for a custom dynamic value type

I'm using Haskell to interpret a dynamically-typed language. I have a sum type called Value which can represent some basic objects: ...
  • 143
3 votes
1 answer
56 views

Quickly read numeric input

Do you have any criticisms or corrections or improvements? I need to read only numbers(and this numbers could be from 0 to 1000000) ...
1 vote
2 answers
69 views

Function to read a file until next token

I've got this function which reads an entry until the next starting Token determined through a function, as the nature of the token is flexible. Usage: ...
  • 449
9 votes
1 answer
1k views

Python script to analyse Apache log files

I am fairly new to Python programming language. Most of python programmers have heard the philosophy behind the python programming language. The code should be easy to read, easy to understand, simple,...
2 votes
2 answers
94 views

Parse a string with titles and subitems to an object

I want to parse a string to an array of object with following those rules: parse line by line if line starts with "*" this is a title if line starts with "\s**" this is a ...
  • 175
4 votes
1 answer
64 views

Awk program for extracting unique values from a k1=v1,k2=v2,... list

A single string consisting of comma-separated pairs in the format <key>=<value>, like ...
1 vote
0 answers
61 views

Gemtext parser in JavaScript

Gemtext is a lightweight markup language designed to serve content over the Gemini protocol. You can learn more about the language here: A quick introduction to "gemtext" markup, or the ...
  • 1,675
4 votes
0 answers
38 views

formatting flattened string into JSON-like object in C++, part 2

I have reworked the code from my previous (linked) post. For reference: I have a string which contains JSON-like object flattened (stringify()ed). I need to JSON-...
3 votes
0 answers
63 views

Mini Scheme interpreter

Right now, I'm working on an interpreter for a subset of the Scheme programming language. It supports lambdas, let/let*/letrec, procedures, combinations, ...
2 votes
1 answer
83 views

formatting flattened string into JSON-like object in C++

I have a string which contains JSON-like object flattened (stringify()ed). I need to JSON-ify it back. It's a custom format, so I wrote function to JSON-ify the ...
0 votes
0 answers
50 views

Script to fix linkage done with #pragma comment(lib, "a.lib) for Visual Studio project

I have a legacy project that has a lot of linkage done using #pragma comment(lib, "libname.lib"). Moreover, some projects define linker directives in ...
1 vote
1 answer
333 views

Better ways to parse the Content-Length from the HTTP header

I have a buffer that contains the HTTP header, which contains the Content-Length string indicating how big the file is that needs to be downloaded. I am looking to ...
  • 362
3 votes
3 answers
128 views

Implementation of a Parser for Analysis Description Language

I have created a script for parsing ADL and the code looks like below. Example ADL file I am looking for suggestions to divide the code in multiple methods and make it more readable. Thanks ...
  • 209
1 vote
1 answer
183 views

Boolean expression evaluation for user input using evil eval

The following code is a module that evaluates boolean expressions, which are entered through an unauthorized web API. The exposed function of the library being used is ...
6 votes
1 answer
130 views

Lexer for a Scheme-like language in rust

I was/am working on an interpreter for a scheme-like language. Just some time back I shifted my implementation from C++ to Rust, which I just started learning. I know there are parser libraries like ...
0 votes
2 answers
205 views

Good practices for parsing this text file

I have the following .txt file structure that i want to parse in Java(8): ...
3 votes
2 answers
457 views

Parsing a std::string to a dictionary (std::map)

As always - the context ! Preliminaries Recently I needed a way to transport data from one environment to another. Though the proper way (probably) to do this would be to use databases (which I don't ...
  • 771
3 votes
0 answers
70 views

Advent of Code 2021: day 10- Syntax Scoring

The following code solves day 10 in the advent of code challenge. The goal for this time around is evaluating whether a line of brackets is complete, has a syntax error or is missing some closing ...
2 votes
1 answer
66 views

Parsing A Simple Matrix Definition In C

In one of my homework projects, I have to parse a matrix definition into a matrix data structure in C. The elements of the matrix will be given in a list of double. I need a simple tokenizer and ...
  • 123
1 vote
1 answer
93 views

Parse a selection of date formats

This Bash program parses day, month, year and month and year from arguments: ...
  • 173
6 votes
5 answers
406 views

Extracting a part of a URL path

I have a string like the one below from which I am extracting the tariff name. ...
  • 63
3 votes
4 answers
268 views

Convert number 1-5 from its spelt-out form

I'm working with an API that for some strange reason returns star ratings as words, like FIVE,FOUR,THREE,TWO,ONE. As far as I can see, there's no way to just get ...
  • 185

1
2 3 4 5
27