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
6
votes
1answer
162 views

Curl-based REST client library (round 2)

This is a second iteration on an earlier review - cURL based REST client library I have done some refactoring to split out the REST HTTP response into it's own class from what was in the previous ...
0
votes
0answers
26 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 ...
3
votes
3answers
108 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 ...
1
vote
1answer
43 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 ...
1
vote
1answer
82 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 ...
0
votes
2answers
142 views

Good practices for parsing this text file

I have the following .txt file structure that i want to parse in Java(8): ...
6
votes
1answer
49 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 ...
3
votes
2answers
66 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 ...
3
votes
0answers
60 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
1answer
170 views

Decode an alarm keypad message

In my efforts to learn the Swift language, I am trying to mix in a pet project along with my learning of the basic language syntax. In essence, i'm trying to write an iOS keypad application to work ...
2
votes
1answer
53 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 ...
1
vote
1answer
85 views

Parse a selection of date formats

This Bash program parses day, month, year and month and year from arguments: ...
6
votes
3answers
4k views

Parsing a string of the form "key1=value1;key2=value2;" into a Hash

I need to parse the following input string into a hash table with the following format: Input: '1001=23;1001B=5;1002=0;1003=5;' Output: ...
6
votes
5answers
254 views

Extracting a part of a URL path

I have a string like the one below from which I am extracting the tariff name. ...
3
votes
4answers
256 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 ...
1
vote
1answer
89 views

Python Fasta Parser using dictionaries without using BioPython or other external libraries

I am writing my own parser for fasta format. I can't use Biopython or anything else, because it's a part of an assigment and our teacher wants us to try to do it manually. For now, I have done this: <...
3
votes
3answers
413 views

Find the average score, given data in a table with labeled columns not in a fixed order

I was on Hacker Rank for the first time and there was a question that required to get the inputs from STDIN and use collections.namedtuple(). It was my first time ...
1
vote
1answer
81 views

Parsing data from different file formats

While setting up applications to communicate between various different trade partners and our WMS software I often have to parse very similar information from various different file formats. In this ...
2
votes
1answer
984 views

Parsing XML file from the REST API

Please suggest how I can improve my code (like memory leakage, which pattern to use etc.). I have to parse a book XML in two ways: first from an FTP file and second from the REST API. I implemented ...
4
votes
2answers
193 views

i3 config file parser

So I am using i3 an Linux window manager to manage my windows. In addition this is run on a laptop that is frequently mounted to several output-displays. This is handled by the following lines in my ...
3
votes
1answer
25 views

Bash argument parser with support for concatenated flags and '=' or ' ' between arguments and values

This is my best attempt so far at a bash script argument parser written without GNU getopt or bash getopts the first two ...
1
vote
1answer
70 views

using pandas and numpy to parse dirty .csv

I'm relatively new to Python have been writing for a few months now. I've started a Pandas Numpy project that starts with parsing large and somewhat sloppy formatted textfile, its not exactly csv but ...
3
votes
0answers
66 views

Python program that analyzes a corpus for randomword generation

