Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Use this tag for code that parses its input, or that is source for a parser generator such as yacc or lex.
8
votes
Boolean conversion for fscanf()
Ooh, unit tests! You know how to make me happy!
Let's look at the tests first, as that's valuable documentation of the expected use cases.
A purist might argue that these are not unit tests because t …
5
votes
Natural language text fast tokenizer
Prefer <cstring> to <string.h>
The C compatibility headers should only be used for extern "C" interfaces. For C++ programs, use the C++ headers, which definitely declare identifiers in the std namesp …
5
votes
Natural language text fast tokenizer (Rev.3)
We're missing includes of <locale> and <limits>. It is not portable to assume any transitive includes of standard library headers except those few specifically prescribed in the C++ standard.
This lo …
6
votes
Accepted
INI config loader / saver
We're missing some required header includes:
#include <fstream>
#include <memory>
#include <regex>
#include <string>
#include <unordered_map>
#include <utility>
The code doesn't compile until we …
2
votes
Accepted
Bash menu-driven text file viewer / presenter tool
I don't have time for a full review, but I'll just mention that you seem to have terminal-specific escapes here:
lineColor='\e[0m'
reset="\e[0m";
black="\e[1;30m";
blue="\e[1;34m";
cyan="\e[1;36m";
g …
3
votes
C parser for reading 3D ASCII scene files
Unfortunately the code doesn't compile - perhaps you have some non-portable assumptions?
gcc-14 -std=c23 -fPIC -gdwarf-4 -g -Wall -Wextra -Wwrite-strings -Wno-parentheses -Wpedantic -Warray-bounds -Wm …
2
votes
Accepted
Iterate over a process' maps file
If user code is not supposed to access the innards of a reapMapIterator, it's best to make it an incomplete type in the header, and define it only in the implementation. A small change is needed to t …
2
votes
Accepted
Function to skip characters
I think that's the wrong choice, as conceptually, joining continuation lines is usually the first step in parsing. In either case, we should document this in comments. …
5
votes
Accepted
if you gaze long enough into strtok, strtok will gaze back into you
The tokenise() function is clear and succinct; I can't find anything to dislike. A couple of minor suggestions: wrap the declaration to a shorter line length, and consider changing the interface to t …
4
votes
A very simple config file parser in C++
Everything Edward said; plus some code-level review:
union __int_m_data{
Use of double underscore within an identifier is dangerous. Such names are reserved to the implementation for any purpose ( …
6
votes
Accepted
Advent of Code 2023 day 1: Trebuchet in C (part 2)
It's normal to write main() as the last function, so there's no need to forward-declare getDigts(). We would normally make that function static unless there's a good reason to share it with other tra …
1
vote
Terminal Calculator/Parser Inspired by gcalccmd
Naming
Please don't use ALL_CAPS identifiers for things that are not preprocessor macros:
extern bool CMD_LINE;
static const char *VAL_CHRS = "+-!^*/%.()\n1234567890'",
*OPERS = "+- …
3
votes
Accepted
C key: value file parser
Naming
C reserves identifiers beginning with _ followed by any letter for the implementation, so they should not be defined by user programs.
I can't quite remember whether leading _ is permitted in s …
4
votes
Accepted
C++ string parser for wpa_supplicant
I'll make no comment on the use of C-style <stdio.h>, since that's likely an artefact of the surrounding code, rather than something you'd have written yourself.
A missing header and a typo/oversight …
1
vote
Accepted
C - Argparse (Argument struct)
Includes
The interface needs only <stdbool.h> - the rest of the standard headers only need to be included in the implementation file.
Interface
The declaration isn't very helpful:
struct Argument …