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
3
votes
0answers
24 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 ...
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
52 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" ...
1
vote
1answer
33 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: ...
3
votes
2answers
84 views

Parsing a text file into a pandas DataFrame

I have a .txt file that looks like this: ...
6
votes
1answer
125 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 ...
0
votes
0answers
59 views

Asynchronous web scraping

This is my solution to a "vacancy test" task. I'm not sure at all if I have correctly implemented the task, but here is my solution. Goals of code: Parse rows of table from a URL and ...
3
votes
1answer
39 views

Text replacement with Räubersprache (“Røversprog”)

I've been toying with Haskell again and implementing a simple text replacement program that replaces all consonants c in a text by coc, i.e., inserting an 'o' in between: ...
1
vote
1answer
54 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. ...
3
votes
2answers
109 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
0answers
25 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 ...
1
vote
0answers
40 views
1
vote
1answer
80 views

Company database REPL program in Rust for Chapter 8 of The Book

Using a hash map and vectors, create a text interface to allow a user to add employee names to a department in a company. For example, “Add Sally to Engineering” or “Add Amir to Sales.” Then let the ...
0
votes
2answers
69 views

Parse file and make output in custom List [closed]

I have a file output like this and want to do parsing and put the output into a List. The biggest problem here is the name of a wake-lock which appears after ID and runtime, in some cases, it contains ...
2
votes
1answer
62 views

Can this parser (concerning about infinite hierarchy of operators) be implemented purely in ReadPrec?

In Haskell, I tried to implement a parser for expressions containing hyperoperations, and finally succeeded. Valid expressions shall contain: Parentheses. Nonnegative integers. Addition represented ...
2
votes
0answers
45 views

Custom HTML parser in Haskell

For the last couple of months, I have started to learn Haskell and since I am following a course on functional programming soon, I thought I would test my current skills. So what I did was create an ...
10
votes
1answer
1k views

Parsing overly complex JSON

The Merriam-Webster Dictionary API at some point discontinued the use of XML in favor of exclusively returning JSON. This had the unfortunate effect of making finding a definition listed by sense ...
2
votes
1answer
59 views

Parse proxy strings to array of objects

The goal of this module is to take in a string (user input, someone copy and pasting a large list of proxies) and parse it into an array of objects. I appreciate any and all feedback, but I'm ...
2
votes
2answers
70 views

A postfix (a.k.a. Reverse-Polish Notation - RPN) calculator

