FreeBSD/contrib/bsnmp/gensnmptree/gensnmptree.c
/*
 * Parse a type. We've seen the ENUM or type keyword already. Leave next
 * token.
 */
Parse a type. We've seen the ENUM or type keyword already. Leave next
token.
Parse a type . We ' ve seen the ENUM or type keyword already . Leave next token .
static u_int
parse_type(enum tok *tok, struct type *t, const char *vname)
{
	u_int syntax;
	struct enums *e;
	syntax = val;
	if (*tok == TOK_ENUM || *tok == TOK_BITS) {
		if (t == NULL && vname != NULL) {
			t = make_type(vname);
			t->is_enum = (*tok == TOK_ENUM);
			t->is_bits = (*tok == TOK_BITS);
			t->syntax = syntax;
		}
		if (gettoken() != '(')
			report("'(' expected after ENUM");
		if ((*tok = gettoken()) == TOK_EOF)
			report("unexpected EOF in ENUM");
		do {
			e = NULL;
			if (t != NULL) {
				e = xalloc(sizeof(*e));
			}
			if (*tok == '-') {
				if ((*tok = gettoken()) == TOK_EOF)
					report("unexpected EOF in ENUM");
				e->value = -(long)val;
			} else
				e->value = val;
			if (*tok != TOK_NUM)
				report("need value for ENUM/BITS");
			if (gettoken() != TOK_STR)
				report("need string in ENUM/BITS");
			e->name = savetok();
			TAILQ_INSERT_TAIL(&t->enums, e, link);
			if ((*tok = gettoken()) == TOK_EOF)
				report("unexpected EOF in ENUM/BITS");
		} while (*tok != ')');
		*tok = gettoken();
	} else if (*tok == TOK_DEFTYPE) {
		*tok = gettoken();
	} else {
		if ((*tok = gettoken()) == '|') {
			if (gettoken() != TOK_STR)
				report("subtype expected after '|'");
			*tok = gettoken();
		}
	}
	return (syntax);
}
static u_int parse_type ( enum tok * tok , struct type * t , const char * vname ) { u_int syntax ; struct enums * e ; syntax = val ; if ( * tok == TOK_ENUM || * tok == TOK_BITS ) { if ( t == NULL && vname != NULL ) { t = make_type ( vname ) ; t -> is_enum = ( * tok == TOK_ENUM ) ; t -> is_bits = ( * tok == TOK_BITS ) ; t -> syntax = syntax ; } if ( gettoken ( ) != ' ' ) report ( " " ) ; if ( ( * tok = gettoken ( ) ) == TOK_EOF ) report ( " " ) ; do { e = NULL ; if ( t != NULL ) { e = xalloc ( sizeof ( * e ) ) ; } if ( * tok == ' ' ) { if ( ( * tok = gettoken ( ) ) == TOK_EOF ) report ( " " ) ; e -> value = - ( long ) val ; } else e -> value = val ; if ( * tok != TOK_NUM ) report ( " " ) ; if ( gettoken ( ) != TOK_STR ) report ( " " ) ; e -> name = savetok ( ) ; TAILQ_INSERT_TAIL ( & t -> enums , e , link ) ; if ( ( * tok = gettoken ( ) ) == TOK_EOF ) report ( " " ) ; } while ( * tok != ' ' ) ; * tok = gettoken ( ) ; } else if ( * tok == TOK_DEFTYPE ) { * tok = gettoken ( ) ; } else { if ( ( * tok = gettoken ( ) ) == ' ' ) { if ( gettoken ( ) != TOK_STR ) report ( " " ) ; * tok = gettoken ( ) ; } } return ( syntax ) ; }
Parse a type.
Parse a type .