Genivia / RE-flex

A high-performance C++ regex library and lexical analyzer generator with Unicode support. Extends Flex++ with Unicode support, indent/dedent anchors, lazy quantifiers, functions for lex and syntax error reporting and more. Seamlessly integrates with Bison and other parsers.
https://www.genivia.com/doc/reflex/html
BSD 3-Clause "New" or "Revised" License
504 stars 85 forks source link

uncaught exception: %option ctorinit with string constant line continuation #183

Closed teshields closed 1 year ago

teshields commented 1 year ago

I tried using a string constant with a line continuation in the ctorinit option and got an uncaught exception:

source:

// L-file lexer constructor specification
%option ctorarg="Lfile_specIO& fR"
%option ctorinit="EOLstate (EOLctx (position (&fR.inName, 0, 0))), \
theFiles (fR)"

error:

libc++abi: terminating due to uncaught exception of type std::out_of_range: basic_string
/bin/sh: line 1: 80210 Abort trap: 6           reflex --debug --full --header-file=reflex/agc-Lfile-internal.hh -o reflex/agc-Lfile-lexer.cc reflex/agc-Lfile-lexer.ll

This would be a nice extension for cases where the initialization is an extremely long string constant.

genivia-inc commented 1 year ago

Hm. Parsing option values by the code generation tool seems to go haywire somewhere. Should be easy to fix.

I agree that line continuations are useful and should be obeyed.

Thanks for sharing to make RE/flex better!

genivia-inc commented 1 year ago

I fixed it in the development version. I can't create an update right now and that has to wait until later, after a week.

genivia-inc commented 1 year ago

I will upload the fixed source code shortly, but can't create an official release yet.