]> granicus.if.org Git - flex/commitdiff
added yyclass
authorVern Paxson <vern@ee.lbl.gov>
Sun, 5 Mar 1995 20:37:26 +0000 (20:37 +0000)
committerVern Paxson <vern@ee.lbl.gov>
Sun, 5 Mar 1995 20:37:26 +0000 (20:37 +0000)
flexdef.h
main.c
scan.l

index cc241a74ca2d5ccf0e681f73a052de31b63c9898..0ebff13527b048252a2d573800155bf72be0dabe 100644 (file)
--- a/flexdef.h
+++ b/flexdef.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 2a1902d91da0a15ac723883229f9cee783a7a52d..40bd769b793a61d2b7ade26ada21e00280aabeae 100644 (file)
--- a/main.c
+++ b/main.c
@@ -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 748a0cb1c5bcdef4cf3a342c9b58ffbab658030b..2bff1b246a4ff3aa277974343c70a77b023d3cc2 100644 (file)
--- a/scan.l
+++ b/scan.l
@@ -273,6 +273,7 @@ LEXOPT              [aceknopr]
 
        outfile         return OPT_OUTFILE;
        prefix          return OPT_PREFIX;
+       yyclass         return OPT_YYCLASS;
 
        \"[^"\n]*\"     {
                        strcpy( nmstr, yytext + 1 );