Hot answers tagged

8 votes

Thread-safe strtok in C

Since this is not a drop-in replacement of strtok, which iterates token, but only allows a complete tokenization of a string, I'd not expose ...
vnp's user avatar
  • 56.2k
7 votes
Accepted

Natural language text fast tokenizer

Avoid using char* C++ provides much nicer and safer ways to deal with strings and string slices than C's char*. Before C++17, I ...
G. Sliepen's user avatar
6 votes

Thread-safe strtok in C

Significant semantic differences from strtok() I decided to practice and write a thread-safe version of the same function. Yours is not "a thread-safe ...
John Bollinger's user avatar
6 votes

Thread-safe strtok in C

You don't need the inclusion of stdlib.h in com_github_coderodde_thread_safe_strtok.h. For the definition of ...
Harith's user avatar
  • 3,969
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 ...
Toby Speight's user avatar
  • 74.4k
5 votes

Natural language text fast tokenizer

Prefer <cstring> to <string.h> The C compatibility headers should only be used for ...
Toby Speight's user avatar
  • 74.4k
5 votes

Advent of Code 2023 day 1: Trebuchet in C (part 2)

Do not trust user input: If there were no arguments supplied, argv[1] would be NULL, and the call to ...
Harith's user avatar
  • 3,969
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 ...
Toby Speight's user avatar
  • 74.4k
4 votes
Accepted

Natural language text fast tokenizer (Rev.5)

Enable compiler warnings and fix them When developing code, always enable rather strict compiler warnings (for example, using -Wall -W -pedantic for Clang and GCC, ...
G. Sliepen's user avatar
4 votes
Accepted

Natural language text fast tokenizer (Rev.4)

It doesn't output the last token Your own demo shows that it is not printing the last token .... Missing test suite You should create a test suite that tests your <...
G. Sliepen's user avatar
4 votes
Accepted

Natural language text fast tokenizer (Rev.3)

Answers to your questions Concerns The only place I still don’t like is this calculation of offset in operator++(), but I can’t see the better way: I think it's ...
G. Sliepen's user avatar
3 votes
Accepted

Natural language text fast tokenizer (Rev.2)

I've make a partial review below. It's only partial, because it's become clear that the code is a bit too much work in progress. Not only the formatting, but also the correctness. Further, that also ...
uli's user avatar
  • 1,515
2 votes
Accepted

Simple Python text file Parser and Converter

Naming Method/function names, parameters, and variable names should be snake_case Parser.parse This doesn't have to be a ...
C.Nivs's user avatar
  • 2,887
2 votes
Accepted

Evaluating Polish Prefix Notation and Polish Postfix Notation

operator module OPCODES = { "+": lambda lhs, rhs: lhs + rhs, ... The lambdas are nice enough, they get the job done. We could have just mentioned ...
J_H's user avatar
  • 21.9k
2 votes

Evaluating Polish Prefix Notation and Polish Postfix Notation

Testing the first and last tokens is very dubious. It rejects a perfectly valid expression 42, and accepts definitely invalid expressions like ...
vnp's user avatar
  • 56.2k
4 votes

Thread-safe strtok in C - version II

Reconsider token_t This is currently a linear linked list of tokens, surprising given the name. A strictly-evaluated linear linked list isn’t an efficient data ...
Davislor's user avatar
  • 6,706
2 votes

Multithreaded natural language text parser (Rev.2)

About your feedback Taking into account a huge size of data, the slowest thread shouldn’t be much slower that any other as they have almost the same amount of lexems on average; The problem isn't ...
G. Sliepen's user avatar
2 votes

Multithreaded natural language text parser

Answers to your questions The main question if the approach correct at all. First of all, it the idea of chunking the best one or something better (heaps?) could be used? It is a rather naive ...
G. Sliepen's user avatar
1 vote

Simple Python text file Parser and Converter

pass class ParserInterface(ABC): @abstractmethod def parse(self) -> None: pass At the end there we had to write ...
J_H's user avatar
  • 21.9k

Only top scored, non community-wiki answers of a minimum length are eligible