示例#1
1
文件: parser.c 项目: Saruta/a2c
struct prog *parse(void)
{
  lookahead[0] = gettok(); lookahead[1] = gettok();
  struct prog *prog = parse_prog();
  freetok(tok); freetok(lookahead[0]); freetok(lookahead[1]);
  return prog;
}
示例#2
1
文件: parse.c 项目: yogmk/prog
int 
factor()
{
	int value = 0;

	switch (token)
	{
		case lparen:	gettok();
						value = expression();
						if (token != rparen)
							puts("missing ')'");
						else
							gettok();
						break;

		case number:	--pos;
						value = getnumber();
						gettok();
						break;
	
		default:		puts("error: expecting number or '('");
						break;
	}
	return value;
}
示例#3
0
/**
 * Parses \<nidrange\> token of the syntax.
 *
 * \retval 1 if \a src parses to \<addrrange\> '@' \<net\>
 * \retval 0 otherwise
 */
static int
parse_nidrange(struct lstr *src, cfs_list_t *nidlist)
{
    struct lstr addrrange, net, tmp;
    struct nidrange *nr;

    tmp = *src;
    if (gettok(src, '@', &addrrange) == 0)
        goto failed;

    if (gettok(src, '@', &net) == 0 || src->ls_str != NULL)
        goto failed;

    nr = add_nidrange(&net, nidlist);
    if (nr == NULL)
        goto failed;

    if (!parse_addrange(&addrrange, nr))
        goto failed;

    return 1;
failed:
    CWARN("can't parse nidrange: \"%.*s\"\n", tmp.ls_len, tmp.ls_str);
    return 0;
}
示例#4
0
文件: cron.c 项目: 99years/plan9
/*
 * return the next time range (as a bit vector) in the file:
 * times: '*'
 * 	| range
 * range: number
 *	| number '-' number
 *	| range ',' range
 * a return of zero means a syntax error was discovered
 */
uvlong
gettime(int min, int max)
{
	uvlong n, m, e;

	if(gettok(min, max) == '*')
		return ~0ULL;
	n = 0;
	while(tok == '1'){
		m = 1ULL << lexval;
		n |= m;
		if(gettok(0, 0) == '-'){
			if(gettok(lexval, max) != '1')
				return 0;
			e = 1ULL << lexval;
			for( ; m <= e; m <<= 1)
				n |= m;
			gettok(min, max);
		}
		if(tok != ',')
			break;
		if(gettok(min, max) != '1')
			return 0;
	}
	pushtok();
	return n;
}
示例#5
0
文件: syntax.c 项目: E-LLP/VICAR
    FUNCTION BOOL dash_dash (FAST struct SYNBLK	*sb)
    {
    TEXT    token[TOKESIZ+1];
    CODE    toke_type;
    TEXT    *init_pos;
    
    init_pos = SAVPOS;
    toke_type = gettok(sb, token);
    if (toke_type == S_WHITE)
        toke_type = gettok(sb, token);
    if (toke_type == '-')
        {
	toke_type = gettok(sb, token);		/* look for 2nd dash 	*/
	if (toke_type == '-')
	    {
	    toke_type = gettok(sb, token);	/* get separator	*/
	    if (toke_type == S_WHITE || toke_type == S_COMSEP ||
	        toke_type == EOS)
		{
		(*sb).lstcg = toke_type;
	        return (TRUE);
		}
	    }
	}
    SETPOS(init_pos);				/* return to init pos	*/
    return (FALSE);
    }	    
