confparse.l revision 7c478bd95313f5f23a4c958a745db2134aa03244
%{
/*
* 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) 2001 by Sun Microsystems, Inc.
* All rights reserved.
*
* Lexical analyzer used for parsing wrsm cluster configuration files
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <strings.h>
#include <ctype.h>
#include <sys/wrsm_config.h>
#include "confparse.tab.h"
int ErrorCount = 0;
int lineNumber = 1;
int lexdebug = 0;
typedef struct reserved {
char *name;
int id;
} reserved_t;
static int lookup_reserved(char *name);
/*
* For debugging purposes, ECHO can be defined to print tokens
* as they are reduced.
*/
#ifdef ECHO
#define ECHO
#endif
/*
* If lexdebug it turned on, print each token value and string
* before they are returned.
*/
%}
DIGIT [0-9]
WS [\t ]
%%
"//".* { ECHO; }
"#".* { ECHO; }
{INTEGER} {
ECHO;
}
{HEX} {
ECHO;
}
"central_switch" {
}
"distributed_switch" {
ECHO;
}
{ID} {
int id;
ECHO;
}
}
. {
/*
* If none of the rules above matched there must be an
* unrecognized character, so fall through to here.
*/
ECHO;
else
++ErrorCount;
}
%%
reserved_t res_words[] = {
{"fmnodeid", FMNODEID},
{"controller", CONTROLLER},
{"version", VERSION},
{"config_protocol_version", CONF_PROTOCOL_VERSION},
{"local_cnodeid", LOCAL_CNODEID},
{"imported_ncslices", IMPORTED_NCSLICES},
{"exported_ncslices", EXPORTED_NCSLICES},
{"cnodeid", CNODEID},
{"comm_ncslice", COMM_NCSLICE},
{"local_offset", LOCAL_OFFSET},
{"small", SMALL},
{"large", LARGE},
{"wci", WCI},
{"safari_port_id", SAFARI_PORT_ID},
{"wnodeid", WNODEID},
{"gnid", GNID},
{"reachable", REACHABLE},
{"route_map_striping", ROUTE_MAP_STRIPING},
{"topology_type", TOPOLOGY_TYPE},
{"link", LINK},
{"remote_gnid", REMOTE_GNID},
{"remote_link", REMOTE_LINK},
{"remote_wci", REMOTE_WCI},
{"routing_policy", ROUTING_POLICY},
{"preferred_routes", PREFERRED_ROUTES},
{"wcis_balanced", WCIS_BALANCED},
{"striping_important", STRIPING_IMPORTANT},
{"forwarding_ncslices", FORWARDING_NCSLICES},
{"preferred_route", PREFERRED_ROUTE},
{"striping_level", STRIPING_LEVEL},
{"routing_method", ROUTING_METHOD},
{"use_wci", USE_WCI},
{"stripe_group", STRIPE_GROUP},
{"wcis", WCIS},
{"switches", SWITCHES},
{(char *)0,0}
};
/*
* lookup_reserved is called when an identifier is found (letter
* followed by letters, digits or _) to scan the above list of
* keywords. If a match is found, return the associated token
* value, otherwise return 0.
*/
static int lookup_reserved(char *name)
{
int i = 0;
++i;
}
return 0;
}
/*
* Called from yyparse if it finds an error. s is a string
* describing the type of error found.
*/
void yyerror(char *s)
{
extern char yytext[1024];
ErrorCount++;
}
int yywrap()
{
return 1;
}
void
{
ErrorCount = 0;
lineNumber = 1;
lexdebug = 0;
}