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.

Filter by
Sorted by
Tagged with
1 vote
1 answer
70 views

A simple parser for bencoding format

I have been learning rust sporadically for a while now and decided to write some toy projects. While browsing https://github.com/codecrafters-io/build-your-own-x I came across some bittorrent client ...
Hakan Sonmez's user avatar
5 votes
2 answers
323 views

Parsing gateway ip from `/proc/net/route` in a docker container

In try to replicate the outcome of the following command sequence using php: netstat -rn | grep "^0.0.0.0 " | cut -d " " -f10 I did this using ...
Dimitrios Desyllas's user avatar
2 votes
1 answer
93 views

Command-line parser with built-in error checking

Simple command-line option parser with automatic setting of variables and built-in error checking. The story is I was working on another new project that had a lot of configurable options, as they ...
Mode77's user avatar
  • 641
8 votes
2 answers
942 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 & ...
p0sa's user avatar
  • 81
4 votes
1 answer
99 views

Tokeniser which yields a Range of string views

In my answer to string_view tokenizer function template I suggested that a flexible tokeniser would yield a Range that could be iterated over. This is my implementation of such a tokeniser. ...
Toby Speight's user avatar
5 votes
2 answers
93 views

String unescaping in Dyalog APL

I am adapting the following existing python parser: ...
ohAitch's user avatar
  • 51
0 votes
0 answers
30 views

Detecting the content type of a given http body/string

I am trying to detect the content/mime type of a given Buffer/string. In other words, I am trying to guess what on earth is a given string. My approach is somewhat brute-force: ...
Dimitrios Desyllas's user avatar
2 votes
1 answer
47 views

Parsing one UserData type to a preview

I am currently developing a web app and am using Spring as a Backend. I have some user data that is provided by one of our services and I need to display it in my frontend. The subject of the code ...
monamona's user avatar
  • 425
0 votes
1 answer
67 views

Retrieve data from an XML file in Java

few months back I did a code test for a company and I quickly managed to solve it within 5-10 minutes. But, I got rejected because it wasnt "good enough". What is good enough? they said its ...
Con101's user avatar
  • 3
7 votes
4 answers
415 views

Separating a String of Text into Separate Words in Python

Occasionally, we want to do a rudimentary parsing on English text; we separate the text into separate words. ...
Samuel Muldoon's user avatar
4 votes
7 answers
254 views

Breaking a string expression in operator and operands

Requesting for a code review for a scala implementation. Problem Given an expression string made of numbers and operators +,-,/,* , break it in a list of Integer or ...
vikrant's user avatar
  • 395
3 votes
3 answers
601 views

Command line calculator in C

This code is an arithmetic parser as is the code in a previous question of mine. However this parser handles floating point arguments and mathematical functions, and handles them without needing to ...
user16217248's user avatar
5 votes
1 answer
518 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 ...
user16217248's user avatar
4 votes
0 answers
164 views

constraint solving graduation using HTML Parsing, pandas, and z3

not sure if this project fits on code review, but my code is getting extremely messy, and would love some tips to clean it up! Overview The project is designed to take in an HTML file (a degree audit),...
retep's user avatar
  • 169
2 votes
1 answer
98 views

Powershell file parsing

I am using Powershell 7. We have the following PowerShell script that will parse some very large file. I no longer want to use 'Get-Content' as this is to slow. The script below works, but it takes a ...
Cell-o's user avatar
  • 285
3 votes
1 answer
140 views

ANTLR4 grammar for Conventional Commits spec

I would like to create a grammar for the Conventional Commits spec and I would love to hear any feedback for what I wrote. The spec has some ambiguities, I think, hence my usage of "island ...
Michael's user avatar
  • 133
0 votes
1 answer
70 views

Parsing shortcodes out of a string

I wrote this shortcode parsing and it runs in \$O(N^2)\$. Is there a way to better optimize this? ...
ericraio's user avatar
  • 151
1 vote
2 answers
134 views

Creating a dictionary from a word document using docx

I have a word document that contains alphabetical bullet points along with the key: value that I am trying to input into a dictionary using docx. Example: ...
Brendan S's user avatar
6 votes
2 answers
1k views

Read a large CSV order book

I am trying to read entries of my CSV file into an entries vector whose data type is object OrderBookEntry, which is an object that stores the tokenized variables ...
Beginner_coder's user avatar
7 votes
1 answer
201 views