示例#6
0
void IFCParser::parselist(wistream& is, Attribute& args)
{
	args.clear();

	wstring tok;
	while ((tok = lookahead(is)).length() > 0) {
		if (tok[0] == L',') {
			gettok(is);
			continue;	// more
		}

		if (tok[0] == L')')
			break;

		if (tok[0] == L'(') {
			Attribute* f = new Attribute();	// add a list
			parseargs(is, *f);
			args.add(f);
			continue;
		}

		tok = gettok(is);

		args.add(tok);	// add a value
	}
}
示例#7
0
文件: error.c 项目: Izhido/qrevpak
void test(int tok, char set[]) {
	if (t == tok)
		t = gettok();
	else {
		expect(tok);
		skipto(tok, set);
		if (t == tok)
			t = gettok();
	}
}
示例#8
0
void IFCParser::parseargs(wistream& is, Attribute& args)
{
	args.clear();

	wstring tok = gettok(is);	// '('

	parselist(is, args);

	tok = gettok(is);					// ')'	
}
示例#9
0
文件: port.c 项目: davecb/port
/*
 * parse -- parse the contents of a regular line
 */
 static int
parse(char *buffer, int *lineNo, char *file) {
	int	curlyLevel = 0;
	char	*p, nextc = '\0';
	const char *skip = " \t\n~!@#$%^&*()-+=[]|;<>,./?";
		/* This used to contain :s */
	ISSUE	*q;

	for (p=gettok(buffer, skip, &nextc); p != NULL;
					p = gettok(NULL, skip, &nextc)) {
#ifdef DEBUG	  
		(void) fprintf(stderr, ">> \"%s\"\n", p);
#endif
		
		if (isalnum(*p) || *p == '_') {
			/* Alphanumeric token. */
			if ((q = inDatabase(p)) != NULL
			   && (q->keyword == YES 
                               || followingParen(p, nextc) != 0)) {

				report(p, q, file, *lineNo,
				       (int)(ErrnoLevel >= curlyLevel));
			}
			else if (strstr(p, "errno") != NULL) {
				/* errno is mentioned. */
				ErrnoLevel = curlyLevel;
			}
		}
		else if (*p == '"' || *p == '\'') {
			/* Quoted string or character. */
			/*EMPTY */
			;
		}
		else if (*p == '{') {
			curlyLevel++;
		}

		else if (*p == '}') {
			if (ErrnoLevel == curlyLevel) {
				/* We passed the closing curly of */
				/* its declaration, turn it off. */
				ErrnoLevel = -1;
			}
			curlyLevel--;
		}
		else {
			/* End of line (or false negative). */
			break;
		}
	}
	return 0;
 }
示例#10
0
/* pragma - handle #pragma ref id... */
static void pragma(void) {
	if ((t = gettok()) == ID && strcmp(token, "ref") == 0)
		for (;;) {
			while (*cp == ' ' || *cp == '\t')
				cp++;
			if (*cp == '\n' || *cp == 0)
				break;
			if ((t = gettok()) == ID && tsym) {
				tsym->ref++;
				use(tsym, src);
			}
		}
}
示例#11
0
文件: syntax.c 项目: E-LLP/VICAR
FUNCTION CODE getkey 
(
    FAST struct SYNBLK	*sb,		/* in/out: symbol table		*/
    TEXT		key[TOKESIZ+1]	/* out: parameter name		*/

 )
    {
    FAST CODE	code;
    FAST CODE	toktyp;			/* token type				*/
    TEXT	dummy[TOKESIZ+1];

    key[0] = EOS;
    code = SUCCESS;
    if ((toktyp = gettok(sb, key)) == S_WHITE)	/* get token into key		*/
	toktyp = gettok(sb, key);	/* if white, get another		*/
    if (toktyp == S_COMSEP)		/* if comma separator			*/
	code = S_NONE;
    else if (toktyp == EOS)
	if ((*sb).lstcg == S_COMSEP)	/* if following comma			*/
	    {
	    code = S_NONE;		/* null value				*/
	    (*sb).lstcg = EOS;
	    }
	else				/* otherwise				*/
	    code = EOS;			/* end of command stream		*/
    else if (toktyp == FLAG_CHAR)	/* start of flagged keyword?	*/
	code = S_KEYWORD;
    else if (toktyp != S_ALPHA && toktyp != S_QALPHA)
	{
	(*sb).errchr = (*sb).curchr - 1;/* point to where error detected	*/
	synerr(sb, "Invalid parameter name");	/* put EM in syntax block	*/
	code = S_SYNERR;
	}
    else				/* got a keyword (or positional value)	*/
	{
	if ((toktyp = gettok(sb, dummy)) == S_WHITE)	/* eat the "="		*/
	    toktyp = gettok(sb, dummy);
	if (toktyp ==  '=')		/* if trailing "=" was present		*/
	    {
	    if (s_length(key) > F_Q_NAMESIZ)
		{
		(*sb).errchr = (*sb).curchr - 1;
		synerr(sb, "Parameter name too long");
		code = S_SYNERR;
		}
	    }
	else				/* else no trailing blank, so...	*/
	    code = S_NONE;		/* value without keyword		*/
	}
    return(code);
    }
