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.
4
votes
1answer
64 views
Converting string to dict using Python ast library
I have been trying to convert a string of dictionary objects as given below
...
3
votes
3answers
46 views
Parsing an ExpandoObject into a typed class using reflection
I've spent some time writing a library to parse JSON into a statically typed object. Am I following most of the standard coding guidelines? Any thoughts on what I could do better, or any edge cases ...
6
votes
2answers
64 views
Parsing mathematical expressions in Reverse Polish Notation
I've wanted to make a calculator for a long time now, so I wrote one of my first parsers, where the input is in reverse polish notation, \$1 \ 1 +\$ becomes \$2\$.
It supports to following operators; ...
1
vote
3answers
74 views
Implementation of IpV4Address
For legacy reason (guys here LOVE immutable object), I need a struct that contain an IpV4.
I can't use System.Net.IPAddress because it's not a struct.
So far here what I got:
...
6
votes
2answers
50 views
Parsing BibTeX files in Java
As part of a larger project to generate a website with a personal list of publications, I implemented a parser for BibTeX files.
The entry point is the parseFile ...
13
votes
3answers
281 views
Lexer for C- in Python
I am currently taking a compilers course where we are designing a compiler for C- (which is a subset of C). Our first step was the lexer and I have written that but I believe that it is not very ...
6
votes
0answers
28 views
Perl parsing code
I've extracted a subroutine from some perl code I've written. (I also included the use enum line for easy reference.) Its purpose is to parse the given code, ...
5
votes
2answers
50 views
Process text file of fulltext articles from news publications
I'm relatively new to programming and have started writing some code for work. This script is something I wrote that I'd like to have someone comment on. Am I doing anything silly, stupid or totally ...
4
votes
2answers
71 views
Parsing mathmatical functions
I have finally finished a Ruby calculator project, which is not based on eval. Instead it parses input char by char. The project is hosted on GitHub.
However, I find a specific part of the program ...
2
votes
2answers
41 views
K&R atoi() variation
I'm currently learning C with The C Programming Language by K&R and this is my current exercise:
Rewrite appropriate programs from earlier chapters and exercises with pointers instead of array ...
4
votes
3answers
138 views
Extracting a database name from a file
I am developing a project that converts SQL server file to MySQL file based on some assumptions. I have written a function that takes the string source as input and it extracts the database name. Is ...
7
votes
3answers
148 views
Parsing pipe delimited lines
I am parsing the following line of code via a specific format.
Line is:
S|111111|87654321|Bar UK|BCreace UK|GBP|24/08/2010|
The Format is:
...
3
votes
2answers
56 views
C - K&R getint() variation
I'm currently learning C with "The C Programming Language" by K&R. At the moment I'm at the chapter about pointers (since I come from Java, they are new to me). In the book is an example code for ...
1
vote
0answers
63 views
Parse a plain text newsletter and show it with nicer markdown formatting
I wrote some code to parse an e-mailed events newsletter I'm on and redisplay it with better formatting. I like the output, but I'm not thrilled with the code. It feels like there's a lot of ...
4
votes
0answers
47 views
Android XML parser to parse themes
I used XML to control the theme of an InputMethod for Android. A theme in XML contains the color and the shape of keys.
XML file
...
6
votes
2answers
69 views
Text tokenizer example
Here is a partial example of a text tokenizer. I'm looking for ways to improve one particular line in this code:
...
5
votes
0answers
163 views
JSON parser in C#
I've writen a C# JSON parser, but its performance is not as good as JSON.NET.
Running the same test, my parser takes 278 ms and JSON.NET takes 24 ms. What should I do to optimize it? It seems that ...
3
votes
2answers
39 views
Advanced CSV-to-SQLite converter
I just wrote an advanced CSV parser that translates CSV to SQL(SQLite Compatible) statements, which are then inserted into the database. It translates variable names in the CSV to values defined in ...
6
votes
1answer
86 views
Cleaning up HTML created by users
I have a system that accepts free text from users. This can either be plain text or a heavily limited subset of HTML. I've written the below with Html Agility Pack and Microsoft's AntiXss library. I ...
6
votes
1answer
108 views
JavaScript program to count lines of Java code
I've implemented a small program in JavaScript to count the number of lines of a string of java source code.
This was done for one of the Code Kata exercise: ...
4
votes
1answer
61 views
Python tokenizer in Haskell + Parsec
I wrote a tokenizer/lexer (difference?) for Python in Haskell: this is my code on GitHub.
I already tested it out with some of CPython's standard library scripts, and it doesn't fail. However, it ...
8
votes
2answers
180 views
Parsing a list of single numbers and number ranges
I have input of a string containing a single number (like: \$3\$) or a range (like: \$1-5\$). Sample input, all together, looks like: "1-5,3,15-16", and sample ...
6
votes
1answer
60 views
Manually parsing HTTP response header
Due to some constraints I had to manually parse an HTTP response coming out of a stream.
I could not use buffered reader or scanner because the perform buffering and end up buffering bytes beyond the ...
5
votes
2answers
289 views
E-mail MIME message parser
As part of a larger Java application I'm working on, I have to retrieve emails and parse the data for the emails' content (subject, date, text, attachments, sender). In the method below, I pass a ...
5
votes
1answer
72 views
Parse OpenFoam files in Python
I'm writing a Python parser for OpenFoam mesh files. When the mesh is big, I face performance issues.
Here is the format of the file describing the points:
...
-1
votes
2answers
62 views
Extracting a date and time from a log file
I am trying to make my code as legible as possible, and today I wrote the following snippet and I'm unsure as to whether it can be improved in an obvious way. There's always room for improvement, of ...
1
vote
1answer
26 views
Quickly passing and parsing variable length float arrays
I have this code for parsing for parsing a list of floats of variable length.
...
1
vote
0answers
89 views
Game server in Java querying MongoDB for JSON
I was hoping someone would have a look at how I retrieve the questions from the db, parse the JSON and process the results - possibly advise how I could improve efficiency by streamlining my code. I ...
4
votes
1answer
90 views
Obtaining different weather forecasts from the Environment Canada website
Here is the code I use to get the different weather forecasts from the Environment Canada website:
...
5
votes
3answers
637 views
Function that adds two integer strings
I wrote this method that adds two integers in the form of strings together. This way I can add large integers without overflowing.
How efficient is the code that I wrote? I am by no means a great ...
1
vote
2answers
123 views
Parsing double from string
I'm trying to parse Double from String in Java. The string input is not necessarily a number, any non number input should be ...
5
votes
1answer
78 views
Parsing and plotting complex numbers
I am trying to write a Haskell application that parses a bunch of complex numbers from a Mathematica output and then produces a PPM image.
The end product looks like this:
The code to create this ...
2
votes
1answer
68 views
Parsing a component of a regex followed by an optional quantifier character
I have a piece of parsec code that parses a unit optionally followed by ?, + or ...
6
votes
1answer
102 views
High performance parsing for large, well-formatted text files
I am looking to optimize the performance of a big data parsing problem I have using Python. The example data I show are segments of whole genome DNA sequence alignments for six primate species.
Each ...
10
votes
4answers
853 views
Method to count all comments in single external C# file
I recently had an interview question:
Write a method that counts all comments in a single external file.
It was a timed question and I wanted to know if this is the best way to accomplish the ...
2
votes
1answer
82 views
File parser to extract data from text file
I am trying to extract the data from input file and store it for plotting.
I have tested this code for a few files of same format. I am not sure if the code works correctly with the little change in ...
2
votes
3answers
185 views
Reading a configuration file
I have written the following C code to parse a configuration file for settings to my program. I denote comments with a # and blank lines are allowed. e.g.:
...
10
votes
2answers
109 views
Processing command line parameters
This code works, but I'm curious what feedback you have about style and doing things in a more "pythonic" way.
...
20
votes
4answers
257 views
Convert Bitmap Font to Texture Atlas
I wanted to render the textures that comprise a bitmap font glyph onto the screen directly as an Image in libGDX. When you make a bitmap font using a program (such ...
1
vote
0answers
42 views
Parsing span library
This is a Python library for efficiently tracking span information while parsing source code, and generating errors on those spans.
I intend to use it in my rewrite of mypy's Python parser to add ...
1
vote
2answers
53 views
Function that check's file type based on certain keywords
I have a function that breaks up a source file and checks each token against a keyword list to determine whether its a particular file type. How can I improve this function? ...
4
votes
1answer
94 views
XML parsing in Java using SAX parser
I have started learning XML parsing in Java (currently reading Java & XML by Brett McLaughlin). Here is my first program to parse XML using SAX parser. Please review the code and let me know if ...
10
votes
2answers
106 views
File parser convert to node data and neighbouring relational data
I have been working on a file parser that takes a very specific file format and parses it into a list that is arranged into node data and the neighbors that it relates to. I am new to Python (this is ...
7
votes
1answer
63 views
Python XML parsing, extraction and renaming files
I've written some code to:
Parse an XML file.
Extract some strings.
Make copies of the original XML whose names are suffixed with the extracted strings.
Please review this.
...
10
votes
1answer
132 views
Rust language tag implementation
language-tags is my first crate, it is hosted on GitHub and I uploaded it to Crates.io. It parses language tags like en-US into useful parts, like language and ...
6
votes
1answer
74 views
Templated Tokenizer Functions
I wanted to be able to tokenize a few different containers so I created a generic way to do it. I originally wrote this in Visual Studio 2012, but I had to modify it to get it to compile on Ideone.
...
4
votes
1answer
53 views
Find allele frequencies at each site for each iteration for each population from FASTA file
The script takes a FASTA format file in input and outputs the frequencies of each amino acid (A, C, ...
2
votes
2answers
92 views
Parsing a text file of node data into Nodes and Edges
I'm a fairly new developer (well, engineer really, but currently working on a software project). In the Android project I'm working on, I read a node representation of a map into my app and interpret ...
8
votes
3answers
79 views
Calculating bytes of code
I am new to Perl and I wrote this Perl script to calculate bytes of code and lines of code in a directory. I want to know if there are any improvements that can be made to it.
...
4
votes
3answers
375 views
Parsing huge data coming from a URL
I need to parse the data coming from the URL which looks like this:
...