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
0answers
4 views
Parsing of a file with non-quoted strings
I have written some Flex and Bison code for parsing a file.
The following is a simplified example of the input file as well as the code used for parsing.
There are a few things I am not satisfied ...
4
votes
4answers
361 views
Program to search many files and remove a certain string
The reasons I create this program is because we had an issue of XML elements showing up with older assembly versions in, which were duplicate elements of the same element with the new assembly version ...
1
vote
0answers
39 views
Numeric parser for integers, big integers, and doubles
I have written the following numeric parser. It may not be as fast as Boost's lexical_cast, nor as convenient, but it does get the job done and it does look good. I'...
5
votes
1answer
69 views
Track hours worked total or per month
I track the hours that I have worked on something in an Excel sheet (actually Google Spreadsheet, but semantics). This is tracked in the following format:
Date | Start (time) | End (time) | ...
4
votes
0answers
89 views
Parsing simple log files in Julia vs Python
I wrote a log parser in Python and Julia. The Python version takes about 8 seconds to process 350 files, while the Julia version takes about 8 seconds to compile, after which it takes over 20 seconds ...
1
vote
1answer
51 views
Generating a sequence number based on last item of a list
I wrote this method in order to generate a sequence number based on a specific pattern:
...
1
vote
0answers
46 views
Parsing the first two command-line arguments and extracting the remainder
My program can be called like this:
FakeDpi someInteger someExecutable [parametersForSomeExecutable]
For example:
...
1
vote
1answer
50 views
Flexible String tokenization in Swift
I want a flexible and fast way to break a string up into strongly typed tokens so that I can do things like the following:
...
4
votes
3answers
160 views
Convert a numeric string to number but without python's built in function
I'd like to get a code review and some insights of whether I chose a good way to do this. What would other, clever ways look like.
...
1
vote
1answer
189 views
Parsing string and extracting meaningful information
A message can contain an user name or group name, the user name has to be 2 character long and should contain uppercase ASCII characters only, similarly group name ...
10
votes
3answers
466 views
Using Python to tokenize a string in a stack-based programming language
As an avid user of esoteric programming languages, I'm currently designing one, interpreted in Python.
The language will be stack-based and scripts will be a mix of symbols, letters, and digits, like ...
1
vote
1answer
44 views
A push style parser combinator in Haskell
Usually, parser combinators in Haskell based on the parser type like
newtype Parser t r = Parser ([t] -> [(r,[t])])
This allows back tracking and multiple ...
2
votes
0answers
123 views
Node Server Pages
I wrote a small script that lets you run node.js inside .html files (the same as PHP). CGI-Node already does this, but uses CGI rather than FastCGI, which doesn't work with Nginx. Here's my code (...
4
votes
3answers
60 views
Getting the Twitter account from various input formats
I have an input for users to enter a Twitter account in any different way and I want to extract the user account.
For example:
...
0
votes
4answers
100 views
Parsing and summarizing an aviation METAR (US) report
I have a list of objects, which contains field rawData (eg rawData="KLAX 141353Z 06003KT 6SM BR FEW002 FEW008 BKN280 12/12 A3007 RMK AO2 SLP182 T01170117 $"). In my ...
6
votes
1answer
30 views
Parsing a key=value config file for a Python FreeCell game
I'm new to Python, and my first serious project was a FreeCell game. The game works, with lots of options to combine moves, save games, load them, etc. But I skimped on some specifics of Python. In ...
4
votes
1answer
32 views
Deserializer in ruby
Given a serialized hash of any depth in string format, convert it into a hash object.
I want to know if my approach is correct, I am capturing states and storing the results in a stack and generating ...
5
votes
1answer
139 views
Translating an inputted query to SQL
I'm working on a small RestApi that would be able to:
Interpret different query languages like ...
5
votes
1answer
61 views
Converting a 12h clock to 24h clock
I started picking up Rust on my free time, and I'm curious about what style errors have I made and where should I improve as a programmer.
The problem is from HackerRank and very simple: there is a ...
4
votes
0answers
44 views
Parsing my JSON-like format in C
For the past few weeks, I've been using the wonderful cJSON to add content to my game. But recently, I got tired of JSON's verbosity so I decided to roll my own format called SON (Simple Object ...
4
votes
1answer
51 views
From a string of 3 numbers to 3 integers
I'm solving some puzzles to learn Rust. A problem I faced is to turn a string of 3 integers into 3 integers. I succeeded with the following example:
...
5
votes
1answer
52 views
What is the idiomatic Rust way to write this naive JavaScript token scanner code fragment?
I am learning Rust and finding it quite a difficult but rewarding and fun challenge to learn how to write idiomatic and succinct, clean code in it.
I have written the following simple naive ...
5
votes
2answers
38 views
Parse Run Length Encoded file for cellular automaton data
I wanted to be able to parse Run Length Encoded (*.rle) files into something usable for a cellular automaton simulator (e.g. Conway's Game of Life and such).
Here ...
5
votes
2answers
249 views
Genotype as input, give the phenotype
I want to write a Python script where the input is a genotype (e.g. "CCDd") based upon the following Punnett square. The output should be the phenotype (e.g. "seal").
My code works, but doesn't look ...
6
votes
2answers
471 views
PrimitiveParser
This class has the responsibility of parsing a string to one of the primitive types: int, double, ...
2
votes
0answers
34 views
5
votes
2answers
115 views
Optimize shunting-yard algorithm
Following your suggestions, I updated my expression evaluator with a Shunting-Yard algorithm.
I've created two classes, a Shunting-yard class and a RPNsolver class.
The first I mentioned converts ...
2
votes
1answer
127 views
Remove comments from C-like source code
I am working on the problem of removing comments from C-like source code. Here is my code in Python 2.7, and if anyone could advise improvement areas (especially performance), or any functional bugs ...
7
votes
1answer
99 views
Math expression evaluator
It is my second attempt to make a math expression evaluator.
To evaluate an expression, I created a class that works like this:
-it removes all the blank spaces
-if brackets are present, it ...
4
votes
2answers
51 views
Parsing an XML file with elements for keys and values
I'm parsing an XML file that is structured like this:
...
2
votes
2answers
57 views
Linear quation system solver
I've done an equation system that takes as input the equations (you choose the number of equations), and gives as output the values of the unknowns.
I splitted the code in four files:
-equation ...
2
votes
1answer
45 views
Finding an arbitrary word in a string of words given an offset
Background
Given a string (s) and an offset into that string (offset), find the whole word that can be found at the given ...
8
votes
2answers
101 views
Parsing cron expression
I'm building my own scheduler and I took the first step by creating a cron expression parser.
To test it I used this expression to cover each case. (I guess the 52W is wrong but this doesn't matter ...
4
votes
1answer
61 views
Python Hex Viewer
I have created an hex viewer in python, as a timed-challenge by friend. My implementation was in the form of a class, with a separate main file running with ...
3
votes
0answers
35 views
Sorting upcoming events listed in JSON
I've written my first program in GO, a command line tool that parses JSON containing events from a file or from STDIN and outputs the upcoming events in sorted order. Please critique it!
...
0
votes
0answers
14 views
Wyld: Lightweight Javascript tool for creating input-output mappings
I've created a lightweight library for handling input-output mappings by just using a "configuration" object as the map.
Here's a snippet of the README:
To create a direct mapping from an exact ...
5
votes
2answers
381 views
Small part of an INI parser
I know there are probably thousands of INI parser implementations in C.
Nevertheless I want to implement one to learn the art of parsing grammar.
I just wrote a small piece of the INI parser and ...
4
votes
0answers
33 views
Parsing BibTeX in JavaScript
I have a project for which I need to parse BibTeX strings. In v0.2.9 and before, I used Regex, and I want to change that. I set up a while loop system that reads ...
3
votes
2answers
96 views
Delimited File Reader
UPDATE: I have refactored the code into a Gist using @Dmitry's answer as a guide. The update is much simpler to grok, implements IDisposable, and is roughly thirty ...
4
votes
2answers
97 views
Matching maximal nodes with velocities
I have written a code which works very good for small data-files (see below). The data file 'WSPL.dat' which I want to evaluate has a size of 2.6 GB and the data file 'VELOC.dat' has a size of 4.3 GB....
3
votes
0answers
26 views
Converting a sentence string to a number in Scheme
I wrote a scheme procedure that converts strings such as "Two hundred and fifty" into a number like "250" that I can use in math calculations (It's for some Natural Language Processing project).
Is ...
1
vote
3answers
56 views
Look for patterns in the keys of an array, to group them in a new array
I am working on a function that will take a an array of options. These options are retrived from a database, and could have other options inputted throughout the system. When adding my options, I am ...
2
votes
1answer
144 views
Analyze Shakespeare's Macbeth parsing XML from web using Nokogiri
This is a simple Ruby program to analyze the number of lines characters speak in Shakespeare's Macbeth using Nokogiri and open-uri to parse a given url containing xml. I wrote this as practice getting ...
4
votes
2answers
74 views
Tokenizer building blocks: tokens and spans
In a completely overkill BrainFuck lexer/parser I've presented the lexer, parser, interpreter and syntax tree classes. With this post I'd like to go over the lower-level ...
15
votes
2answers
3k views
A completely overkill BrainFuck lexer/parser
I'll need to build a syntax tree (AST) for Rubberduck, but since VBA has dozens of tokens and complex rules, I needed a simpler language to play with first, so I thought BrainFuck would be a perfect ...
5
votes
2answers
59 views
Get a floating point number from a string with a finite state machine
I wanted to restart the big-float project I had paused the moment I suddenly realized that the implementation of the main four rounding modes (which I postponed so long, that I got all of the IEEE-754 ...
3
votes
3answers
109 views
1
vote
2answers
163 views
Swap first and last name in C
I took an entire line of input in the form of a string, and tokenized the string into substrings and obtained the first string as the first name and the second as the last name. This program as it ...
0
votes
0answers
29 views
Text parser in Python 2.5
I wrote a text parser which generates a necessary file. Python 2.5 is used because the code was mostly written and tested on my old Nokia with Python 2.5 onboard.
Parser designed to project - scummvm
...
-1
votes
1answer
55 views
Construct: (un)dumping bytes to hex
This code is part of the Construct library. Docstrings explain what the code is supposed to do.
...