示例#12
0
文件: a2pb.c 项目: joseph8th/unm-cs
/* process input line
 * ALL FOREGROUND version 
 */
int procline(void)
{
  char *arg[MAXARG + 1];   /* pointer array for runcommand */
  int toktype;		  /* type of token in command     */
  int narg = 0;           /* number of arguments so far   */
  int ran;                /* error code for runcommand()  */

  for(;;) {
    /* take action according to token type */
    switch(toktype = gettok(&arg[narg])) {
    case ARG:
      if (narg<MAXARG) narg++;
      break;
    case EOL:
      if (narg != 0) {
        arg[narg] = '\0';
        ran = runcommand(arg, narg, FOREGROUND);
      }
      return ran;
    case SEMICOLON:
    case AMPERSAND:
      /* change to BACKGROUND and add routine
       * to runcommand() to add run in background
       */
      if (narg != 0) {
        arg[narg] = '\0';
        ran = runcommand(arg, narg, FOREGROUND);
        if (ran == -1) return ran;
      }
      narg = 0;
      break;
    }
  }
}
示例#13
0
文件: parse.c 项目: yogmk/prog
void
parse (void)
{
	pos = 0; token = 0;
	gettok();
	statement();
}
示例#14
0
文件: error.c 项目: pipul/lab
void skipto(int tok, char set[])
{
    int n;
    char *s;

    assert(set);
    for (n = 0; t != EOI && t != tok; t = gettok()) {
        for (s = set; *s && kind[t] != *s; s++)
            ;
        if (kind[t] == *s)
            break;
        if (n++ == 0)
            error("skipping");
        if (n <= 8)
            printtoken();
        else if (n == 9)
            fprint(stderr, " ...");
    }
    if (n > 8) {
        fprint(stderr, " up to");
        printtoken();
    }
    if (n > 0)
        fprint(stderr, "\n");
}
示例#15
0
static Tree expr3(int k) {
	int k1;
	Tree p = unary();

	for (k1 = prec[t]; k1 >= k; k1--)
		while (prec[t] == k1 && *cp != '=') {
			Tree r;
			Coordinate pt;
			int op = t;
			t = gettok();
			pt = src;
			p = pointer(p);

			if (op == ANDAND || op == OROR) {
				r = pointer(expr3(k1));

				if (events.points)
					apply(events.points, &pt, &r);
			} else
				r = pointer(expr3(k1 + 1));
			p = (*optree[op])(oper[op], p, r);
		}

	return p;
}
示例#16
0
static Tree expr2(void) {
	Tree p = expr3(4);

	if (t == '?') {
		Tree l, r;
		Coordinate pts[2];

		if (Aflag > 1 && isfunc(p->type))
			warning("%s used in a conditional expression\n", funcname(p));
		p = pointer(p);
		t = gettok();
		pts[0] = src;
		l = pointer(expr(':'));
		pts[1] = src;
		r = pointer(expr2());

		if (events.points) {
				apply(events.points, &pts[0], &l);
				apply(events.points, &pts[1], &r);
			}

		p = condtree(p, l, r);
	}

	return p;
}
示例#17
0
void
yylex(void)
{
    if (tok == LEXERR)
	return;
    do
	tok = gettok();
    while (tok != ENDINPUT && exalias());
    if (tok == NEWLIN || tok == ENDINPUT) {
	while (hdocs) {
	    struct heredocs *next = hdocs->next;
	    char *name;

	    hwbegin(0);
	    cmdpush(hdocs->type == REDIR_HEREDOC ? CS_HEREDOC : CS_HEREDOCD);
	    STOPHIST
	    name = gethere(hdocs->str, hdocs->type);
	    ALLOWHIST
	    cmdpop();
	    hwend();
	    setheredoc(hdocs->pc, REDIR_HERESTR, name);
	    zfree(hdocs, sizeof(struct heredocs));
	    hdocs = next;
	}
    }
    if (tok != NEWLIN)
	isnewlin = 0;
    else
	isnewlin = (inbufct) ? -1 : 1;
    if (tok == SEMI || tok == NEWLIN)
	tok = SEPER;
}
示例#18
0
/**
 * Parses \<range_expr\> token of the syntax.
 *
 * \retval pointer to allocated range_expr and initialized
 * range_expr::re_lo, range_expr::re_hi and range_expr:re_stride if \a
 `* src parses to
 * \<number\> |
 * \<number\> '-' \<number\> |
 * \<number\> '-' \<number\> '/' \<number\>
 * \retval NULL othersize
 */