Chess position representation with FEN parser

I'm developing a UCI chess engine and as part of my engine I need a position representation that stores the position of every piece on the board and all the information about the game, like castling ...
Aiya's user avatar
  • 108
3 votes
1 answer
175 views

Generating indent and dedent tokens for python-style indenting code

I found lexy, a C++ template-based parser combinator, that helps a lot to build a language parser. The problem is that lexy can only deal with context free grammar, and python indentation is not ...
jokoon's user avatar
  • 293
0 votes
1 answer
61 views

Checking several strings against a n-depth list of lists and returning one if its values

The data structure I am working with is a list of lists that is created by parsing a file. The depth of the list can vary. The list can have n Strings before its child-value begins. My current example ...
Qohelet's user avatar
  • 151
2 votes
0 answers
130 views

Pillow plugin adding support for the QOI image format

Pillow is a popular library for handling images in Python. My code adds support for the QOI image format to Pillow. Aside from loading and saving QOI images, my goal was to write a streaming decoder ...
gazoh's user avatar
  • 2,902
1 vote
1 answer
66 views

State machine for parsing GitHub URL formats

A while ago, I wrote a small Rust crate for parsing & generating URLs for GitHub repositories in various formats (HTTPS, SSH, git://, etc.), with the parsing done using regular expressions with ...
jwodder's user avatar
  • 302
0 votes
0 answers
123 views

Top-down parser for arithmetic expressions

Here is a JS parser for a simple language we use at work. For now it can only parse arithmetic expressions. I would like to make sure I am on the right track before starting with the other constructs, ...
user266319's user avatar
1 vote
2 answers
126 views

Parse list of UserPrincipal objects into custom class

I'm wondering how I could optimize this method that takes in a list of UserPrincipal objects, filters them by Regex and inserts the new class instance into a list. It takes 4 to 5 seconds for an input ...
mvi2110's user avatar
  • 11
0 votes
0 answers
57 views

Parsing log files for scan date, IP address, ports, etc. to create JSON

I wrote this code that uses the nom library to parse some values from a log file and then output data in JSON format. I had to use a lot of variables for the cases when the parses found nothing, ...
Erty Desu's user avatar
3 votes
5 answers
869 views

Struct that parses full name into first name, middle name, last name and suffix

The struct below parses full name into first name, middle name, last name and suffix. Perhaps Builder pattern is more appropriate here? I remember there was a principle referring to the number of ...
nop's user avatar
  • 719
2 votes
1 answer
142 views

PHP Laravel Check if given date is a week or a regular day

I have a problem. In my project the user can copy a menu for a specific day or for a specific week. The value that will be sent to the back-end will be something like: ...
A. Vreeswijk's user avatar
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 ...
CubeyTheCube's user avatar
2 votes
2 answers
381 views

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

I need to parse a file, with a standard formatting: ...
Maxime's user avatar
  • 123
3 votes
1 answer
252 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: ...
Martin's user avatar
  • 181
1 vote
1 answer
71 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 ...
Alex's user avatar
  • 21
2 votes
1 answer
84 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 ...
Daniel Walker's user avatar
1 vote
1 answer
94 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 ...
Pom Mop's user avatar
  • 57
2 votes
1 answer
54 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 ...
Jahid Chowdhury Choton's user avatar
2 votes
1 answer
43 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. ...
reducing activity's user avatar
3 votes
2 answers
1k 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 ...
Caleb Shank's user avatar
2 votes
2 answers
182 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 ...
Kami's user avatar
  • 23
2 votes
1 answer
147 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 ...
luser droog's user avatar
  • 2,008
2 votes
1 answer
136 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 ...
luser droog's user avatar
  • 2,008
3 votes
2 answers
89 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 ...
Afolabi Olaoluwa's user avatar
0 votes
1 answer
72 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 ...
Edenia's user avatar
  • 1,548
1 vote
2 answers
138 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 ...
stromboli's user avatar
2 votes
1 answer
181 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 ...
JackWeir's user avatar
5 votes
0 answers
73 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 ...
Seninha's user avatar
  • 171
1 vote
2 answers
424 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 ...
LRDPRDX's user avatar
  • 781
2 votes
2 answers
108 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 ...
Jason Leaver's user avatar
8 votes
2 answers
940 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 ...
Latex_xetaL's user avatar
4 votes
1 answer
215 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 ...
792f8NFF's user avatar

1
2 3 4 5
27