1993-05-04 11:44:39 +04:00
|
|
|
/* scan.l - scanner for flex input */
|
|
|
|
|
|
|
|
%{
|
1993-03-21 12:45:37 +03:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1990 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
1993-05-04 11:44:39 +04:00
|
|
|
* Vern Paxson.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
1993-05-04 11:44:39 +04:00
|
|
|
* The United States Government has rights in this work pursuant
|
1993-03-21 12:45:37 +03:00
|
|
|
* to contract no. DE-AC03-76SF00098 between the United States
|
|
|
|
* Department of Energy and the University of California.
|
|
|
|
*
|
1993-05-04 11:44:39 +04:00
|
|
|
* 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.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
/* $Header: /cvsroot/src/usr.bin/lex/Attic/scan.l,v 1.4 1993/12/02 19:17:59 jtc Exp $ */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#include "flexdef.h"
|
|
|
|
#include "parse.h"
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
#define ACTION_ECHO add_action( yytext )
|
|
|
|
#define MARK_END_OF_PROLOG mark_prolog();
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#define YY_DECL \
|
|
|
|
int flexscan()
|
|
|
|
|
|
|
|
#define RETURNCHAR \
|
|
|
|
yylval = yytext[0]; \
|
1993-12-02 22:17:24 +03:00
|
|
|
return CHAR;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#define RETURNNAME \
|
1993-12-02 22:17:24 +03:00
|
|
|
(void) strcpy( nmstr, yytext ); \
|
|
|
|
return NAME;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#define PUT_BACK_STRING(str, start) \
|
1993-12-02 22:17:24 +03:00
|
|
|
for ( i = strlen( str ) - 1; i >= start; --i ) \
|
|
|
|
unput((str)[i])
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#define CHECK_REJECT(str) \
|
|
|
|
if ( all_upper( str ) ) \
|
1993-12-02 22:17:24 +03:00
|
|
|
reject = true;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#define CHECK_YYMORE(str) \
|
|
|
|
if ( all_lower( str ) ) \
|
1993-12-02 22:17:24 +03:00
|
|
|
yymore_used = true;
|
1993-03-21 12:45:37 +03:00
|
|
|
%}
|
|
|
|
|
|
|
|
%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE
|
|
|
|
%x FIRSTCCL CCL ACTION RECOVER BRACEERROR C_COMMENT ACTION_COMMENT
|
1993-12-02 22:17:24 +03:00
|
|
|
%x ACTION_STRING PERCENT_BRACE_ACTION USED_LIST CODEBLOCK_2
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
WS [ \t]+
|
|
|
|
OPTWS [ \t]*
|
|
|
|
NOT_WS [^ \t\n]
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
NL (\n|\r\n|\n\r)
|
|
|
|
|
|
|
|
NAME ([a-z_][a-z_0-9-]*)
|
|
|
|
NOT_NAME [^a-z_*\n]+
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
SCNAME {NAME}
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
ESCSEQ (\\([^\n]|[0-9]{1,3}|x[0-9a-f]{1,2}))
|
|
|
|
|
|
|
|
FIRST_CCL_CHAR ([^\\\n]|{ESCSEQ})
|
|
|
|
CCL_CHAR ([^\\\n\]]|{ESCSEQ})
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
%%
|
1993-12-02 22:17:24 +03:00
|
|
|
static int bracelevel, didadef, indented_code, checking_used;
|
|
|
|
|
|
|
|
int doing_codeblock = false;
|
|
|
|
int i;
|
|
|
|
Char nmdef[MAXLINE], myesc();
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
^{WS} indented_code = true; BEGIN(CODEBLOCK);
|
1993-12-02 22:17:24 +03:00
|
|
|
^"/*" ACTION_ECHO; BEGIN(C_COMMENT);
|
|
|
|
^"%s"{NAME}? return SCDECL;
|
|
|
|
^"%x"{NAME}? return XSCDECL;
|
|
|
|
^"%{".*{NL} {
|
1993-03-21 12:45:37 +03:00
|
|
|
++linenum;
|
1993-12-02 22:17:24 +03:00
|
|
|
line_directive_out( (FILE *) 0 );
|
1993-03-21 12:45:37 +03:00
|
|
|
indented_code = false;
|
|
|
|
BEGIN(CODEBLOCK);
|
|
|
|
}
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
{WS} return WHITESPACE;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
^"%%".* {
|
|
|
|
sectnum = 2;
|
1993-12-02 22:17:24 +03:00
|
|
|
bracelevel = 0;
|
|
|
|
mark_defs1();
|
|
|
|
line_directive_out( (FILE *) 0 );
|
1993-03-21 12:45:37 +03:00
|
|
|
BEGIN(SECT2PROLOG);
|
1993-12-02 22:17:24 +03:00
|
|
|
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;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
^"%used" {
|
1993-12-02 22:17:24 +03:00
|
|
|
warn( "%used/%unused have been deprecated" );
|
1993-03-21 12:45:37 +03:00
|
|
|
checking_used = REALLY_USED; BEGIN(USED_LIST);
|
|
|
|
}
|
|
|
|
^"%unused" {
|
1993-12-02 22:17:24 +03:00
|
|
|
warn( "%used/%unused have been deprecated" );
|
1993-03-21 12:45:37 +03:00
|
|
|
checking_used = REALLY_NOT_USED; BEGIN(USED_LIST);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
^"%"[aceknopr]{OPTWS}[0-9]*{OPTWS}{NL} ++linenum; /* ignore */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
^"%"[^sxanpekotcru{}].* synerr( "unrecognized '%' directive" );
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
^{NAME} {
|
1993-12-02 22:17:24 +03:00
|
|
|
(void) strcpy( nmstr, yytext );
|
1993-03-21 12:45:37 +03:00
|
|
|
didadef = false;
|
|
|
|
BEGIN(PICKUPDEF);
|
|
|
|
}
|
|
|
|
|
|
|
|
{SCNAME} RETURNNAME;
|
1993-12-02 22:17:24 +03:00
|
|
|
^{OPTWS}{NL} ++linenum; /* allows blank lines in section 1 */
|
|
|
|
{OPTWS}{NL} ++linenum; return '\n';
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<C_COMMENT>"*/" ACTION_ECHO; BEGIN(INITIAL);
|
|
|
|
<C_COMMENT>"*/".*{NL} ++linenum; ACTION_ECHO; BEGIN(INITIAL);
|
|
|
|
<C_COMMENT>[^*\n]+ ACTION_ECHO;
|
|
|
|
<C_COMMENT>"*" ACTION_ECHO;
|
|
|
|
<C_COMMENT>{NL} ++linenum; ACTION_ECHO;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<CODEBLOCK>^"%}".*{NL} ++linenum; BEGIN(INITIAL);
|
|
|
|
<CODEBLOCK>"reject" ACTION_ECHO; CHECK_REJECT(yytext);
|
|
|
|
<CODEBLOCK>"yymore" ACTION_ECHO; CHECK_YYMORE(yytext);
|
|
|
|
<CODEBLOCK>{NAME}|{NOT_NAME}|. ACTION_ECHO;
|
|
|
|
<CODEBLOCK>{NL} {
|
1993-03-21 12:45:37 +03:00
|
|
|
++linenum;
|
1993-12-02 22:17:24 +03:00
|
|
|
ACTION_ECHO;
|
1993-03-21 12:45:37 +03:00
|
|
|
if ( indented_code )
|
1993-12-02 22:17:24 +03:00
|
|
|
BEGIN(INITIAL);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
<PICKUPDEF>{WS} /* separates name and definition */
|
|
|
|
|
|
|
|
<PICKUPDEF>{NOT_WS}.* {
|
1993-12-02 22:17:24 +03:00
|
|
|
(void) strcpy( (char *) nmdef, yytext );
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
/* Skip trailing whitespace. */
|
1993-03-21 12:45:37 +03:00
|
|
|
for ( i = strlen( (char *) nmdef ) - 1;
|
1993-12-02 22:17:24 +03:00
|
|
|
i >= 0 && (nmdef[i] == ' ' || nmdef[i] == '\t');
|
1993-03-21 12:45:37 +03:00
|
|
|
--i )
|
1993-12-02 22:17:24 +03:00
|
|
|
;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
nmdef[i + 1] = '\0';
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
ndinstal( nmstr, nmdef );
|
1993-03-21 12:45:37 +03:00
|
|
|
didadef = true;
|
|
|
|
}
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<PICKUPDEF>{NL} {
|
1993-03-21 12:45:37 +03:00
|
|
|
if ( ! didadef )
|
1993-12-02 22:17:24 +03:00
|
|
|
synerr( "incomplete name definition" );
|
1993-03-21 12:45:37 +03:00
|
|
|
BEGIN(INITIAL);
|
|
|
|
++linenum;
|
|
|
|
}
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<RECOVER>.*{NL} ++linenum; BEGIN(INITIAL); RETURNNAME;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<USED_LIST>{NL} ++linenum; BEGIN(INITIAL);
|
1993-03-21 12:45:37 +03:00
|
|
|
<USED_LIST>{WS}
|
|
|
|
<USED_LIST>"reject" {
|
|
|
|
if ( all_upper( yytext ) )
|
1993-12-02 22:17:24 +03:00
|
|
|
reject_really_used = checking_used;
|
1993-03-21 12:45:37 +03:00
|
|
|
else
|
1993-12-02 22:17:24 +03:00
|
|
|
synerr(
|
|
|
|
"unrecognized %used/%unused construct" );
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
<USED_LIST>"yymore" {
|
|
|
|
if ( all_lower( yytext ) )
|
1993-12-02 22:17:24 +03:00
|
|
|
yymore_really_used = checking_used;
|
1993-03-21 12:45:37 +03:00
|
|
|
else
|
1993-12-02 22:17:24 +03:00
|
|
|
synerr(
|
|
|
|
"unrecognized %used/%unused construct" );
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
<USED_LIST>{NOT_WS}+ synerr( "unrecognized %used/%unused construct" );
|
|
|
|
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<SECT2PROLOG>^"%{".* ++bracelevel; yyless( 2 ); /* eat only %{ */
|
|
|
|
<SECT2PROLOG>^"%}".* --bracelevel; yyless( 2 ); /* eat only %} */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<SECT2PROLOG>^{WS}.* ACTION_ECHO; /* indented code in prolog */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<SECT2PROLOG>^{NOT_WS}.* { /* non-indented code */
|
|
|
|
if ( bracelevel <= 0 )
|
|
|
|
{ /* not in %{ ... %} */
|
|
|
|
yyless( 0 ); /* put it all back */
|
|
|
|
mark_prolog();
|
|
|
|
BEGIN(SECT2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ACTION_ECHO;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<SECT2PROLOG>.* ACTION_ECHO;
|
|
|
|
<SECT2PROLOG>{NL} ++linenum; ACTION_ECHO;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<SECT2PROLOG><<EOF>> {
|
|
|
|
mark_prolog();
|
|
|
|
sectnum = 0;
|
|
|
|
yyterminate(); /* to stop the parser */
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<SECT2>^{OPTWS}{NL} ++linenum; /* allow blank lines in section 2 */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
<SECT2>^({WS}|"%{") {
|
|
|
|
indented_code = (yytext[0] != '%');
|
|
|
|
doing_codeblock = true;
|
|
|
|
bracelevel = 1;
|
|
|
|
|
|
|
|
if ( indented_code )
|
1993-12-02 22:17:24 +03:00
|
|
|
ACTION_ECHO;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
BEGIN(CODEBLOCK_2);
|
|
|
|
}
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<SECT2>^"<" BEGIN(SC); return '<';
|
|
|
|
<SECT2>^"^" return '^';
|
|
|
|
<SECT2>\" BEGIN(QUOTE); return '"';
|
|
|
|
<SECT2>"{"/[0-9] BEGIN(NUM); return '{';
|
1993-03-21 12:45:37 +03:00
|
|
|
<SECT2>"{"[^0-9\n][^}\n]* BEGIN(BRACEERROR);
|
1993-12-02 22:17:24 +03:00
|
|
|
<SECT2>"$"/([ \t]|{NL}) return '$';
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
<SECT2>{WS}"%{" {
|
|
|
|
bracelevel = 1;
|
|
|
|
BEGIN(PERCENT_BRACE_ACTION);
|
1993-12-02 22:17:24 +03:00
|
|
|
return '\n';
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1993-12-02 22:17:24 +03:00
|
|
|
<SECT2>{WS}"|".*{NL} continued_action = true; ++linenum; return '\n';
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
<SECT2>{WS} {
|
1993-12-02 22:17:24 +03:00
|
|
|
/* This rule is separate from the one below because
|
1993-03-21 12:45:37 +03:00
|
|
|
* otherwise we get variable trailing context, so
|
1993-12-02 22:17:24 +03:00
|
|
|
* we can't build the scanner using -{f,F}.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
bracelevel = 0;
|
|
|
|
continued_action = false;
|
|
|
|
BEGIN(ACTION);
|
1993-12-02 22:17:24 +03:00
|
|
|
return '\n';
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<SECT2>{OPTWS}{NL} {
|
1993-03-21 12:45:37 +03:00
|
|
|
bracelevel = 0;
|
|
|
|
continued_action = false;
|
|
|
|
BEGIN(ACTION);
|
1993-12-02 22:17:24 +03:00
|
|
|
unput( '\n' ); /* so <ACTION> sees it */
|
|
|
|
return '\n';
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<SECT2>"<<EOF>>" return EOF_OP;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
<SECT2>^"%%".* {
|
|
|
|
sectnum = 3;
|
|
|
|
BEGIN(SECT3);
|
1993-12-02 22:17:24 +03:00
|
|
|
yyterminate(); /* to stop the parser */
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<SECT2>"["{FIRST_CCL_CHAR}{CCL_CHAR}* {
|
1993-03-21 12:45:37 +03:00
|
|
|
int cclval;
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
(void) strcpy( nmstr, yytext );
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
/* Check to see if we've already encountered this
|
|
|
|
* ccl.
|
|
|
|
*/
|
1993-03-21 12:45:37 +03:00
|
|
|
if ( (cclval = ccllookup( (Char *) nmstr )) )
|
1993-12-02 22:17:24 +03:00
|
|
|
{
|
|
|
|
if ( input() != ']' )
|
|
|
|
synerr( "bad character class" );
|
|
|
|
|
|
|
|
yylval = cclval;
|
|
|
|
++cclreuse;
|
|
|
|
return PREVCCL;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
else
|
1993-12-02 22:17:24 +03:00
|
|
|
{
|
|
|
|
/* We fudge a bit. We know that this ccl will
|
|
|
|
* soon be numbered as lastccl + 1 by cclinit.
|
|
|
|
*/
|
|
|
|
cclinstal( (Char *) nmstr, lastccl + 1 );
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
/* Push back everything but the leading bracket
|
|
|
|
* so the ccl can be rescanned.
|
|
|
|
*/
|
|
|
|
yyless( 1 );
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
BEGIN(FIRSTCCL);
|
|
|
|
return '[';
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
<SECT2>"{"{NAME}"}" {
|
|
|
|
register Char *nmdefptr;
|
|
|
|
Char *ndlookup();
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
(void) strcpy( nmstr, yytext + 1 );
|
|
|
|
nmstr[yyleng - 2] = '\0'; /* chop trailing brace */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
if ( ! (nmdefptr = ndlookup( nmstr )) )
|
|
|
|
format_synerr( "undefined definition {%s}",
|
|
|
|
nmstr );
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
else
|
1993-12-02 22:17:24 +03:00
|
|
|
{ /* 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('(');
|
|
|
|
}
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<SECT2>[/|*+?.()] return (int) yytext[0];
|
1993-03-21 12:45:37 +03:00
|
|
|
<SECT2>. RETURNCHAR;
|
|
|
|
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<SC>[,*] return (int) yytext[0];
|
|
|
|
<SC>">" BEGIN(SECT2); return '>';
|
|
|
|
<SC>">"/^ BEGIN(CARETISBOL); return '>';
|
1993-03-21 12:45:37 +03:00
|
|
|
<SC>{SCNAME} RETURNNAME;
|
1993-12-02 22:17:24 +03:00
|
|
|
<SC>. {
|
|
|
|
format_synerr( "bad <start condition>: %s", yytext );
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<CARETISBOL>"^" BEGIN(SECT2); return '^';
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
|
|
|
|
<QUOTE>[^"\n] RETURNCHAR;
|
1993-12-02 22:17:24 +03:00
|
|
|
<QUOTE>\" BEGIN(SECT2); return '"';
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<QUOTE>{NL} {
|
1993-03-21 12:45:37 +03:00
|
|
|
synerr( "missing quote" );
|
|
|
|
BEGIN(SECT2);
|
|
|
|
++linenum;
|
1993-12-02 22:17:24 +03:00
|
|
|
return '"';
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<FIRSTCCL>"^"/[^-\]\n] BEGIN(CCL); return '^';
|
|
|
|
<FIRSTCCL>"^"/("-"|"]") return '^';
|
1993-03-21 12:45:37 +03:00
|
|
|
<FIRSTCCL>. BEGIN(CCL); RETURNCHAR;
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<CCL>-/[^\]\n] return '-';
|
1993-03-21 12:45:37 +03:00
|
|
|
<CCL>[^\]\n] RETURNCHAR;
|
1993-12-02 22:17:24 +03:00
|
|
|
<CCL>"]" BEGIN(SECT2); return ']';
|
|
|
|
<CCL>.|{NL} {
|
|
|
|
synerr( "bad character class" );
|
|
|
|
BEGIN(SECT2);
|
|
|
|
return ']';
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
|
|
|
|
<NUM>[0-9]+ {
|
|
|
|
yylval = myctoi( yytext );
|
1993-12-02 22:17:24 +03:00
|
|
|
return NUMBER;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<NUM>"," return ',';
|
|
|
|
<NUM>"}" BEGIN(SECT2); return '}';
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
<NUM>. {
|
|
|
|
synerr( "bad character inside {}'s" );
|
|
|
|
BEGIN(SECT2);
|
1993-12-02 22:17:24 +03:00
|
|
|
return '}';
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<NUM>{NL} {
|
1993-03-21 12:45:37 +03:00
|
|
|
synerr( "missing }" );
|
|
|
|
BEGIN(SECT2);
|
|
|
|
++linenum;
|
1993-12-02 22:17:24 +03:00
|
|
|
return '}';
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
<BRACEERROR>"}" synerr( "bad name in {}'s" ); BEGIN(SECT2);
|
1993-12-02 22:17:24 +03:00
|
|
|
<BRACEERROR>{NL} synerr( "missing }" ); ++linenum; BEGIN(SECT2);
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<CODEBLOCK_2>"/*" ACTION_ECHO; BEGIN(ACTION_COMMENT);
|
1993-03-21 12:45:37 +03:00
|
|
|
<PERCENT_BRACE_ACTION,CODEBLOCK_2>{OPTWS}"%}".* bracelevel = 0;
|
|
|
|
<PERCENT_BRACE_ACTION,CODEBLOCK_2,ACTION>"reject" {
|
|
|
|
ACTION_ECHO;
|
|
|
|
CHECK_REJECT(yytext);
|
|
|
|
}
|
|
|
|
<PERCENT_BRACE_ACTION,CODEBLOCK_2,ACTION>"yymore" {
|
|
|
|
ACTION_ECHO;
|
|
|
|
CHECK_YYMORE(yytext);
|
|
|
|
}
|
|
|
|
<PERCENT_BRACE_ACTION,CODEBLOCK_2>{NAME}|{NOT_NAME}|. ACTION_ECHO;
|
1993-12-02 22:17:24 +03:00
|
|
|
<PERCENT_BRACE_ACTION,CODEBLOCK_2>{NL} {
|
1993-03-21 12:45:37 +03:00
|
|
|
++linenum;
|
|
|
|
ACTION_ECHO;
|
|
|
|
if ( bracelevel == 0 ||
|
|
|
|
(doing_codeblock && indented_code) )
|
1993-12-02 22:17:24 +03:00
|
|
|
{
|
|
|
|
if ( ! doing_codeblock )
|
|
|
|
add_action( "\tYY_BREAK\n" );
|
|
|
|
|
|
|
|
doing_codeblock = false;
|
|
|
|
BEGIN(SECT2);
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Reject and YYmore() are checked for above, in PERCENT_BRACE_ACTION */
|
|
|
|
<ACTION>"{" ACTION_ECHO; ++bracelevel;
|
|
|
|
<ACTION>"}" ACTION_ECHO; --bracelevel;
|
|
|
|
<ACTION>[^a-z_{}"'/\n]+ ACTION_ECHO;
|
|
|
|
<ACTION>{NAME} ACTION_ECHO;
|
|
|
|
<ACTION>"/*" ACTION_ECHO; BEGIN(ACTION_COMMENT);
|
|
|
|
<ACTION>"'"([^'\\\n]|\\.)*"'" ACTION_ECHO; /* character constant */
|
|
|
|
<ACTION>\" ACTION_ECHO; BEGIN(ACTION_STRING);
|
1993-12-02 22:17:24 +03:00
|
|
|
<ACTION>{NL} {
|
1993-03-21 12:45:37 +03:00
|
|
|
++linenum;
|
|
|
|
ACTION_ECHO;
|
|
|
|
if ( bracelevel == 0 )
|
1993-12-02 22:17:24 +03:00
|
|
|
{
|
|
|
|
add_action( "\tYY_BREAK\n" );
|
|
|
|
BEGIN(SECT2);
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
<ACTION>. ACTION_ECHO;
|
|
|
|
|
1993-12-02 22:17:24 +03:00
|
|
|
<ACTION_COMMENT>"*/" {
|
|
|
|
ACTION_ECHO;
|
|
|
|
if ( doing_codeblock )
|
|
|
|
BEGIN(CODEBLOCK_2);
|
|
|
|
else
|
|
|
|
BEGIN(ACTION);
|
|
|
|
}
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
<ACTION_COMMENT>"*" ACTION_ECHO;
|
1993-12-02 22:17:24 +03:00
|
|
|
<ACTION_COMMENT>[^*\n]+ ACTION_ECHO;
|
|
|
|
<ACTION_COMMENT>[^*\n]*{NL} ++linenum; ACTION_ECHO;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
<ACTION_STRING>[^"\\\n]+ ACTION_ECHO;
|
|
|
|
<ACTION_STRING>\\. ACTION_ECHO;
|
1993-12-02 22:17:24 +03:00
|
|
|
<ACTION_STRING>{NL} ++linenum; ACTION_ECHO;
|
1993-03-21 12:45:37 +03:00
|
|
|
<ACTION_STRING>\" ACTION_ECHO; BEGIN(ACTION);
|
|
|
|
<ACTION_STRING>. ACTION_ECHO;
|
|
|
|
|
|
|
|
<ACTION,ACTION_COMMENT,ACTION_STRING><<EOF>> {
|
|
|
|
synerr( "EOF encountered inside an action" );
|
|
|
|
yyterminate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
<SECT2,QUOTE,CCL>{ESCSEQ} {
|
1993-12-02 22:17:24 +03:00
|
|
|
yylval = myesc( (Char *) yytext );
|
|
|
|
return CHAR;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
<FIRSTCCL>{ESCSEQ} {
|
1993-12-02 22:17:24 +03:00
|
|
|
yylval = myesc( (Char *) yytext );
|
1993-03-21 12:45:37 +03:00
|
|
|
BEGIN(CCL);
|
1993-12-02 22:17:24 +03:00
|
|
|
return CHAR;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
<SECT3>.*(\n?) ECHO;
|
1993-12-02 22:17:24 +03:00
|
|
|
<SECT3><<EOF>> sectnum = 0; yyterminate();
|
|
|
|
|
|
|
|
<*>.|\n format_synerr( "bad character: %s", yytext );
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
%%
|
|
|
|
|
|
|
|
|
|
|
|
int yywrap()
|
|
|
|
{
|
1993-12-02 22:17:24 +03:00
|
|
|
if ( --num_input_files > 0 )
|
|
|
|
{
|
|
|
|
set_input_file( *++input_files );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
return 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* set_input_file - open the given file (if NULL, stdin) for scanning */
|
|
|
|
|
|
|
|
void set_input_file( file )
|
|
|
|
char *file;
|
|
|
|
{
|
1993-12-02 22:17:24 +03:00
|
|
|
if ( file )
|
|
|
|
{
|
|
|
|
infilename = file;
|
|
|
|
yyin = fopen( infilename, "r" );
|
|
|
|
|
|
|
|
if ( yyin == NULL )
|
|
|
|
lerrsf( "can't open %s", file );
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
yyin = stdin;
|
|
|
|
infilename = "<stdin>";
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|