static struct range_expr *
parse_range_expr(struct lstr *src, unsigned min, unsigned max)
{
    struct lstr tok;
    struct range_expr *expr;

    LIBCFS_ALLOC(expr, sizeof(struct range_expr));
    if (expr == NULL)
        return NULL;

    if (libcfs_str2num_check(src->ls_str, src->ls_len, &expr->re_lo,
                             min, max)) {
        /* <number> is parsed */
        expr->re_hi = expr->re_lo;
        expr->re_stride = 1;
        return expr;
    }

    if (!gettok(src, '-', &tok))
        goto failed;
    if (!libcfs_str2num_check(tok.ls_str, tok.ls_len, &expr->re_lo,
                              min, max))
        goto failed;
    /* <number> - */
    if (libcfs_str2num_check(src->ls_str, src->ls_len, &expr->re_hi,
                             min, max)) {
        /* <number> - <number> is parsed */
        expr->re_stride = 1;
        return expr;
    }

    /* go to check <number> '-' <number> '/' <number> */
    if (gettok(src, '/', &tok)) {
        if (!libcfs_str2num_check(tok.ls_str, tok.ls_len,
                                  &expr->re_hi, min, max))
            goto failed;
        /* <number> - <number> / ... */
        if (libcfs_str2num_check(src->ls_str, src->ls_len,
                                 &expr->re_stride, min, max))
            /* <number> - <number> / <number> is parsed */
            return expr;
    }

failed:
    LIBCFS_FREE(expr, sizeof(struct range_expr));
    return NULL;
}
示例#19
0
文件: func.c 项目: chrisl212/lang
struct func *strtofunc(const char *s, struct func *f, struct expr *expr, struct dict *funcs) {
    char *argstr, *funcname, *tok, *funcpy;
    struct func *call, *funcarg;
    struct token *atok;
    struct var *arg;
    
    tok = strdup(s);
    
    while (isspace(*tok)) tok++; /* remove leading whitespace */
    if (!strpbrk(tok, " ")) {
        call = dictobj(funcs, tok);
        if (!call)
            error(-1, "No such function %s\nLine: %s\n", funcname, expr->expr);
        call->args = arrnew(NULL);
        return call;
    }
    argstr = strdup(strpbrk(tok, " "));
    funcname = strtok(tok, " ");
    call = dictobj(funcs, funcname);
    if (!call) 
        error(-1, "No such function %s\nLine: %s\n", funcname, expr->expr);
    call->args = arrnew(NULL);
    arg = NULL;
    
