Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

re2c scanners on C++ iterator source

Tags:

c++

lexer

re2c

I am attempting to use re2c with input defined with an iterator pair instead of a null terminated string.

From Manual:

YYCURSOR
[...] 
On entry, YYCURSOR is assumed to point to the first character of the current token.
On exit, YYCURSOR will point to the first character of the following token.

This last point means that it is attempting to iterate past the end.

Is there a trick to make re2c work with iterators ? (Other than not using checked iterators.)

like image 499
JonT Avatar asked Mar 22 '23 17:03

JonT


1 Answers

Are you using re2c in the pull model where it calls YYFILL(n) or push model by passing -f?

In the pull model, declare YYFILL(n) to call return when your iterator is exhausted.

In the push model, your iterator loop will dictate when input is done and you won't call into the parser again.

like image 153
WeakPointer Avatar answered Apr 05 '23 21:04

WeakPointer