I play a lot of old-school western CRPGs, and most of them (if not all) require the player to generate an avatar at the start of a new game, including naming the character (with names that will never ...
3
votes
3answers
133 views

PHP fetch an automated email, parse text for specific data, store, send summary

I'm new here. I recently found myself in charge of a large PHP-based system. The guy that wrote it produced some of the worst code I've ever seen. I've never been in charge and have had the luxury of ...
5
votes
1answer
87 views

Small combinator parsing library in Haskell

I recently wrote code to parse lambda expressions written in a lisp like format, using a small hand-rolled parsing library. The goal This code was written as a part of this code-golf challenge not as ...
2
votes
3answers
116 views

Optimize lexer/parser bottleneck in C++

I am writing a parser for a custom mesh format for fluid dynamics simulation library, the mesh file contains 3D points (vertices) for the simulation mesh, for example: ...
6
votes
1answer
280 views

Parsing input and output currency names

The input for price() would be STRINGS, as you see below. If the string starts with "-" I would like what follows to be stored in fiat_name and then retrieve the symbol from ...
1
vote
2answers
159 views

Parsing words from string

I am learning Java, so I am beginner. I know I can do this with split function but I want to improve my algorithm knowledge. I will be glad if you help me. Thanks. inputStr variable is contains the ...
3
votes
2answers
720 views

Separate an email address into its username and domain name

This is my first ever Python program and I wanted to get everyone's opinions on it. The goal of the program is to separate an email address into its username and domain name. ...
2
votes
0answers
33 views

How could this indentation-based lexer be simplified?

I finally got this lexer working. How can the parse function be simplified? The goal is to take a tree of indentation-based text, and convert it into parentheses-...
1
vote
2answers
82 views

Function to skip characters

A very simple function that can be used such that it returns a pointer to the first character on which func returned 0. However, ...
4
votes
1answer
52 views

Preprocessing invalid xml before feeding it to a parser

As part of a larger project I'm writing to learn C++, I'm trying to read through some almost-XML files generated by another program. Unfortunately this program uses its own custom escaping logic, so ...
1
vote
0answers
75 views

Yet another .ini parser for AutoHotKey

I decided to learn a little about AutoHotKey, to practice a little and learn about classes. I ended up writting a basic ini file parser. ...
1
vote
2answers
58 views

Extracting items from comma/semicolon-delimited strings, discarding parts after a hyphen

New Scala dev here. Is there a more idiomatic or efficient way to accomplish this in Scala? Given a list of the following strings, I need to obtain the unique 'main parts' once any parts including ...
1
vote
1answer
43 views

Suggestions on making this parsing/unparsing format more human-friendly

I am working on some application which involves regular expressions with counting. Also, these regular expressions are not necessarily over some fixed alphabet, but over some class of predicates over ...
12
votes
5answers
19k views

Python calculator taking string input

It accepts string input like '1+1' instead of num1 = 1, num2 = 2, operation = '+' or something like that. ...
4
votes
1answer
71 views

Convert ASCII representations of phonetics to Unicode characters

Here is some working code for converting an input string to an output string: ...
8
votes
2answers
188 views

JSON4 parser in Typescript

Context I may have accidentally gotten a little sidetracked during homeschooling, and wrote a JSON4 parser in Typescript during the down-time. This project started as an idea that I got while ...
0
votes
0answers
21 views

User input, floats, ints and ranges

Intro So I am writing a larger script where a part of it is checking user input. Maybe I have a menu where the user can choose different options, or maybe I want them to write in some number/s. After ...
3
votes
2answers
130 views

Parse sequence of characters detecting formatting categories

I am a beginner coder and SonarLint tells me code is too complex. I tried recursion, iterators, slicing but had not luck making this code any simpler. The code will parse the input string to detect ...
2
votes
1answer
104 views

Parsing glider data from IGC files

I have to do a program in PHP that reads IGC files like this IGC file and gets records about the glider. For now I came up with something like this: ...
2
votes
2answers
112 views

Message encode/decode library

I write protocol messages encoder/decoder for my project. All messages have 2-bytes header (1 byte - message type, 1 byte message sub-type) and body. There are two types of messages: Plain message - ...
5
votes
2answers
143 views

C key: value file parser

I implemented a key:value format file parser in C, or something that comes close to it as there is no such thing as dynamically creating structs in C. Assumptions: we are creating a C program that ...
6
votes
4answers
1k views

Make my XML Parser in Java using WoodStox run faster and use less memory, or just generally better

I have an XML Parser in Java using WoodStox that I wrote. This parser is going to be parsing through extremely large files, could be 5+GB. The goal of the parser is to convert a nest XML file into a ...
7
votes
1answer
528 views

Count characters, words, and lines in files (wc in rust)

I wrote a barebones version of wc in rust. wc is a program that counts the number of characters, words, and lines in a file and ...
3
votes
3answers
69 views

C string parser criticism

I have written a program to parse a string depending on the string the user provides. Any advise/criticism is appreciated. ...
25
votes
4answers
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 ...
3
votes
0answers
65 views

Lisp expression parser

I'm building a very simple Lisp interpreter. Similar to the the one from here. Here is what I have so far for the parsing part, that is, everything from "text is passed to the the program" ...
6
votes
1answer
298 views

Calculator in C - Parsing arithmetic expression using the shunting-yard algorithm

This is a simple arithmetic calculator, which parses mathematical expressions specified in infix notation using the shunting-yard algorithm. This is one of my personal projects and I would love to ...
3
votes
2answers
2k views

Parsing a text file into a pandas DataFrame

I have a .txt file that looks like this: ...

1
2 3 4 5
26