diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y index 4db2c80e3ea3..8959e6c2b142 100644 --- a/usr.sbin/config/config.y +++ b/usr.sbin/config/config.y @@ -59,8 +59,7 @@ %token FPNUMBER %type Save_id -%type Opt_name -%type Opt_string +%type Opt_value %type Dev %type device_name %type 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 30cf8059fa1c..3e47f5e5bb92 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} { +{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; } +{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; + } +{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; + } +[^#\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]; }