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.

learn more… | top users | synonyms (1)

3
votes
1answer
17 views

Terminal ESC Sequence Decoder

The goal of this code is to read-in a stream of terminal ESC sequences, and break them down and fill a vector of parameterized sequences for processing later on. For example ...
7
votes
2answers
63 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 ...
3
votes
1answer
74 views

Parsing data from text with repeating blocks

I am parsing the responses from our Varnish load balancers in order to monitor the status of various nodes. One of the responses we get is text consisting of multiple blocks of data, one for each ...
2
votes
4answers
133 views

Consecutive whitespace reduction

I pursued an according algorithm with an absolute best performance, the following class embodies the solution. Any comment is welcome. ...
0
votes
0answers
47 views

Calculator in Node.JS

I'm new to parsing, and there's only one way to learn anything, and that's to do it yourself. So I did. I wrote what is essentially a calculator. But instead you will send it a string and it will be ...
4
votes
1answer
37 views

Multiple base numbers parser

This code is a Parser that parses numbers according to R5RS. #b1001 - binary #o2127 - octal #h02d - hexadecimal #d1231 - decimal 3923 - decimal It is ...
7
votes
1answer
57 views

Assembler listings parser components: Operands parser

I'm building the above mentioned parser. It reads a string of assembler instructions. I want to become a better coder, so I wanted to get a code review to start learning to do things property. As we ...
6
votes
1answer
70 views

Somewhat Advanced C++ Calculator

I am currently in the process of learning C++ from C++ Primer. I have found the exercises in this book to be somewhat dull in that they only test syntax and not reasoning. As such, I have recently ...
3
votes
1answer
33 views

Bash function to parse git status

I have a function here and wondered how well this can be refactored. I currently have this: ...
5
votes
1answer
36 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 ...
4
votes
1answer
107 views

Parsing a string to extract values

I am writing some C# that will be running on Linux and will extract values from a kernel generated system file that represents readings from a sensor. The file contains two lines of text, and I have ...
4
votes
3answers
77 views

Load recurring (but not strictly identical) sets of Key, Values into a DataFrame from text files

I am reading text files that contain data from observations. The format is not Fixed Width or Delimited, so I built a generator ...
1
vote
1answer
47 views

Collating creature descriptors spread across multiple stanzas

I have been using Python for only a few days, so I am trying to learn about some best practices. An explanation of what this code is supposed to do is at the bottom of this post. It is an exercise to ...
7
votes
2answers
163 views

Removing curly braces and contents inside it

Lets say I have a string like this: string s = "A }{ B { C } }{" //Indexes: 0123456789ABCDE Just consider the indexes beyond #9 are 10,11,12,13, and 14 ...
3
votes
2answers
200 views

Parsing “mailto:”

Can you help me to review my "mailto:"-parsing function ? Since I'm trying to write less code, that is as simple as possible. I'm not sure there if there is some bug or better solution. ...
2
votes
0answers
62 views

PHP class for reading DTD

A very long time ago, I started development of a code generator for HTML. And some time ago I rewrote it and published it under LGPL v3.0 on Sourceforge.net. It is very universal because one of its ...
5
votes
1answer
32 views

Function to get specified key from /proc/cpuinfo

On Linux, the file /proc/cpuinfo returns a set of key-value pairs, where the key and value are separated by a colon and each pair has its own line. It's a bit more ...
6
votes
1answer
50 views

VCF parser for eventual genomic data visualization

I've just started out writing an app that will visualize genomic data for anybody to understand. When you get your genome sequenced the raw data usually comes in the form of a VCF file. I started out ...
5
votes
1answer
154 views

Basic arithmetic operations for a programming language

I have written a set of functions to compute basic mathematical operations for my own Java-based programming language. First I tokenize input from the source code file and store it in a String array. ...
3
votes
0answers
28 views

CIDR Notation parser

I created the following code to better understand CIDR notation. Also to learn some of the Stream features in Java8. I posted my unit tests too. I'm interested in ways it might be improved ...
5
votes
0answers
48 views

Error Handling for XML parser