    atok = gettok(argstr);
    /* funcname becomes the name of the arg here */
    while (atok != NULL) {
        funcname = atok->tok;
        switch (atok->type) {
            case T_LIT:
                arg = strtolit(atok->tok, f, expr);
                arg->name = funcname;
                break;
            case T_VAR:
                arg = dictobj(f->scope, funcname);
                if (!arg)
                    error(-2, "No such variable %s\nLine: %s\n", funcname, expr->expr);
                break;
            case T_FUNC:
                funcpy = strdup(atok->tok);
                funcpy++;
                funcpy[strlen(funcpy) - 1] = 0;
                funcarg = strtofunc(funcpy, f, expr, funcs);
                if (funcarg->type == F_NORM)
                    arg = exec(funcarg, funcs);
                else if (funcarg->type == F_SPEC)
                    arg = funcarg->spec(funcarg->args);
                break;
                
            default:
                atok = atok->next;
                continue;
        }
        arradd(call->args, arg);
        atok = atok->next;
    }
    
    return call;
}
示例#20
0
文件: parser.c 项目: Saruta/a2c
void next(void)
{
  if (tok)
    freetok(tok);
  tok = lookahead[0];
  lookahead[0] = lookahead[1];
  lookahead[1] = gettok();
}
示例#21
0
文件: port.c 项目: davecb/port
/*
 * pragma -- parse pragmas and #line directives
 */
 static int
pragma(char *buffer, int *lineNo, char *file) {
	char	*p, nextc;

	if (buffer[1] == ' ') {
		/* It's a # line directive, */
		/* get the lineNo and filename. */
		*lineNo = atoi(gettok(buffer, "# \t\n", &nextc)) -1;
		
		if ((p = gettok(NULL, " \t\n",&nextc)) != NULL) {
			(void) strlcpy(file, p, PATH_MAX);
		}

	}
	/* Otherwise its a pragma or #ident and we ignore it. */
	return 0;
 }
示例#22
0
文件: stmt.c 项目: 0culus/ioq3
static void ifstmt(int lab, int loop, Swtch swp, int lev) {
	t = gettok();
	expect('(');
	definept(NULL);
	walk(conditional(')'), 0, lab);
	refinc /= 2.0;
	statement(loop, swp, lev);
	if (t == ELSE) {
		branch(lab + 1);
		t = gettok();
		definelab(lab);
		statement(loop, swp, lev);
		if (findlabel(lab + 1)->ref)
			definelab(lab + 1);
	} else
		definelab(lab);
}
示例#23
0
/// gettok - Return the next token from standard input.
int lexer::gettok()
{
	// Skip any whitespace.
	c = skipspace(input, c, line_num);

	// identifier: [a-zA-Z][a-zA-Z0-9_]*
	if (isalpha(c)) { 
		str = c;
		do {
			c = input->get();
			if ( isalnum(c) || c=='_' )
				str += c;
			else
				break;
		} while (true);
		if (unlikely(literal_p(str)))
			return token_type::literal;
		else
			return token_type::identifier;
	}

	// Number: [0-9]+([.][0-9]*(eE[+-][0-9]+)*)*
	if (isdigit(c) || c == '.') {
		str = "";
		do {
			str += c;
			c = input->get();
		} while (isdigit(c) || c == '.');
		if (c == 'E' || c == 'e') {
			str += 'E';
			c = input->get();
			if (isdigit(c))
				str += '+';
			do {
				str += c;
				c = input->get();
			} while (isdigit(c));
		}
		return token_type::number;
	}

	// Comment until end of line.
	if (c == '#') {
		c = skipline(input);
		++line_num;
		if (c != EOF)
			return gettok();
	}

	// Check for end of file.  Don't eat the EOF.
	if (c == EOF)
		return token_type::eof;

	// Otherwise, just return the character as its ascii value.
	int current = c;
	c = input->get();
	return current;
}
示例#24
0
文件: error.c 项目: Izhido/qrevpak
void expect(int tok) {
	if (t == tok)
		t = gettok();
	else {
		error("syntax error; found");
		printtoken();
		fprint(stderr, " expecting `%k'\n", tok);
	}
}
示例#25
0
文件: syntax.c 项目: E-LLP/VICAR
FUNCTION CODE chkend (FAST struct SYNBLK *sb)
    {
    FAST CODE	code;			/* return code				*/
    CODE	toktyp;			/* token type				*/
    TEXT	dummy[TOKESIZ+1];

    if ((toktyp = gettok(sb, dummy)) == S_WHITE)	/* get token...		*/
	toktyp = gettok(sb, dummy);	/* if white, get another		*/
    if (toktyp == EOS)
	code = SUCCESS;
    else
	{
	code = S_SYNERR;
	(*sb).errchr = (*sb).curchr - 1;
	synerr(sb, "Unexpected trailing characters");
	}
    return(code);
    }
