1994-08-24 13:10:34 +00:00
|
|
|
/* scan.l - scanner for flex input */
|
|
|
|
|
|
|
|
%{
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 1990 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Vern Paxson.
|
|
|
|
*
|
|
|
|
* The United States Government has rights in this work pursuant
|
|
|
|
* to contract no. DE-AC03-76SF00098 between the United States
|
|
|
|
* Department of Energy and the University of California.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms are permitted provided
|
|
|
|
* that: (1) source distributions retain this entire copyright notice and
|
|
|
|
* comment, and (2) distributions including binaries display the following
|
|
|
|
* acknowledgement: ``This product includes software developed by the
|
|
|
|
* University of California, Berkeley and its contributors'' in the
|
|
|
|
* documentation or other materials provided with the distribution and in
|
|
|
|
* all advertising materials mentioning features or use of this software.
|
|
|
|
* Neither the name of the University nor the names of its contributors may
|
|
|
|
* be used to endorse or promote products derived from this software without
|
|
|
|
* specific prior written permission.
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*/
|
|
|
|
|
1999-10-27 07:56:49 +00:00
|
|
|
/* $Header: /home/daffy/u0/vern/flex/RCS/scan.l,v 2.56 95/04/24 12:17:19 vern Exp $ */
|
1999-08-28 05:11:36 +00:00
|
|
|
/* $FreeBSD$ */
|
1994-08-24 13:10:34 +00:00
|
|
|
|
|
|
|
#include "flexdef.h"
|
|
|
|
#include "parse.h"
|
|
|
|
|
|
|
|
#define ACTION_ECHO add_action( yytext )
|
1996-06-19 20:26:48 +00:00
|
|
|
#define ACTION_IFDEF(def, should_define) \
|
|
|
|
{ \
|
|
|
|
if ( should_define ) \
|
|
|
|
action_define( def, 1 ); \
|
|
|
|
}
|
|
|
|
|
1994-08-24 13:10:34 +00:00
|
|
|
#define MARK_END_OF_PROLOG mark_prolog();
|
|
|
|
|
|
|
|
#define YY_DECL \
|
|
|
|
int flexscan()
|
|
|
|
|
|
|
|
#define RETURNCHAR \
|
|
|
|
yylval = (unsigned char) yytext[0]; \
|
|
|
|
return CHAR;
|
|
|
|
|
|
|
|
#define RETURNNAME \
|
|
|
|
strcpy( nmstr, yytext ); \
|
|
|
|
return NAME;
|
|
|
|
|
|
|
|
#define PUT_BACK_STRING(str, start) \
|
|
|
|
for ( i = strlen( str ) - 1; i >= start; --i ) \
|
|
|
|
unput((str)[i])
|
|
|
|
|
|
|
|
#define CHECK_REJECT(str) \
|
|
|
|
if ( all_upper( str ) ) \
|
|
|
|
reject = true;
|
|
|
|
|
|
|
|
#define CHECK_YYMORE(str) \
|
|
|
|
if ( all_lower( str ) ) \
|
|
|
|
yymore_used = true;
|
|
|
|
%}
|
|
|
|
|
1996-12-14 05:48:48 +00:00
|
|
|
%option caseless nodefault outfile="scan.c" stack noyy_top_state
|
1996-06-19 20:26:48 +00:00
|
|
|
%option nostdinit
|
|
|
|
|
1994-08-24 13:10:34 +00:00
|
|
|
%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE
|
1996-06-19 20:26:48 +00:00
|
|
|
%x FIRSTCCL CCL ACTION RECOVER COMMENT ACTION_STRING PERCENT_BRACE_ACTION
|
|
|
|
%x OPTION LINEDIR
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
WS [[:blank:]]+
|
|
|
|
OPTWS [[:blank:]]*
|
|
|
|
NOT_WS [^[:blank:]\n]
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
NL \r?\n
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
NAME ([[:alpha:]_][[:alnum:]_-]*)
|
|
|
|
NOT_NAME [^[:alpha:]_*\n]+
|
1994-08-24 13:10:34 +00:00
|
|
|
|
|
|
|
SCNAME {NAME}
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
ESCSEQ (\\([^\n]|[0-7]{1,3}|x[[:xdigit:]]{1,2}))
|
1994-08-24 13:10:34 +00:00
|
|
|
|
|
|
|
FIRST_CCL_CHAR ([^\\\n]|{ESCSEQ})
|
|
|
|
CCL_CHAR ([^\\\n\]]|{ESCSEQ})
|
1996-06-19 20:26:48 +00:00
|
|
|
CCL_EXPR ("[:"[[:alpha:]]+":]")
|
|
|
|
|
|
|
|
LEXOPT [aceknopr]
|
1994-08-24 13:10:34 +00:00
|
|
|
|
|
|
|
%%
|
1996-06-19 20:26:48 +00:00
|
|
|
static int bracelevel, didadef, indented_code;
|
|
|
|
static int doing_rule_action = false;
|
|
|
|
static int option_sense;
|
1994-08-24 13:10:34 +00:00
|
|
|
|
|
|
|
int doing_codeblock = false;
|
|
|
|
int i;
|
|
|
|
Char nmdef[MAXLINE], myesc();
|
|
|
|
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<INITIAL>{
|
|
|
|
^{WS} indented_code = true; BEGIN(CODEBLOCK);
|
|
|
|
^"/*" ACTION_ECHO; yy_push_state( COMMENT );
|
|
|
|
^#{OPTWS}line{WS} yy_push_state( LINEDIR );
|
|
|
|
^"%s"{NAME}? return SCDECL;
|
|
|
|
^"%x"{NAME}? return XSCDECL;
|
|
|
|
^"%{".*{NL} {
|
1994-08-24 13:10:34 +00:00
|
|
|
++linenum;
|
1996-06-19 20:26:48 +00:00
|
|
|
line_directive_out( (FILE *) 0, 1 );
|
1994-08-24 13:10:34 +00:00
|
|
|
indented_code = false;
|
|
|
|
BEGIN(CODEBLOCK);
|
|
|
|
}
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
{WS} /* discard */
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
^"%%".* {
|
1994-08-24 13:10:34 +00:00
|
|
|
sectnum = 2;
|
|
|
|
bracelevel = 0;
|
|
|
|
mark_defs1();
|
1996-06-19 20:26:48 +00:00
|
|
|
line_directive_out( (FILE *) 0, 1 );
|
1994-08-24 13:10:34 +00:00
|
|
|
BEGIN(SECT2PROLOG);
|
|
|
|
return SECTEND;
|
|
|
|
}
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
^"%pointer".*{NL} yytext_is_array = false; ++linenum;
|
|
|
|
^"%array".*{NL} yytext_is_array = true; ++linenum;
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
^"%option" BEGIN(OPTION); return OPTION_OP;
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
^"%"{LEXOPT}{OPTWS}[[:digit:]]*{OPTWS}{NL} ++linenum; /* ignore */
|
|
|
|
^"%"{LEXOPT}{WS}.*{NL} ++linenum; /* ignore */
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
^"%"[^sxaceknopr{}].* synerr( _( "unrecognized '%' directive" ) );
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
^{NAME} {
|
1994-08-24 13:10:34 +00:00
|
|
|
strcpy( nmstr, yytext );
|
|
|
|
didadef = false;
|
|
|
|
BEGIN(PICKUPDEF);
|
|
|
|
}
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
{SCNAME} RETURNNAME;
|
|
|
|
^{OPTWS}{NL} ++linenum; /* allows blank lines in section 1 */
|
|
|
|
{OPTWS}{NL} ACTION_ECHO; ++linenum; /* maybe end of comment line */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
<COMMENT>{
|
|
|
|
"*/" ACTION_ECHO; yy_pop_state();
|
|
|
|
"*" ACTION_ECHO;
|
|
|
|
[^*\n]+ ACTION_ECHO;
|
|
|
|
[^*\n]*{NL} ++linenum; ACTION_ECHO;
|
|
|
|
}
|
|
|
|
|
|
|
|
<LINEDIR>{
|
|
|
|
\n yy_pop_state();
|
|
|
|
[[:digit:]]+ linenum = myctoi( yytext );
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
\"[^"\n]*\" {
|
|
|
|
flex_free( (void *) infilename );
|
|
|
|
infilename = copy_string( yytext + 1 );
|
|
|
|
infilename[strlen( infilename ) - 1] = '\0';
|
|
|
|
}
|
|
|
|
. /* ignore spurious characters */
|
|
|
|
}
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<CODEBLOCK>{
|
|
|
|
^"%}".*{NL} ++linenum; BEGIN(INITIAL);
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
{NAME}|{NOT_NAME}|. ACTION_ECHO;
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
{NL} {
|
1994-08-24 13:10:34 +00:00
|
|
|
++linenum;
|
|
|
|
ACTION_ECHO;
|
|
|
|
if ( indented_code )
|
|
|
|
BEGIN(INITIAL);
|
|
|
|
}
|
1996-06-19 20:26:48 +00:00
|
|
|
}
|
1994-08-24 13:10:34 +00:00
|
|
|
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<PICKUPDEF>{
|
|
|
|
{WS} /* separates name and definition */
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
{NOT_WS}.* {
|
1994-08-24 13:10:34 +00:00
|
|
|
strcpy( (char *) nmdef, yytext );
|
|
|
|
|
|
|
|
/* Skip trailing whitespace. */
|
|
|
|
for ( i = strlen( (char *) nmdef ) - 1;
|
|
|
|
i >= 0 && (nmdef[i] == ' ' || nmdef[i] == '\t');
|
|
|
|
--i )
|
|
|
|
;
|
|
|
|
|
|
|
|
nmdef[i + 1] = '\0';
|
|
|
|
|
|
|
|
ndinstal( nmstr, nmdef );
|
|
|
|
didadef = true;
|
|
|
|
}
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
{NL} {
|
1994-08-24 13:10:34 +00:00
|
|
|
if ( ! didadef )
|
1996-06-19 20:26:48 +00:00
|
|
|
synerr( _( "incomplete name definition" ) );
|
1994-08-24 13:10:34 +00:00
|
|
|
BEGIN(INITIAL);
|
|
|
|
++linenum;
|
|
|
|
}
|
1996-06-19 20:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
<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;
|
|
|
|
always-interactive {
|
|
|
|
action_define( "YY_ALWAYS_INTERACTIVE", 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;
|
|
|
|
}
|
|
|
|
input ACTION_IFDEF("YY_NO_INPUT", ! option_sense);
|
|
|
|
interactive interactive = option_sense;
|
|
|
|
lex-compat lex_compat = option_sense;
|
|
|
|
main {
|
|
|
|
action_define( "YY_MAIN", option_sense );
|
|
|
|
do_yywrap = ! option_sense;
|
|
|
|
}
|
|
|
|
meta-ecs usemecs = option_sense;
|
|
|
|
never-interactive {
|
|
|
|
action_define( "YY_NEVER_INTERACTIVE", 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 );
|
|
|
|
stdinit do_stdinit = option_sense;
|
|
|
|
stdout use_stdout = option_sense;
|
|
|
|
unput ACTION_IFDEF("YY_NO_UNPUT", ! option_sense);
|
|
|
|
verbose printstats = option_sense;
|
|
|
|
warn nowarn = ! option_sense;
|
|
|
|
yylineno do_yylineno = option_sense;
|
|
|
|
yymore yymore_really_used = option_sense;
|
|
|
|
yywrap do_yywrap = option_sense;
|
|
|
|
|
|
|
|
yy_push_state ACTION_IFDEF("YY_NO_PUSH_STATE", ! option_sense);
|
|
|
|
yy_pop_state ACTION_IFDEF("YY_NO_POP_STATE", ! option_sense);
|
|
|
|
yy_top_state ACTION_IFDEF("YY_NO_TOP_STATE", ! option_sense);
|
|
|
|
|
|
|
|
yy_scan_buffer ACTION_IFDEF("YY_NO_SCAN_BUFFER", ! option_sense);
|
|
|
|
yy_scan_bytes ACTION_IFDEF("YY_NO_SCAN_BYTES", ! option_sense);
|
|
|
|
yy_scan_string ACTION_IFDEF("YY_NO_SCAN_STRING", ! option_sense);
|
|
|
|
|
|
|
|
outfile return OPT_OUTFILE;
|
|
|
|
prefix return OPT_PREFIX;
|
|
|
|
yyclass return OPT_YYCLASS;
|
|
|
|
|
|
|
|
\"[^"\n]*\" {
|
|
|
|
strcpy( nmstr, yytext + 1 );
|
|
|
|
nmstr[strlen( nmstr ) - 1] = '\0';
|
|
|
|
return NAME;
|
1994-08-24 13:10:34 +00:00
|
|
|
}
|
1996-06-19 20:26:48 +00:00
|
|
|
|
|
|
|
(([a-mo-z]|n[a-np-z])[[:alpha:]\-+]*)|. {
|
|
|
|
format_synerr( _( "unrecognized %%option: %s" ),
|
|
|
|
yytext );
|
|
|
|
BEGIN(RECOVER);
|
1994-08-24 13:10:34 +00:00
|
|
|
}
|
1996-06-19 20:26:48 +00:00
|
|
|
}
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<RECOVER>.*{NL} ++linenum; BEGIN(INITIAL);
|
1994-08-24 13:10:34 +00:00
|
|
|
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<SECT2PROLOG>{
|
|
|
|
^"%{".* ++bracelevel; yyless( 2 ); /* eat only %{ */
|
|
|
|
^"%}".* --bracelevel; yyless( 2 ); /* eat only %} */
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
^{WS}.* ACTION_ECHO; /* indented code in prolog */
|
|
|
|
|
|
|
|
^{NOT_WS}.* { /* non-indented code */
|
1994-08-24 13:10:34 +00:00
|
|
|
if ( bracelevel <= 0 )
|
|
|
|
{ /* not in %{ ... %} */
|
|
|
|
yyless( 0 ); /* put it all back */
|
1996-06-19 20:26:48 +00:00
|
|
|
yy_set_bol( 1 );
|
1994-08-24 13:10:34 +00:00
|
|
|
mark_prolog();
|
|
|
|
BEGIN(SECT2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ACTION_ECHO;
|
|
|
|
}
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
.* ACTION_ECHO;
|
|
|
|
{NL} ++linenum; ACTION_ECHO;
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<<EOF>> {
|
1994-08-24 13:10:34 +00:00
|
|
|
mark_prolog();
|
|
|
|
sectnum = 0;
|
|
|
|
yyterminate(); /* to stop the parser */
|
|
|
|
}
|
1996-06-19 20:26:48 +00:00
|
|
|
}
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<SECT2>{
|
|
|
|
^{OPTWS}{NL} ++linenum; /* allow blank lines in section 2 */
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
^{OPTWS}"%{" {
|
|
|
|
indented_code = false;
|
1994-08-24 13:10:34 +00:00
|
|
|
doing_codeblock = true;
|
|
|
|
bracelevel = 1;
|
1996-06-19 20:26:48 +00:00
|
|
|
BEGIN(PERCENT_BRACE_ACTION);
|
1994-08-24 13:10:34 +00:00
|
|
|
}
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
^{OPTWS}"<" BEGIN(SC); return '<';
|
|
|
|
^{OPTWS}"^" return '^';
|
|
|
|
\" BEGIN(QUOTE); return '"';
|
|
|
|
"{"/[[:digit:]] BEGIN(NUM); return '{';
|
|
|
|
"$"/([[:blank:]]|{NL}) return '$';
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
{WS}"%{" {
|
1994-08-24 13:10:34 +00:00
|
|
|
bracelevel = 1;
|
|
|
|
BEGIN(PERCENT_BRACE_ACTION);
|
1996-06-19 20:26:48 +00:00
|
|
|
|
|
|
|
if ( in_rule )
|
|
|
|
{
|
|
|
|
doing_rule_action = true;
|
|
|
|
in_rule = false;
|
|
|
|
return '\n';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{WS}"|".*{NL} continued_action = true; ++linenum; return '\n';
|
|
|
|
|
|
|
|
^{WS}"/*" {
|
|
|
|
yyless( yyleng - 2 ); /* put back '/', '*' */
|
|
|
|
bracelevel = 0;
|
|
|
|
continued_action = false;
|
|
|
|
BEGIN(ACTION);
|
1994-08-24 13:10:34 +00:00
|
|
|
}
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
^{WS} /* allow indented rules */
|
|
|
|
|
|
|
|
{WS} {
|
1994-08-24 13:10:34 +00:00
|
|
|
/* This rule is separate from the one below because
|
|
|
|
* otherwise we get variable trailing context, so
|
|
|
|
* we can't build the scanner using -{f,F}.
|
|
|
|
*/
|
|
|
|
bracelevel = 0;
|
|
|
|
continued_action = false;
|
|
|
|
BEGIN(ACTION);
|
1996-06-19 20:26:48 +00:00
|
|
|
|
|
|
|
if ( in_rule )
|
|
|
|
{
|
|
|
|
doing_rule_action = true;
|
|
|
|
in_rule = false;
|
|
|
|
return '\n';
|
|
|
|
}
|
1994-08-24 13:10:34 +00:00
|
|
|
}
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
{OPTWS}{NL} {
|
1994-08-24 13:10:34 +00:00
|
|
|
bracelevel = 0;
|
|
|
|
continued_action = false;
|
|
|
|
BEGIN(ACTION);
|
|
|
|
unput( '\n' ); /* so <ACTION> sees it */
|
1996-06-19 20:26:48 +00:00
|
|
|
|
|
|
|
if ( in_rule )
|
|
|
|
{
|
|
|
|
doing_rule_action = true;
|
|
|
|
in_rule = false;
|
|
|
|
return '\n';
|
|
|
|
}
|
1994-08-24 13:10:34 +00:00
|
|
|
}
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
^{OPTWS}"<<EOF>>" |
|
|
|
|
"<<EOF>>" return EOF_OP;
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
^"%%".* {
|
1994-08-24 13:10:34 +00:00
|
|
|
sectnum = 3;
|
|
|
|
BEGIN(SECT3);
|
|
|
|
yyterminate(); /* to stop the parser */
|
|
|
|
}
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
"["({FIRST_CCL_CHAR}|{CCL_EXPR})({CCL_CHAR}|{CCL_EXPR})* {
|
1994-08-24 13:10:34 +00:00
|
|
|
int cclval;
|
|
|
|
|
|
|
|
strcpy( nmstr, yytext );
|
|
|
|
|
|
|
|
/* Check to see if we've already encountered this
|
|
|
|
* ccl.
|
|
|
|
*/
|
1996-06-19 20:26:48 +00:00
|
|
|
if ( (cclval = ccllookup( (Char *) nmstr )) != 0 )
|
1994-08-24 13:10:34 +00:00
|
|
|
{
|
|
|
|
if ( input() != ']' )
|
1996-06-19 20:26:48 +00:00
|
|
|
synerr( _( "bad character class" ) );
|
1994-08-24 13:10:34 +00:00
|
|
|
|
|
|
|
yylval = cclval;
|
|
|
|
++cclreuse;
|
|
|
|
return PREVCCL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We fudge a bit. We know that this ccl will
|
|
|
|
* soon be numbered as lastccl + 1 by cclinit.
|
|
|
|
*/
|
|
|
|
cclinstal( (Char *) nmstr, lastccl + 1 );
|
|
|
|
|
|
|
|
/* Push back everything but the leading bracket
|
|
|
|
* so the ccl can be rescanned.
|
|
|
|
*/
|
|
|
|
yyless( 1 );
|
|
|
|
|
|
|
|
BEGIN(FIRSTCCL);
|
|
|
|
return '[';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
"{"{NAME}"}" {
|
2008-06-08 19:59:15 +00:00
|
|
|
Char *nmdefptr;
|
1994-08-24 13:10:34 +00:00
|
|
|
Char *ndlookup();
|
|
|
|
|
|
|
|
strcpy( nmstr, yytext + 1 );
|
|
|
|
nmstr[yyleng - 2] = '\0'; /* chop trailing brace */
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
if ( (nmdefptr = ndlookup( nmstr )) == 0 )
|
|
|
|
format_synerr(
|
|
|
|
_( "undefined definition {%s}" ),
|
1994-08-24 13:10:34 +00:00
|
|
|
nmstr );
|
|
|
|
|
|
|
|
else
|
|
|
|
{ /* push back name surrounded by ()'s */
|
|
|
|
int len = strlen( (char *) nmdefptr );
|
|
|
|
|
|
|
|
if ( lex_compat || nmdefptr[0] == '^' ||
|
|
|
|
(len > 0 && nmdefptr[len - 1] == '$') )
|
|
|
|
{ /* don't use ()'s after all */
|
|
|
|
PUT_BACK_STRING((char *) nmdefptr, 0);
|
|
|
|
|
|
|
|
if ( nmdefptr[0] == '^' )
|
|
|
|
BEGIN(CARETISBOL);
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unput(')');
|
|
|
|
PUT_BACK_STRING((char *) nmdefptr, 0);
|
|
|
|
unput('(');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
[/|*+?.(){}] return (unsigned char) yytext[0];
|
|
|
|
. RETURNCHAR;
|
|
|
|
}
|
1994-08-24 13:10:34 +00:00
|
|
|
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<SC>{
|
|
|
|
[,*] return (unsigned char) yytext[0];
|
|
|
|
">" BEGIN(SECT2); return '>';
|
|
|
|
">"/^ BEGIN(CARETISBOL); return '>';
|
|
|
|
{SCNAME} RETURNNAME;
|
|
|
|
. {
|
|
|
|
format_synerr( _( "bad <start condition>: %s" ),
|
|
|
|
yytext );
|
1994-08-24 13:10:34 +00:00
|
|
|
}
|
1996-06-19 20:26:48 +00:00
|
|
|
}
|
1994-08-24 13:10:34 +00:00
|
|
|
|
|
|
|
<CARETISBOL>"^" BEGIN(SECT2); return '^';
|
|
|
|
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<QUOTE>{
|
|
|
|
[^"\n] RETURNCHAR;
|
|
|
|
\" BEGIN(SECT2); return '"';
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
{NL} {
|
|
|
|
synerr( _( "missing quote" ) );
|
1994-08-24 13:10:34 +00:00
|
|
|
BEGIN(SECT2);
|
|
|
|
++linenum;
|
|
|
|
return '"';
|
|
|
|
}
|
1996-06-19 20:26:48 +00:00
|
|
|
}
|
1994-08-24 13:10:34 +00:00
|
|
|
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<FIRSTCCL>{
|
|
|
|
"^"/[^-\]\n] BEGIN(CCL); return '^';
|
|
|
|
"^"/("-"|"]") return '^';
|
|
|
|
. BEGIN(CCL); RETURNCHAR;
|
|
|
|
}
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<CCL>{
|
|
|
|
-/[^\]\n] return '-';
|
|
|
|
[^\]\n] RETURNCHAR;
|
|
|
|
"]" BEGIN(SECT2); return ']';
|
|
|
|
.|{NL} {
|
|
|
|
synerr( _( "bad character class" ) );
|
1994-08-24 13:10:34 +00:00
|
|
|
BEGIN(SECT2);
|
|
|
|
return ']';
|
|
|
|
}
|
1996-06-19 20:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
<FIRSTCCL,CCL>{
|
|
|
|
"[:alnum:]" BEGIN(CCL); return CCE_ALNUM;
|
|
|
|
"[:alpha:]" BEGIN(CCL); return CCE_ALPHA;
|
|
|
|
"[:blank:]" BEGIN(CCL); return CCE_BLANK;
|
|
|
|
"[:cntrl:]" BEGIN(CCL); return CCE_CNTRL;
|
|
|
|
"[:digit:]" BEGIN(CCL); return CCE_DIGIT;
|
|
|
|
"[:graph:]" BEGIN(CCL); return CCE_GRAPH;
|
|
|
|
"[:lower:]" BEGIN(CCL); return CCE_LOWER;
|
|
|
|
"[:print:]" BEGIN(CCL); return CCE_PRINT;
|
|
|
|
"[:punct:]" BEGIN(CCL); return CCE_PUNCT;
|
|
|
|
"[:space:]" BEGIN(CCL); return CCE_SPACE;
|
|
|
|
"[:upper:]" BEGIN(CCL); return CCE_UPPER;
|
|
|
|
"[:xdigit:]" BEGIN(CCL); return CCE_XDIGIT;
|
|
|
|
{CCL_EXPR} {
|
|
|
|
format_synerr(
|
|
|
|
_( "bad character class expression: %s" ),
|
|
|
|
yytext );
|
|
|
|
BEGIN(CCL); return CCE_ALNUM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
<NUM>{
|
|
|
|
[[:digit:]]+ {
|
1994-08-24 13:10:34 +00:00
|
|
|
yylval = myctoi( yytext );
|
|
|
|
return NUMBER;
|
|
|
|
}
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
"," return ',';
|
|
|
|
"}" BEGIN(SECT2); return '}';
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
. {
|
|
|
|
synerr( _( "bad character inside {}'s" ) );
|
1994-08-24 13:10:34 +00:00
|
|
|
BEGIN(SECT2);
|
|
|
|
return '}';
|
|
|
|
}
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
{NL} {
|
|
|
|
synerr( _( "missing }" ) );
|
1994-08-24 13:10:34 +00:00
|
|
|
BEGIN(SECT2);
|
|
|
|
++linenum;
|
|
|
|
return '}';
|
|
|
|
}
|
1996-06-19 20:26:48 +00:00
|
|
|
}
|
1994-08-24 13:10:34 +00:00
|
|
|
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<PERCENT_BRACE_ACTION>{
|
|
|
|
{OPTWS}"%}".* bracelevel = 0;
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<ACTION>"/*" ACTION_ECHO; yy_push_state( COMMENT );
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<CODEBLOCK,ACTION>{
|
|
|
|
"reject" {
|
1994-08-24 13:10:34 +00:00
|
|
|
ACTION_ECHO;
|
|
|
|
CHECK_REJECT(yytext);
|
|
|
|
}
|
1996-06-19 20:26:48 +00:00
|
|
|
"yymore" {
|
1994-08-24 13:10:34 +00:00
|
|
|
ACTION_ECHO;
|
|
|
|
CHECK_YYMORE(yytext);
|
|
|
|
}
|
1996-06-19 20:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{NAME}|{NOT_NAME}|. ACTION_ECHO;
|
|
|
|
{NL} {
|
1994-08-24 13:10:34 +00:00
|
|
|
++linenum;
|
|
|
|
ACTION_ECHO;
|
|
|
|
if ( bracelevel == 0 ||
|
|
|
|
(doing_codeblock && indented_code) )
|
|
|
|
{
|
1996-06-19 20:26:48 +00:00
|
|
|
if ( doing_rule_action )
|
1994-08-24 13:10:34 +00:00
|
|
|
add_action( "\tYY_BREAK\n" );
|
1996-06-19 20:26:48 +00:00
|
|
|
|
|
|
|
doing_rule_action = doing_codeblock = false;
|
1994-08-24 13:10:34 +00:00
|
|
|
BEGIN(SECT2);
|
|
|
|
}
|
|
|
|
}
|
1996-06-19 20:26:48 +00:00
|
|
|
}
|
1994-08-24 13:10:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Reject and YYmore() are checked for above, in PERCENT_BRACE_ACTION */
|
1996-06-19 20:26:48 +00:00
|
|
|
<ACTION>{
|
|
|
|
"{" ACTION_ECHO; ++bracelevel;
|
|
|
|
"}" ACTION_ECHO; --bracelevel;
|
|
|
|
[^[:alpha:]_{}"'/\n]+ ACTION_ECHO;
|
|
|
|
{NAME} ACTION_ECHO;
|
|
|
|
"'"([^'\\\n]|\\.)*"'" ACTION_ECHO; /* character constant */
|
|
|
|
\" ACTION_ECHO; BEGIN(ACTION_STRING);
|
|
|
|
{NL} {
|
1994-08-24 13:10:34 +00:00
|
|
|
++linenum;
|
|
|
|
ACTION_ECHO;
|
|
|
|
if ( bracelevel == 0 )
|
|
|
|
{
|
1996-06-19 20:26:48 +00:00
|
|
|
if ( doing_rule_action )
|
|
|
|
add_action( "\tYY_BREAK\n" );
|
|
|
|
|
|
|
|
doing_rule_action = false;
|
1994-08-24 13:10:34 +00:00
|
|
|
BEGIN(SECT2);
|
|
|
|
}
|
|
|
|
}
|
1996-06-19 20:26:48 +00:00
|
|
|
. ACTION_ECHO;
|
|
|
|
}
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<ACTION_STRING>{
|
|
|
|
[^"\\\n]+ ACTION_ECHO;
|
|
|
|
\\. ACTION_ECHO;
|
|
|
|
{NL} ++linenum; ACTION_ECHO;
|
|
|
|
\" ACTION_ECHO; BEGIN(ACTION);
|
|
|
|
. ACTION_ECHO;
|
|
|
|
}
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<COMMENT,ACTION,ACTION_STRING><<EOF>> {
|
|
|
|
synerr( _( "EOF encountered inside an action" ) );
|
1994-08-24 13:10:34 +00:00
|
|
|
yyterminate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<SECT2,QUOTE,FIRSTCCL,CCL>{ESCSEQ} {
|
1994-08-24 13:10:34 +00:00
|
|
|
yylval = myesc( (Char *) yytext );
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
if ( YY_START == FIRSTCCL )
|
|
|
|
BEGIN(CCL);
|
|
|
|
|
1994-08-24 13:10:34 +00:00
|
|
|
return CHAR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<SECT3>{
|
|
|
|
.*(\n?) ECHO;
|
|
|
|
<<EOF>> sectnum = 0; yyterminate();
|
|
|
|
}
|
1994-08-24 13:10:34 +00:00
|
|
|
|
1996-06-19 20:26:48 +00:00
|
|
|
<*>.|\n format_synerr( _( "bad character: %s" ), yytext );
|
1994-08-24 13:10:34 +00:00
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
|
|
|
|
int yywrap()
|
|
|
|
{
|
|
|
|
if ( --num_input_files > 0 )
|
|
|
|
{
|
|
|
|
set_input_file( *++input_files );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* set_input_file - open the given file (if NULL, stdin) for scanning */
|
|
|
|
|
|
|
|
void set_input_file( file )
|
|
|
|
char *file;
|
|
|
|
{
|
1996-06-19 20:26:48 +00:00
|
|
|
if ( file && strcmp( file, "-" ) )
|
1994-08-24 13:10:34 +00:00
|
|
|
{
|
1996-06-19 20:26:48 +00:00
|
|
|
infilename = copy_string( file );
|
1994-08-24 13:10:34 +00:00
|
|
|
yyin = fopen( infilename, "r" );
|
|
|
|
|
|
|
|
if ( yyin == NULL )
|
1996-06-19 20:26:48 +00:00
|
|
|
lerrsf( _( "can't open %s" ), file );
|
1994-08-24 13:10:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
yyin = stdin;
|
1996-06-19 20:26:48 +00:00
|
|
|
infilename = copy_string( "<stdin>" );
|
1994-08-24 13:10:34 +00:00
|
|
|
}
|
1996-06-19 20:26:48 +00:00
|
|
|
|
|
|
|
linenum = 1;
|
1994-08-24 13:10:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Wrapper routines for accessing the scanner's malloc routines. */
|
|
|
|
|
|
|
|
void *flex_alloc( size )
|
1996-06-19 20:26:48 +00:00
|
|
|
size_t size;
|
1994-08-24 13:10:34 +00:00
|
|
|
{
|
1996-06-19 20:26:48 +00:00
|
|
|
return (void *) malloc( size );
|
1994-08-24 13:10:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *flex_realloc( ptr, size )
|
|
|
|
void *ptr;
|
1996-06-19 20:26:48 +00:00
|
|
|
size_t size;
|
1994-08-24 13:10:34 +00:00
|
|
|
{
|
1996-06-19 20:26:48 +00:00
|
|
|
return (void *) realloc( ptr, size );
|
1994-08-24 13:10:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void flex_free( ptr )
|
|
|
|
void *ptr;
|
|
|
|
{
|
1996-06-19 20:26:48 +00:00
|
|
|
if ( ptr )
|
|
|
|
free( ptr );
|
1994-08-24 13:10:34 +00:00
|
|
|
}
|