Skip to content

Commit

Permalink
Narrow the interface between Flex and the skeleton file...
Browse files Browse the repository at this point in the history
...and reduce C preprocessor entanglement in the C99 skeleton.
  • Loading branch information
eric-s-raymond committed Oct 25, 2020
1 parent 393b0b5 commit 307645b
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/c99-flex.skl
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ m4_define([[M4_HOOK_EOF_STATE_CASE_ARM]], [[ case YY_STATE_EOF($1):]])
m4_define([[M4_HOOK_EOF_STATE_CASE_FALLTHROUGH]], [[ /* FALLTHROUGH */]])
m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate();
]])
m4_define([[M4_HOOK_CONST_DEFINE]], [[#define $1 $2
m4_define([[M4_HOOK_CONST_DEFINE]], [[const int $1 = $2;
]])
m4_define([[M4_HOOK_SET_YY_DECL]], [[#define YY_DECL $1
]])
m4_define([[M4_HOOK_SET_YYLMAX]], [[#define YYLMAX $1
m4_define([[M4_HOOK_SET_OFFSET_TYPE]], [[#define YY_OFFSET_TYPE $1
]])
m4_define([[M4_HOOK_SET_USERINIT]], [[#define YY_USER_INIT $1
]])
Expand Down
4 changes: 2 additions & 2 deletions src/cpp-flex.skl
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ m4_define([[M4_HOOK_EOF_STATE_CASE_TERMINATE]], [[ yyterminate();
]])
m4_define([[M4_HOOK_CONST_DEFINE]], [[#define $1 $2
]])
m4_define([[M4_HOOK_SET_YY_DECL]], [[#define YY_DECL $1
m4_define([[M4_HOOK_SET_OFFSET_TYPE]], [[#define YY_OFFSET_TYPE $1
]])
m4_define([[M4_HOOK_SET_YYLMAX]], [[#define YYLMAX $1
m4_define([[M4_HOOK_SET_YY_DECL]], [[#define YY_DECL $1
]])
m4_define([[M4_HOOK_SET_USERINIT]], [[#define YY_USER_INIT $1
]])
Expand Down
1 change: 0 additions & 1 deletion src/flexdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,6 @@ extern void out_dec(const char *, int);
extern void out_dec2(const char *, int, int);
extern void out_hex(const char *, unsigned int);
extern void out_str(const char *, const char *);
extern void out_str3(const char *, const char *, const char *, const char *);
extern void out_str_dec(const char *, const char *, int);
extern void outc(int);
extern void outn(const char *);
Expand Down
4 changes: 2 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ int flex_main (int argc, char *argv[])
/* Need to define the transet type as a size large
* enough to hold the biggest offset.
*/
out_str3 ("M4_HOOK_CONST_DEFINE(%s, %s)", "YY_OFFSET_TYPE", optimize_pack(tblend + numecs + 1)->name, "");
out_str ("M4_HOOK_SET_OFFSET_TYPE(%s)", optimize_pack(tblend + numecs + 1)->name);
comment("END of Flex-generated definitions\n");

skelout (true); /* %% [2.0] - tables get dumped here */
Expand Down Expand Up @@ -1307,7 +1307,7 @@ void readin (void)
}

if (ctrl.yylmax != 0) {
out_dec ("M4_HOOK_SET_YYLMAX(%d)\n", ctrl.yylmax);
out_dec ("M4_CONST_DEFINE(YYLMAX, %d)\n", ctrl.yylmax);
}

/* Dump the user defined preproc directives. */
Expand Down
5 changes: 0 additions & 5 deletions src/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,6 @@ void out_str (const char *fmt, const char str[])
fprintf (stdout,fmt, str);
}

void out_str3 (const char *fmt, const char s1[], const char s2[], const char s3[])
{
fprintf (stdout,fmt, s1, s2, s3);
}

void out_str_dec (const char *fmt, const char str[], int n)
{
fprintf (stdout,fmt, str, n);
Expand Down

0 comments on commit 307645b

Please sign in to comment.