summaryrefslogtreecommitdiffstats
path: root/usr.sbin/config
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
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')
-rw-r--r--usr.sbin/config/config.y25
-rw-r--r--usr.sbin/config/lang.l50
2 files changed, 45 insertions, 30 deletions
diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y
index 4db2c80..8959e6c 100644
--- a/usr.sbin/config/config.y
+++ b/usr.sbin/config/config.y
@@ -59,8 +59,7 @@
%token <val> FPNUMBER
%type <str> Save_id
-%type <str> Opt_name
-%type <str> Opt_string
+%type <str> Opt_value
%type <str> Dev
%type <str> device_name
%type <val> major_minor
@@ -165,7 +164,7 @@ Spec:
;
Config_spec:
- MACHINE Opt_string
+ MACHINE Save_id
= {
if (!strcmp($2, "i386")) {
machine = MACHINE_I386;
@@ -179,7 +178,7 @@ Config_spec:
} else
yyerror("Unknown machine type");
} |
- CPU Opt_string
+ CPU Save_id
= {
struct cputype *cp =
(struct cputype *)malloc(sizeof (struct cputype));
@@ -385,7 +384,7 @@ Opt_list:
;
Option:
- Opt_string
+ Save_id
= {
struct opt *op = (struct opt *)malloc(sizeof (struct opt));
char *s;
@@ -405,7 +404,7 @@ Option:
op->op_value = ns(s + 1);
}
} |
- Opt_string EQUALS Opt_string
+ Save_id EQUALS Opt_value
= {
struct opt *op = (struct opt *)malloc(sizeof (struct opt));
memset(op, 0, sizeof(*op));
@@ -416,7 +415,7 @@ Option:
opt = op;
} ;
-Opt_name:
+Opt_value:
ID
= { $$ = $1; } |
NUMBER
@@ -426,16 +425,6 @@ Opt_name:
(void) snprintf(buf, sizeof(buf), "%d", $1);
$$ = ns(buf);
} ;
-Opt_string:
- Opt_name
- = { $$ = $1; } |
- Opt_name Opt_string
- = {
- char buf[80];
-
- (void) snprintf(buf, sizeof(buf), "%s%s", $1, $2);
- $$ = ns(buf); free($1); free($2);
- } ;
Save_id:
ID
@@ -449,7 +438,7 @@ Mkopt_list:
;
Mkoption:
- Opt_string EQUALS Opt_string
+ Save_id EQUALS Opt_value
= {
struct opt *op = (struct opt *)malloc(sizeof (struct opt));
memset(op, 0, sizeof(*op));
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