summaryrefslogtreecommitdiffstats
path: root/usr.sbin/config/lang.l
diff options
context:
space:
mode:
authorluoqi <luoqi@FreeBSD.org>1999-04-27 01:37:01 +0000
committerluoqi <luoqi@FreeBSD.org>1999-04-27 01:37:01 +0000
commitf768143bcbe1b88f2316e3b88ba9246ec710d667 (patch)
treed4af1079d5fc467511dfc6b294a678518eeabb50 /usr.sbin/config/lang.l
parent1ee0c6ceb26e31e29133c72ad27d3f2d16b410bd (diff)
downloadFreeBSD-src-f768143bcbe1b88f2316e3b88ba9246ec710d667.zip
FreeBSD-src-f768143bcbe1b88f2316e3b88ba9246ec710d667.tar.gz
Make options like NO_F00F_HACK work (with context sensitive lexical rules).
Diffstat (limited to 'usr.sbin/config/lang.l')
-rw-r--r--usr.sbin/config/lang.l50
1 files changed, 38 insertions, 12 deletions
diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l
index 30cf805..3e47f5e 100644
--- a/usr.sbin/config/lang.l
+++ b/usr.sbin/config/lang.l
@@ -105,11 +105,14 @@ int octal __P((char *));
int hex __P((char *));
%}
-WORD [-A-Za-z_][-A-Za-z_]*
+WORD [A-Za-z_][-A-Za-z_]*
+ID [A-Za-z_][-A-Za-z_0-9]*
+%START NONUM TOEOL
%%
-{WORD} {
+<NONUM>{WORD} {
int i;
+ BEGIN 0;
if ((i = kw_lookup(yytext)) == -1)
{
yylval.str = strdup(yytext);
@@ -119,15 +122,42 @@ WORD [-A-Za-z_][-A-Za-z_]*
tprintf("(%s) ", yytext);
return i;
}
+<INITIAL>{WORD}/[0-9]* {
+ int i;
+
+ if ((i = kw_lookup(yytext)) == -1)
+ REJECT;
+ if (i == CONTROLLER || i == DEVICE || i == DISK ||
+ i == PSEUDO_DEVICE || i == AT || i == ON)
+ BEGIN NONUM;
+ tprintf("(%s) ", yytext);
+ return i;
+ }
+<INITIAL>{ID} {
+ BEGIN 0;
+ yylval.str = strdup(yytext);
+ tprintf("id(%s) ", yytext);
+ return ID;
+ }
\\\"[^"]+\\\" {
- yytext[strlen(yytext)-2] = '"';
- yytext[strlen(yytext)-1] = '\0';
+ BEGIN 0;
+ yytext[yyleng-2] = '"';
+ yytext[yyleng-1] = '\0';
yylval.str = strdup(yytext + 1);
+ tprintf("id(%s) ", yytext+1);
return ID;
}
\"[^"]+\" {
- yytext[strlen(yytext)-1] = '\0';
+ BEGIN 0;
+ yytext[yyleng-1] = '\0';
yylval.str = strdup(yytext + 1);
+ tprintf("id(%s) ", yytext+1);
+ return ID;
+ }
+<TOEOL>[^#\n]* {
+ BEGIN 0;
+ yylval.str = strdup(yytext);
+ tprintf("id(%s) ", yytext);
return ID;
}
0[0-7]* {
@@ -140,18 +170,14 @@ WORD [-A-Za-z_][-A-Za-z_]*
tprintf("#X:%x ", yylval.val);
return NUMBER;
}
--[1-9][0-9]* {
- yylval.val = atoi(yytext);
- tprintf("#D:%d ", yylval.val);
- return NUMBER;
- }
-[1-9][0-9]* {
+-?[1-9][0-9]* {
yylval.val = atoi(yytext);
tprintf("#D:%d ", yylval.val);
return NUMBER;
}
[0-9]"."[0-9]* {
yylval.val = (int) (60 * atof(yytext) + 0.5);
+ tprintf("#F:%d ", yylval.val);
return FPNUMBER;
}
"?" {
@@ -172,7 +198,7 @@ WORD [-A-Za-z_][-A-Za-z_]*
[ \t\f]* { /* Ignored (white space) */; }
";" { return SEMICOLON; }
"," { return COMMA; }
-"=" { return EQUALS; }
+"=" { BEGIN TOEOL; return EQUALS; }
"@" { return AT; }
. { return yytext[0]; }
OpenPOWER on IntegriCloud