-
Notifications
You must be signed in to change notification settings - Fork 79
Using reflex instead of flex in aprepro_lib
Greg Sjaardema edited this page Oct 18, 2023
·
5 revisions
Steps needed to use reflex instead of flex... Note that there is additional work required to get the Scanner class working. This just gets you some of the way:
- Delete
FlexLexer.h
- In
aprepro_parser.h
: -- Add#include "aprepro_parser.h"
-- Change include ofFlexLexer.h
toreflex/flexlexer.h
-- theint
arguments on LexerOutput and LexerInput aresize_t
-
Rename
echo
todo_echo
-
Add
#undef yyterminate
before#define yyterminate()
-
Add
#undef YY_USER_ACTION
before the#define YY_USER_ACTION
-
Add:
%option namespace=SEAMS
%option lexer=SEAMSFlexLexer
%option lex=yylex
In the /*** Flex Declarations and Options ***/
section.
-
Change
%START
to%s
-
All matching rules need to have the leading whitespace removed... For example,
<VERBATIM>{
"{VERBATIM(OFF)}" { BEGIN(INITIAL); }
[A-Za-z0-9_ ]* |
. { if (echo) ECHO; }
"\n" { if (echo) ECHO; aprepro.ap_file_list.top().lineno++; }
}
Becomes:
<VERBATIM>{
"{VERBATIM(OFF)}" { BEGIN(INITIAL); }
[A-Za-z0-9_ ]* |
. { if (do_echo) ECHO; }
"\n" { if (do_echo) ECHO; aprepro.ap_file_list.top().lineno++; }
}
reflex --bison --flex --outfile=apr_scanner.cc aprepro.ll
This will get you part of the way to using reflex. ¯