awk.lx.l revision 7c478bd95313f5f23a4c958a745db2134aa03244
%{
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
%}
%{
/* All Rights Reserved */
%}
%{
/* */
%}
%{
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1996, 2001 by Sun Microsystems, Inc. */
/* All rights reserved. */
%}
%{
/* */
%}
%{
#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 2.9 */
%}
%{
#include "awk.h"
#include "y.tab.h"
extern int infunc;
int bracecnt = 0;
int brackcnt = 0;
int parencnt = 0;
#define DEBUG
#ifdef DEBUG
#else
# define RET(x) return(x)
#endif
BEGIN A; \
}
uchar *s;
%}
D [0-9]
O [0-7]
H [0-9a-fA-F]
WS [ \t]
%%
case 0:
BEGIN A;
break;
case sc:
BEGIN A;
RET('}');
}
<A>#.* { ; } /* strip comments */
<A>{WS}+ { ; }
<A>; { RET(';'); }
<A>"\\"\n { lineno++; }
<A>"$"{A}{B}* { int c, n;
return(INDIRECT);
} else {
}
}
<A>({D}+("."?){D}*|"."{D}+)((e|E)("+"|-)?{D}+)? {
<A>{A}{B}* { int n, c;
yylval.i = n;
} else {
if (c == '(') {
} else {
}
}
}
<A>\" { BEGIN str; clen = 0; }
<A>. { if (yytext[0] == '{') bracecnt++;
else if (yytext[0] == '[') brackcnt++;
else if (yytext[0] == '(') parencnt++;
RET(yylval.i = yytext[0]); /* everything else */ }
<reg>\\. { cbuf[clen++] = '\\'; cbuf[clen++] = yytext[1]; }
<reg>"/" { BEGIN A;
cbuf[clen] = 0;
yylval.s = tostring(cbuf);
unput('/');
RET(REGEXPR); }
<reg>. { CADD; }
<str>\" { BEGIN A;
cbuf[clen] = 0; s = tostring(cbuf);
cbuf[clen] = ' '; cbuf[++clen] = 0;
yylval.cp = setsymtab(cbuf, s, 0.0, CON|STR, symtab);
RET(STRING); }
<str>"\\"({O}{O}{O}|{O}{O}|{O}) { int n;
%%
startreg()
{
clen = 0;
}
/* input() and unput() are transcriptions of the standard lex
macros for input and output with additions for error message
printing. God help us all if someone changes how lex works.
*/
input()
{
register int c;
c = U(*--yysptr);
c = *lexprog++;
else /* awk -f ... */
c = pgetc();
if (c == '\n')
yylineno++;
else if (c == EOF)
c = 0;
return *ep++ = c;
}
unput(c)
{
yytchar = c;
if (yytchar == '\n')
yylineno--;
}
unputstr(s)
char *s;
{
int i;
for (i = strlen(s)-1; i >= 0; i--)
unput(s[i]);
}