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.
0
votes
1answer
30 views
Excel-to-JSON parser
I just wanted to build a simple converter from an XLS Excel file to JSON. I have predefined JSON format. All fields except of two - are just simple mapping from Excel to JSON. The two fields have a ...
3
votes
1answer
16 views
Using arrays to read in file, append it with parsed program output and overwrite original
Yesterday a friend of mine asked on U&L: How to optimize 'grep'-and-save?
I will summarise shortly. The output of the torque pbs queueing system tool qstat ...
2
votes
1answer
25 views
Regular expression matching with string slice in Go
I have a slice of strings, and within each string contains multiple key=value formatted messages. I want to pull all the keys out of the strings so I can collect ...
-2
votes
0answers
43 views
How to refactor this monstrous IRC data parser? [closed]
I am participating in open source project and saw monstrous method with 1500 lines of code, full of conditions and cases. The surrounding code is full of code smells.
Moster Method
(No copy the ...
5
votes
3answers
337 views
Parsing a complex number using regular expressions
Requirements were to create a constructor for a complex number, that receives a string. For example: \$3+5i\$. The regex extracts positive or negative numbers from the string with optional decimal.
...
1
vote
0answers
50 views
Email text parser
I am writing a parser to parse out the fields of an email message in the following format (note that I expect that the "To:" field could contain multiple lines, same with the "Subject:" field.
...
3
votes
1answer
27 views
1
vote
1answer
28 views
Finding a delimiting character in a text file
I am writing a program that is capable of reading a matrix supplied from a text file. One intended feature of this program is that it should be capable of detecting various delimiters in the text ...
3
votes
2answers
28 views
Configuring fields to be extracted by a data processor
I solved this problem using closures with Perl and I wonder if/how I could/should have done it differently?
Background:
User creates config file describing properties of some source data file that ...
3
votes
0answers
43 views
Expression parser using Shunting-yard algorithm
I've been working on a expression parser which will be part of another project (some sort of DSL). This parser basically uses the Shunting-yard algorithm, except for the case of parenthesis: here it ...
6
votes
3answers
180 views
Base converting with strings from bases 1 to 36 to bases 1 to 36
I'm writing a fastest-code challenge over at PPCG relating to base conversion of bases 1 to 36, and as a part of the process for writing the competition, I decided to write my own program for it. This ...
3
votes
3answers
76 views
XML parser using PHP
It is just one of the files. I have also tried to write some tests using PHPUnit. Please give me some suggestions to improve my coding-writing skills.
The below is the test file for the above file:
...
2
votes
2answers
42 views
splitting multiple joined words, port from perl to PHP
Though i have never worked on perl, not even once.
I have ported the perl code into PHP and it seems like giving a correct result. But as I am going to use it on production server.
I want this code ...
1
vote
0answers
12 views
Expression parser in Haskell using operator precedence table
This is my first non-trivial Haskell project, an expression parser implemented using the Pratt Parser's technique for managing precedence as a layer on top of Parsec. It simply builds an expression ...
0
votes
1answer
40 views
Parse a string to get a SectorId
In mobile phones technologies, a SectorId is a 128-bit value broadcast by a 1xEV-DO BTS system.
That is a 16 bytes data.
I made a structure to store them:
...
3
votes
1answer
55 views
Reducing memory footprint when manipulating big csv file
I have CSV file which has structure like this (separated by tabulators):
...
7
votes
1answer
62 views
RFC 4180-compliant CSV parser in Java
While looking at a recent question, I realized that there is no CSV parser in the standard Java library. I decided to write one that complies with RFC 4180. Highlights of the standard include:
...
19
votes
5answers
895 views
An OEIS Lookup tool in Python
I'm from PPCG so I was making an esolang and I decided to write it in Python. Eventually it went from an esolang to an OEIS (Online Encyclopedia of Integer Sequences) lookup tool. I'm very new to ...
5
votes
4answers
889 views
2
votes
1answer
50 views
Student data parsing application
My application takes a .csv (comma separated values) file and serializes the data into a binary file. Then it converts the binary file back to a .csv file (identical to the original file).
For ...
6
votes
2answers
91 views
Matrix and Complex Numbers Parser
I have been working on a simple calculator project in Java since November 2014 as hobby. Now I want to add complex number support and Matrices. I also wants to add support for symbolic computation in ...
3
votes
1answer
32 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
78 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
83 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
142 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
57 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
41 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
63 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
84 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
39 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
115 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
80 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
191 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
208 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
1answer
73 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
35 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 ...
5
votes
1answer
56 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
167 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
34 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
54 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
117 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
59 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
115 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
248 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
31 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
118 views
4
votes
1answer
160 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
62 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 ...