]> granicus.if.org Git - flex/commitdiff
%option
authorVern Paxson <vern@ee.lbl.gov>
Mon, 27 Dec 1993 14:41:51 +0000 (14:41 +0000)
committerVern Paxson <vern@ee.lbl.gov>
Mon, 27 Dec 1993 14:41:51 +0000 (14:41 +0000)
parse.y
scan.l

diff --git a/parse.y b/parse.y
index 307db76f2b3fc9100b16497d46d4081ce8936c74..9d447b043f8860aae3d4d4786508ca867345a73e 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -1,6 +1,7 @@
 /* parse.y - parser for flex input */
 
 %token CHAR NUMBER SECTEND SCDECL XSCDECL NAME PREVCCL EOF_OP
+%token OPTION_OP OPT_OUTFILE OPT_PREFIX
 
 %{
 /*-
@@ -65,6 +66,7 @@ int *scon_stk;
 int scon_stk_ptr, max_scon_stk;
 
 Char clower();
+char *copy_string();
 void build_eof_action();
 void yyerror();
 
@@ -120,6 +122,7 @@ initlex             :
                ;
 
 sect1          :  sect1 startconddecl namelist1
+               |  sect1 options
                |
                |  error
                        { synerr( "unknown error processing section 1" ); }
@@ -127,6 +130,7 @@ sect1               :  sect1 startconddecl namelist1
 
 sect1end       :  SECTEND
                        {
+                       check_options();
                        scon_stk = allocate_integer_array( lastsc + 1 );
                        scon_stk_ptr = 0;
                        }
@@ -149,6 +153,22 @@ namelist1  :  namelist1 NAME
                        { synerr( "bad start condition list" ); }
                ;
 
+options                :  OPTION_OP optionlist
+               ;
+
+optionlist     :  optionlist option
+               |
+               ;
+
+option         :  OPT_OUTFILE '=' NAME
+                       {
+                       outfilename = copy_string( nmstr );
+                       did_outfilename = 1;
+                       }
+               |  OPT_PREFIX '=' NAME
+                       { prefix = copy_string( nmstr ); }
+               ;
+
 sect2          :  sect2 scon initforrule flexrule '\n'
                        { scon_stk_ptr = $2; }
                |  sect2 scon '{' sect2 '}'
diff --git a/scan.l b/scan.l
index 0dbc29dc070d4a36dbb2d69c549ea71c9c146481..58a6b9d106ed9e30073f6cd7f276e3b8e5c93aa3 100644 (file)
--- a/scan.l
+++ b/scan.l
@@ -60,8 +60,8 @@
 %}
 
 %x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE
-%x FIRSTCCL CCL ACTION RECOVER BRACEERROR COMMENT ACTION_STRING
-%x PERCENT_BRACE_ACTION USED_LIST
+%x FIRSTCCL CCL ACTION RECOVER COMMENT ACTION_STRING PERCENT_BRACE_ACTION
+%x OPTION
 
 WS             [ \t]+
 OPTWS          [ \t]*
@@ -82,6 +82,7 @@ CCL_CHAR      ([^\\\n\]]|{ESCSEQ})
 %%
        static int bracelevel, didadef, indented_code, checking_used;
        static int doing_rule_action = false;
+       static int option_sense;
 
        int doing_codeblock = false;
        int i;
@@ -111,34 +112,14 @@ CCL_CHAR  ([^\\\n\]]|{ESCSEQ})
                        return SECTEND;
                        }
 
-       ^"%pointer".*{NL}       {
-                       if ( lex_compat )
-                               warn( "%pointer incompatible with -l option" );
-                       else
-                               yytext_is_array = false;
-                       ++linenum;
-                       }
-       ^"%array".*{NL} {
-                       if ( C_plus_plus )
-                               warn( "%array incompatible with -+ option" );
-                       else
-                               yytext_is_array = true;
-                       ++linenum;
-                       }
-
-       ^"%used"        {
-                       warn( "%used/%unused have been deprecated" );
-                       checking_used = REALLY_USED; BEGIN(USED_LIST);
-                       }
-       ^"%unused"      {
-                       warn( "%used/%unused have been deprecated" );
-                       checking_used = REALLY_NOT_USED; BEGIN(USED_LIST);
-                       }
+       ^"%pointer".*{NL}       yytext_is_array = false; ++linenum;
+       ^"%array".*{NL}         yytext_is_array = true; ++linenum;
 
+       ^"%option"      BEGIN(OPTION); return OPTION_OP;
 
        ^"%"[aceknopr]{OPTWS}[0-9]*{OPTWS}{NL}  ++linenum;      /* ignore */
 
-       ^"%"[^sxanpekotcru{}].* synerr( "unrecognized '%' directive" );
+       ^"%"[^sxaceknopr{}].*   synerr( "unrecognized '%' directive" );
 
        ^{NAME}         {
                        strcpy( nmstr, yytext );
@@ -199,26 +180,66 @@ CCL_CHAR  ([^\\\n\]]|{ESCSEQ})
                        }
 }
 
