Skip to main content
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
Results tagged with
Search options answers only not deleted user 75307

Use this tag for code that parses its input, or that is source for a parser generator such as yacc or lex.

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 …
Toby Speight's user avatar
  • 81.7k
3 votes

Command-line parser for multiple subcommands

I'm also surprised that we couldn't write the optimistic parsing without longjmp() (which most of us avoid because it complicates reasoning about program state). …
Toby Speight's user avatar
  • 81.7k
2 votes
Accepted

Parsing Lists: BIO 2024 Q2

This is clear, well-presented code; much better than the thrown-together hacks often seen as programming-challenge entries. We could perhaps make it even clearer by giving a name to std::function<std: …
Toby Speight's user avatar
  • 81.7k
2 votes

Parsing strings indicating duration in seconds (e.g. "60", "60s", "1m", etc.)

Instead of parsing a double with restrictions, it may be simpler to read 1 or 2 integers separated by . and treat the result as a rational number. …
Toby Speight's user avatar
  • 81.7k
6 votes
Accepted

is_decimal Function Implementation in C++

It would be better if we could pass a locale object to control which parsing rules are used, but that would obviously inhibit constexpr evaluation. … Perhaps we should wholeheartedly jump to the C locale and use our own digit predicate: constexpr bool is_digit(char c) noexcept { return '0' <= c && c <= '9'; } We're constrained to parsing
Toby Speight's user avatar
  • 81.7k
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 …
Toby Speight's user avatar
  • 81.7k
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 …
Toby Speight's user avatar
  • 81.7k
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 …
Toby Speight's user avatar
  • 81.7k
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 ( …
Toby Speight's user avatar
  • 81.7k
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 …
Toby Speight's user avatar
  • 81.7k
6 votes

JVM bytecode instruction struct with serializer & parser

Some style critique from me (the principles seem sound). Since the standard headers are independent of each other, we can include them in a consistent order. I prefer alphabetical, but you could choo …
Toby Speight's user avatar
  • 81.7k
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. …
Toby Speight's user avatar
  • 81.7k
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 …
Toby Speight's user avatar
  • 81.7k
2 votes

Convert number 1-5 from its spelt-out form

I'm not a Javascript programmer, but it looks strange that we return a different type of result for the default case. Can't we return a number (e.g. 0)? Or a NaN? Or perhaps even throw an exception. …
Toby Speight's user avatar
  • 81.7k
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 …
Toby Speight's user avatar
  • 81.7k

15 30 50 per page