I have the following Ruby code, which parses an XML document sax style (it's a very simplified version): ...
11
votes
2answers
111 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 ...
5
votes
1answer
43 views

String parsing and saving ipaddress to file in Java

Following function will parse string resp, which will be like shown in following example. I will get an IP address in the form of a hexadecimal string like ...
8
votes
3answers
97 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 ...
10
votes
3answers
242 views

Parsing expression with exponents and evaluating

I'm programming a basic command line calculator in java that can parse expressions and evaluate them, does not handle brackets yet. For example an expression: \$9+9/2^2*5-1\$. At this point I can ...
3
votes
0answers
26 views

Erlang linter written in Erlang using erl_lint:module

I've just started learning Erlang. Since my editor of choice doesn't have a syntax checker for Erlang, I decided to use the parser/linter in the standard library to make a standalone script. It works ...
7
votes
2answers
116 views

Usage of scanner

I have a legacy method which I would like to clean up: ...
4
votes
1answer
153 views

Solution to part 1 of Day 7 Advent of Code in Scala

Does someone want to review my solution to part 1 of Day 7 Advent of Code in Scala? The assignment is here: http://adventofcode.com/day/7 Without repeating the whole text, in short: Given a text file ...
2
votes
1answer
51 views

jQuery replace text with HTML plugin

I've written a jQuery Plugin which searches text & replaces it with other text or HTML. Now everything works quite well but recently I came across this SO question where the OP could have use of ...
3
votes
2answers
118 views

Lexer for C# source code

This code reads a .cs source file in the \bin folder and parses the C# code in it. The program outputs keywords, identifiers, separators and numerical constants. How could it be improved? ...
2
votes
1answer
26 views

Converting fraction notation in strings to a Rational data type

I've been messing around with a RationalInt type, using a simple int-based structure for the time being. I've created code to ...
9
votes
1answer
80 views

Tokenize s-expressions in Rust

I'm writing an s-expression tokenizer in Rust. I have the following code written, but it is not idiomatic Rust - it is quite ugly. TokenizerI is simply an ...
3
votes
2answers
42 views

Return the first number found greater than the provided input number (13 digits)

This script converts the numbers to be at least 13 characters long (for UNIX_MS strings). For use with timestamps, I'm having issues with it being very slow. I wanted an alternative to grepping for ...
2
votes
3answers
77 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. ...
3
votes
1answer
34 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
2answers
106 views

Parsing from one enum to another

I face a problem I think I am not approaching appropiately. I have two independent enumerators that both will contain the same members, the only difference being the values given. I have to be able ...
8
votes
2answers
76 views

Port of NLTK tokenizing code from Python to Rust

I'm working on a port of NLTK to Rust. I am fairly new to Rust, so I wanted to post a small file to check if I was writing idiomatic Rust. I've included the original Python. The Python has docstrings ...
3
votes
0answers
58 views

Infix to Postfix Formula Parser Java

I've written a program that takes a mathematical formula as an user input and converts it from infix to postfix. It doesn't support negative numbers. The program doesn't depend on the user having to ...
1
vote
1answer
60 views

C# Parser of strings with list of assignments

I have implemented class which manages communication with measuring device, which sends list of assignments, like variableName=value. These assignments are always ...
1
vote
0answers
59 views

Parsing JSON with generics

I get back two dictionaries, I need to parse through them and put in an array two objects. I think I did a very poor job and I have a feeling there is a better way to make the code more compact and ...
1
vote
1answer
59 views

Java XML parsing

I am attempting to create XML forms using user input to populate certain areas that would appear when loaded into a STIG viewer. Right now everything is working enough for me to create this and have ...
4
votes
1answer
63 views

Parsing a command line

I've written an object which allows parsing and serializing a command line. I don't in any way consider this done, but this is the beginning of it. I know there are other implementations out there ...
4
votes
2answers
44 views

Compare Two Files

One of the K&R exercises is to write a small piece of software to compare two files and print the first line in which they differ. Here is my attempt: ...
3
votes
1answer
52 views

Simple CFG parser in C++

I have written a CFG (text file) parser for my specific needs. I have found other libraries to be much too large. Even other parsers that bill themselves as "simple" run hundreds of line long. The ...
4
votes
1answer
44 views

Word Counter Project

I recently read K&R The C Programming Language and wanted to write a small program to count the occurrence of each word in the input (std-input - I piped a file with all shakespeare pieces in ...
4
votes
2answers
108 views

Read firewall logs

I am still a Python beginner and would appreciate some help with this code. I am looking through some firewall log files, more specific all lines with Deny in them. For those files I am extracting ...
0
votes
1answer
31 views

Parsing an uploaded file, returning record of 10 fields for each line [closed]

I have a program that reads a .txt file from a given directory. Each record line contains a data and I am parsing it. I think this is costly with it comes to performance but I might be wrong. Here is ...
3
votes
1answer
69 views

Lazy attoparsec parser for log files

I've written a parser with the help of some experienced Haskellers. The parser is not bad, but the same kind of parser written in PHP7 with regular expressions is much faster (takes 25% of the time ...
2
votes
0answers
27 views

Haskell s-expression parser and quasiquoter

There are a number of questions on this site about s-expression parsing: e.g., Calculator parsing S-expressions and Code from "Write Yourself a Scheme in 48 Hours" tutorial. However, these ...
4
votes
3answers
221 views

Using argparse with parameters defined in config file

I understand that and why using eval is generally considered bad practice in most cases (see e.g. here). Related questions on config files and argparse don't use ...