summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVern Paxson <vern@ee.lbl.gov>1993-12-27 14:41:51 +0000
committerVern Paxson <vern@ee.lbl.gov>1993-12-27 14:41:51 +0000
commit2f595d6d62d8b94f37c06f478578161204497491 (patch)
treeb8b1485af63287870c6ab2f51f0d946076a269bc
parent9322563cf65f46d0a08b90fe2e518d9d433212d6 (diff)
%option
-rw-r--r--parse.y20
-rw-r--r--scan.l113
2 files changed, 84 insertions, 49 deletions
diff --git a/parse.y b/parse.y
index 307db76..9d447b0 100644
--- 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 0dbc29d..58a6b9d 100644
--- 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;