As an exercise, I put together a postfix calculator using modern Fortran. Language apart, I am interested in knowing your take on the algorithm. As far as I remember from my freshman year (chemistry - ...
1
vote
1answer
49 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: ...
2
votes
1answer
40 views

Terminal Calculator/Parser Inspired by gcalccmd

My program takes input from the user in two ways: By passing input as an argument whilst calling the command By taking any number of inputs after calling the command The program is a terminal ...
3
votes
2answers
87 views

Python: Parse string of bracketed list items into list of strings

I have a string containing several items listed in the following notation: myString = '[A][B][C]' And I would like to parse that to a python list of several ...
1
vote
2answers
78 views

Parse Certain C++ Headers and Dynamically Generate Other Headers Containing Boilerplate Code

A link to the pull request in question. I maintain a C++ DLL / Game Maker library that constructs an environment that allows one to call any game maker script/function from within the C++ dll directly....
6
votes
1answer
228 views

Parsing a JSON one line at a time in Python

happy 2021 everyone! I started coding some months ago for fun and recently I challenged myself to build a JSON parser in Python (v3.8). The basic idea was to avoid loading the whole file at once, ...
2
votes
1answer
145 views

Simple Haskell Parser

I'm very new to haskell (I never used Monads, Functors and other things) and FP in general. I decided to write the simplest parser I possibly can with some expansion possibilities. (I have a general ...
3
votes
1answer
82 views

Parsing values from string into struct using match in Julia

My goal I am parsing from a string which contains token:value pairs into a type. Example: ...
2
votes
1answer
64 views

Extract values from English numerals, e.g. “nine million and one”

Though many have done it the other way around, I have not seen such code in many places. And, to be honest, I don't know why this cluster of if-statements, ...
0
votes
0answers
25 views

BNF for a number

I'm looking to learn and practice parsing, and so I have started with writing an EBNF for a number (using the python interpreter as an example of possible inputs). Here is what I have so far (also ...
1
vote
1answer
82 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 - ...
3
votes
1answer
53 views

Decode alphabet encoded message

Inspired by another Q I finally made a version that groups permutable regions into parentheses. Non-ambigous sequences are outside of parens. Here the original problem: Given the mapping a = 1, b = 2,...
4
votes
3answers
283 views

Parsing “key: value” format in which values can span multiple lines

So I've written a function which parses a fairly simple key-value pair syntax. Each pair can span across multiple lines, as long as the value does not have a colon in it. If it does, then any new line ...
10
votes
2answers
388 views

Parsing a Chess FEN

What is an FEN? Link to the Wikipedia page: Forsyth–Edwards Notation An FEN is a very simple way of representing a chess position in a single line string. It contains the following data Which piece ...
3
votes
0answers
49 views

Simple single css node parser written in rust

I am new to rust and I wrote a little program that takes a part CSS selector and returns the name of the element and two vectors containing its attributes (classes, ids) Example div#menu.big.pink =&...
11
votes
2answers
150 views

A simple parser generator

I need to parse simple DSLs in a few projects. Since I don't know BNF or other grammars, I figured an alternative would be to use a simple parser generator. I'm looking for improvements to the lexer/...
5
votes
2answers
211 views

C# Logical and Math expression parser

I needed a simple parser that could do both logical and math operations expressed in a string, as well as being able to use variables stored in json. None of what I found online seemed to do all of ...
6
votes
2answers
152 views

Separating data from string representation of objects, with added extras

Given a string representation of data, I want to extract the information into its corresponding object. However, If the string has "|" separators then these should be considered options and ...
3
votes
2answers
32 views

Handle missing children nodes when parsing XML into a dictionary

I work on a code-base that uses xml to set up problems and specify model parameters. I've created a script that I run in tandem with our code. This script will ...
11
votes
3answers
378 views

FASTA-to-tsv conversion script

I worked on a script that takes as input a multi-sequence .fasta file and outputs the number of each aminoacid/sequence in a .tsv...
4
votes
2answers
79 views

Counting Characters from an HTML File with Python

I just completed level 2 of The Python Challenge on pythonchallenge.com and I am in the process of learning python so please bear with me and any silly mistakes I may have made. I am looking for some ...
5
votes
1answer
70 views

URL parser in C

Title should be self-explenatory. This is a simple URL parser I wrote in C. The function takes a URL from the user and produces a struct that contains the information that can be used to request the ...
7
votes
3answers
189 views

parse date and number from API results

I'm slurping up fields from an API that returns an array of fields. Each field in the array is a String that actually contains two separate fields (a number and a date). The number is enclosed in ...
3
votes
1answer
73 views

Parsing a url into host and path

I have a program which splits a url into host and path: ...
2
votes
0answers
39 views

How can I simplify my nom parser?

I'd like a recommendation on how I can improve the function unquoted_string below - specifically is there a better way to combine the parsers I have to achieve the ...
10
votes
1answer
383 views

Python molar mass calculator

I created the following program which takes a molecular formula as an input, eg CH3COOH and returns the molar mass of the compound: ...
2
votes
2answers
104 views

Parse python code, for specific pep8 issues

I am aware, that libraries exist for parsing python code, however, for the sake of learning how they parse errors, I'm creating a script that checks a file for only 6 Pep8 errors just for reference. ...
2
votes
1answer
57 views

Poor man's “about::tracing” for llbuild build time summary in JSON file

I used llbuild ninja build --profile PATH to create a JSON file of build summary in the following format: ...
3
votes
1answer
140 views

Parse selected records from empty-line separated file

This is my first post here and I hope I will get some recommendations to improve my code. I have a parser which processes the file with the following structure: ...
8
votes
1answer
220 views

Making argument parsing more streamlined and readable than if-statements

I am working on an API wrapper for calls to a website. Each of several types of calls can take a large number of optional arguments, some of which contradict. In the interest of preventing the user ...
2
votes
0answers
14 views

Prototype of a scanner/tokenizer for Bitmap Distribution Format parser

Instead of the obvious decision, parsing using given std::io::Lines/std::io::Bytes or crates like nom, I decided to explore ...
1
vote
0answers
89 views

Code refactor - eliminate generic interface and object methods

I'm building a method that tries to detect whether given information about an object's property to retrieve, a constraint operator and some data to compare it against, whether the result is true or ...

1
2 3 4 5
25