示例#26
0
//static bool
//get_double_value(
//    char **line,   /*in|out: pointer to line to be parsed */
//    char *name,    /*in: xxx e.g. 'val' from 'val=0.5' */
//    double *value, /*out: return value (e.g. 0.5) from 'val=0.5'*/
//    bool just_chk_meas /* in: just check measurement if true */
//)
static int
get_double_value(
                 char **line,   /*in|out: pointer to line to be parsed */
                 char *name,    /*in: xxx e.g. 'val' from 'val=0.5' */
                 double *value, /*out: return value (e.g. 0.5) from 'val=0.5'*/
                 int just_chk_meas /* in: just check measurement if true */
)
{
    char *token     = gettok(line);
    //bool return_val = TRUE;
    int return_val = TRUE;
    char *equal_ptr, *junk;
    int  err = 0;

    if (name && (strncmp(token, name, strlen(name)) != 0)) {
        if (just_chk_meas != TRUE) fprintf(cp_err, "Error: syntax error for measure statement; expecting next field to be '%s'.\n", name);
        return_val = FALSE;
    } else {
        /* see if '=' is last char of current token -- implies we need to read value in next token */
        if (token[strlen(token) - 1] == '=') {
            txfree(token);
            junk = token = gettok(line);

            *value = INPevaluate(&junk, &err, 1);
        } else {
            if ((equal_ptr = strstr(token, "=")) != NULL) {
                equal_ptr += 1;
                *value = INPevaluate(&equal_ptr, &err, 1);
            } else {
                if (just_chk_meas != TRUE)
                    fprintf(cp_err, "Error: syntax error for measure statement; missing '='!\n");
                return_val = FALSE;
            }
        }
        if (err) {
            if (just_chk_meas != TRUE)
                fprintf(cp_err, "Error: Bad value.\n");
            return_val = FALSE;
        }
    }
    txfree(token);

    return return_val;
}
示例#27
0
文件: stmt.c 项目: bill2009/lcc1802
static void asmstmt(int lab, Swtch swp, int lev) { //wjr jan 31 43 lines
        char *asmi, *ireg, *oreg, *symn;
        Tree p;

        t = gettok();
        expect('(');
        definept(NULL);

        if (t != SCON) {
                error("expecting string constant\n");
                return;
        }
        asmi = strdup(tsym->u.c.v.p);
        /*t = gettok();
        expect(':');
        if (t != SCON) {
                error("expecting string constant\n");
                return;
        }
        ireg = strdup(tsym->u.c.v.p);
        t = gettok();
        expect(':');
        if (t != SCON) {
                error("expecting string constant\n");
                return;
        }
        oreg = strdup(tsym->u.c.v.p);*/
        t = gettok();
        expect(')');
        expect(';');

        symn = (char *) malloc(strlen(asmi) /*+ strlen(ireg) + strlen(oreg)*/ +4);
        sprintf(symn, "%s", asmi);// was sprintf(symn, "%s:%s:%s", asmi, ireg, oreg);

        free(asmi);
      /*  free(ireg);
        free(oreg);*/

        p = tree(mkop(IASM, voidtype), voidtype, NULL, NULL);
        p->u.v.p = symn;

        listnodes(p, 0, 0);
}
示例#28
0
文件: parser.cpp 项目: 4aiman/HexEdit
bool Parser::Init(const char *buf, size_t len)
{	
//	fileStack.clear();
	if(!lex_initbuf(buf, len))
		return false;

	t = gettok();

	return true;
}
示例#29
0
wstring IFCParser::lookahead(wistream& is)
{
	wistream::pos_type pos = is.tellg();

	wstring tok = gettok(is);

	is.seekg(pos);

	return tok;
}
示例#30
0
#include "c.h"