-<RECOVER>.*{NL}                ++linenum; BEGIN(INITIAL); RETURNNAME;
-
 
-<USED_LIST>{NL}                ++linenum; BEGIN(INITIAL);
-<USED_LIST>{WS}
-<USED_LIST>"reject"    {
-                       if ( all_upper( yytext ) )
-                               reject_really_used = checking_used;
-                       else
-                               synerr(
-                               "unrecognized %used/%unused construct" );
+<OPTION>{
+       {NL}            ++linenum; BEGIN(INITIAL);
+       {WS}            option_sense = true;
+
+       "="             return '=';
+
+       no              option_sense = ! option_sense;
+
+       7bit            csize = option_sense ? 128 : 256;
+       8bit            csize = option_sense ? 256 : 128;
+
+       align           long_align = option_sense;
+       array           yytext_is_array = option_sense;
+       backup          backing_up_report = option_sense;
+       batch           interactive = ! option_sense;
+       "c++"           C_plus_plus = option_sense;
+       caseful|case-sensitive          caseins = ! option_sense;
+       caseless|case-insensitive       caseins = option_sense;
+       debug           ddebug = option_sense;
+       default         spprdflt = ! option_sense;
+       ecs             useecs = option_sense;
+       fast            {
+                       useecs = usemecs = false;
+                       use_read = fullspd = true;
+                       }
+       full            {
+                       useecs = usemecs = false;
+                       use_read = fulltbl = true;
+                       }
+       interactive     interactive = option_sense;
+       lex-compat      lex_compat = option_sense;
+       meta-ecs        usemecs = option_sense;
+       perf-report     performance_report += option_sense ? 1 : -1;
+       pointer         yytext_is_array = ! option_sense;
+       read            use_read = option_sense;
+       reject          reject_really_used = option_sense;
+       stack           action_define( "YY_STACK_USED", option_sense );
+       stdout          use_stdout = option_sense;
+       unput           action_define( "YY_UNPUT_USED", option_sense );
+       verbose         printstats = option_sense;
+       warn            nowarn = ! option_sense;
+       yymore          yymore_really_used = option_sense;
+
+       outfile         return OPT_OUTFILE;
+       prefix          return OPT_PREFIX;
+
+       \"[^"\n]*\"     {
+                       strcpy( nmstr, yytext + 1 );
+                       nmstr[strlen( nmstr ) - 1] = '\0';
+                       return NAME;
                        }
-<USED_LIST>"yymore"    {
-                       if ( all_lower( yytext ) )
-                               yymore_really_used = checking_used;
-                       else
-                               synerr(
-                               "unrecognized %used/%unused construct" );
+
+       (([a-mo-z]|n[a-np-z])[a-z\-+]*)|.       {
+                       format_synerr( "unrecognized %%option: %s", yytext );
+                       BEGIN(RECOVER);
                        }
-<USED_LIST>{NOT_WS}+   synerr( "unrecognized %used/%unused construct" );
+}
+
+<RECOVER>.*{NL}                ++linenum; BEGIN(INITIAL);
 
 
 <SECT2PROLOG>{
@@ -464,12 +485,6 @@ CCL_CHAR   ([^\\\n\]]|{ESCSEQ})
 }
 
 
-<BRACEERROR>{
-       "}"             synerr( "bad name in {}'s" ); BEGIN(SECT2);
-       {NL}            synerr( "missing }" ); ++linenum; BEGIN(SECT2);
-}
-
-
 <PERCENT_BRACE_ACTION>{
        {OPTWS}"%}".*           bracelevel = 0;