summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvern <vern>1995-03-05 20:37:26 +0000
committervern <vern>1995-03-05 20:37:26 +0000
commit904d8d2b8f8b11743967cf75741c8086f64206cc (patch)
tree7e83016ea89debafd3bed0505ee48865687fde4f
parent8afe518ac26bbc147e2864c8433b8dc3fdd0fcf8 (diff)
downloadflex-904d8d2b8f8b11743967cf75741c8086f64206cc.tar.gz
added yyclass
-rw-r--r--flexdef.h5
-rw-r--r--main.c23
-rw-r--r--scan.l3
3 files changed, 26 insertions, 5 deletions
diff --git a/flexdef.h b/flexdef.h
index 68cc29b..9fd28b6 100644
--- a/flexdef.h
+++ b/flexdef.h
@@ -26,7 +26,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-/* @(#) $Header: /cvsroot/flex/flex/flexdef.h,v 2.50 1995/03/04 18:06:51 vern Exp $ (LBL) */
+/* @(#) $Header: /cvsroot/flex/flex/flexdef.h,v 2.51 1995/03/05 20:37:43 vern Exp $ (LBL) */
#include <stdio.h>
#include <ctype.h>
@@ -406,6 +406,7 @@ extern int yymore_really_used, reject_really_used;
* outfilename - name of output file
* did_outfilename - whether outfilename was explicitly set
* prefix - the prefix used for externally visible names ("yy" by default)
+ * yyclass - yyFlexLexer subclass to use for YY_DECL
* do_stdinit - whether to initialize yyin/yyout to stdin/stdout
* use_stdout - the -t flag
* input_files - array holding names of input files
@@ -428,7 +429,7 @@ extern const char *skel[];
extern int skel_ind;
extern char *infilename, *outfilename;
extern int did_outfilename;
-extern char *prefix;
+extern char *prefix, *yyclass;
extern int do_stdinit, use_stdout;
extern char **input_files;
extern int num_input_files;
diff --git a/main.c b/main.c
index 006cfc9..0dd3ff0 100644
--- a/main.c
+++ b/main.c
@@ -32,7 +32,7 @@ char copyright[] =
All rights reserved.\n";
#endif /* not lint */
-/* $Header: /cvsroot/flex/flex/main.c,v 2.56 1995/03/05 16:37:51 vern Exp $ */
+/* $Header: /cvsroot/flex/flex/main.c,v 2.57 1995/03/05 20:37:53 vern Exp $ */
#include "flexdef.h"
@@ -66,7 +66,7 @@ char *action_array;
int action_size, defs1_offset, prolog_offset, action_offset, action_index;
char *infilename = NULL, *outfilename = NULL;
int did_outfilename;
-char *prefix;
+char *prefix, *yyclass;
int do_stdinit, use_stdout;
int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE];
int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
@@ -576,6 +576,7 @@ char **argv;
performance_report = 0;
did_outfilename = 0;
prefix = "yy";
+ yyclass = 0;
use_read = use_stdout = false;
sawcmpflag = false;
@@ -965,8 +966,22 @@ _( "Variable trailing context rules entail a large performance penalty\n" ) );
}
if ( C_plus_plus )
+ {
outn( "\n#include <FlexLexer.h>" );
+ if ( yyclass )
+ {
+ outn( "int yyFlexLexer::yylex()" );
+ outn( "\t{" );
+ outn(
+"\tLexerError( \"yyFlexLexer::yylex invoked but %option yyclass used\" );" );
+ outn( "\t}" );
+
+ out_str( "\n#define YY_DECL int %s::yylex()\n",
+ yyclass );
+ }
+ }
+
else
{
if ( yytext_is_array )
@@ -977,6 +992,10 @@ _( "Variable trailing context rules entail a large performance penalty\n" ) );
outn( "extern char *yytext;" );
outn( "#define yytext_ptr yytext" );
}
+
+ if ( yyclass )
+ flexerror(
+ _( "%option yyclass only meaningful for C++ scanners" ) );
}
if ( useecs )
diff --git a/scan.l b/scan.l
index 39ccaba..15cc8c2 100644
--- a/scan.l
+++ b/scan.l
@@ -27,7 +27,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-/* $Header: /cvsroot/flex/flex/scan.l,v 2.52 1995/03/04 16:11:23 vern Exp $ */
+/* $Header: /cvsroot/flex/flex/scan.l,v 2.53 1995/03/05 20:37:26 vern Exp $ */
#include "flexdef.h"
#include "parse.h"
@@ -273,6 +273,7 @@ LEXOPT [aceknopr]
outfile return OPT_OUTFILE;
prefix return OPT_PREFIX;
+ yyclass return OPT_YYCLASS;
\"[^"\n]*\" {
strcpy( nmstr, yytext + 1 );