static char rcsid[] = "main.c - faked rcsid";

static void typestab(Symbol, void *);

static void stabline(Coordinate *);
static void stabend(Coordinate *, Symbol, Coordinate **, Symbol *, Symbol *);
Interface *IR = NULL;

int Aflag;		/* >= 0 if -A specified */
int Pflag;		/* != 0 if -P specified */
int glevel;		/* == [0-9] if -g[0-9] specified */
int xref;		/* != 0 for cross-reference data */
Symbol YYnull;		/* _YYnull  symbol if -n or -nvalidate specified */
Symbol YYcheck;		/* _YYcheck symbol if -nvalidate,check specified */

static char *comment;
static Interface stabIR;
static char *currentfile;       /* current file name */
static int currentline;		/* current line number */
static FILE *srcfp;		/* stream for current file, if non-NULL */
static int srcpos;		/* position of srcfp, if srcfp is non-NULL */
int main(int argc, char *argv[]) {
	int i, j;
	for (i = argc - 1; i > 0; i--)
		if (strncmp(argv[i], "-target=", 8) == 0)
			break;
	if (i > 0) {
		char *s = strchr(argv[i], '\\');
		if (s != NULL)
			*s = '/';
		for (j = 0; bindings[j].name && bindings[j].ir; j++)
			if (strcmp(&argv[i][8], bindings[j].name) == 0) {
				IR = bindings[j].ir;
				break;
			}
		if (s != NULL)
			*s = '\\';
	}
	if (!IR) {
		fprint(stderr, "%s: unknown target", argv[0]);
		if (i > 0)
			fprint(stderr, " `%s'", &argv[i][8]);
		fprint(stderr, "; must specify one of\n");
		for (i = 0; bindings[i].name; i++)
			fprint(stderr, "\t-target=%s\n", bindings[i].name);
		exit(EXIT_FAILURE);
	}
	init(argc, argv);
	t = gettok();
	(*IR->progbeg)(argc, argv);
	if (glevel && IR->stabinit)
		(*IR->stabinit)(firstfile, argc, argv);
	program();
	if (events.end)
		apply(events.end, NULL, NULL);
	memset(&events, 0, sizeof events);
	if (glevel || xref) {
		Symbol symroot = NULL;
		Coordinate src;
		foreach(types,       GLOBAL, typestab, &symroot);
		foreach(identifiers, GLOBAL, typestab, &symroot);
		src.file = firstfile;
		src.x = 0;
		src.y = lineno;
		if ((glevel > 2 || xref) && IR->stabend)
			(*IR->stabend)(&src, symroot,
				ltov(&loci,    PERM),
				ltov(&symbols, PERM), NULL);
		else if (IR->stabend)
			(*IR->stabend)(&src, NULL, NULL, NULL, NULL);
	}
	finalize();
	(*IR->progend)();
	deallocate(PERM);
	return errcnt > 0;
}