Exemplo n.º 1
0
int	yyincl(char *fn, int fil) {
	char		*s;

	DEBUG(CURDLEV+1,"Going to include (ptr=%d) %s \'%s\'.\n",include_stack_ptr,fil?"file":"string",fn);
	if (include_stack_ptr>=MAX_INCLUDE_DEPTH || include_stack_ptr<-MAX_INCLUDE_DEPTH) {
		PROGERROR("Includes are nested too deeply! %d",include_stack_ptr);
		exit(-1);
	}
	if (include_stack_ptr<0) {
		include_stack_ptr = -1;	 include_app = 0;
		inpfile = NULL;  include_stack_file[0] = NULL;
	}
			/* opens the given include file for reading */
	if (fil) {
		if (include_stack_ptr>0)	/* (tries also the subdir of the previous include) */
			s = fdir_extract(include_stack_fn[include_stack_ptr-1]);
		else  s = NULL;
		yyin = fopen_path(fn,"r",frame_path_read,s,frame_extension);
		//********* add stdin as an input "-" (interactive input) ........
		if (!yyin) {
			LERROR("Cannot open include file \'%s\'!",fn);
			return -1;
		}
		if (!FRNAME(curframe)) {
			frame_setname(curframe,s=fname_extract(fn));
			FREE(s);	/* (this s is a private copy of the string) */
		}
	}
	if (include_stack_ptr>=0) {	/* stores the current buffer, and opens a new buffer */
		include_stack[include_stack_ptr] = YY_CURRENT_BUFFER;
	}
	if (fil) {
		yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE));
		if (include_stack_ptr+1>=0)  include_stack_file[include_stack_ptr+1] = yyin;
	} else {
		yy_scan_string(fn);
		if (include_stack_ptr+1>=0)  include_stack_file[include_stack_ptr+1] = NULL;
	}
	if (include_stack_ptr>=0) {	/* stores the whole current state on the stack */
		yy_push_state(INITIAL);
		include_stack_fn[include_stack_ptr] = inpfile;
		include_stack_ln[include_stack_ptr] = inpline;
	}
	inpfile = MSTRDUP(fn);	/* (freed in yywrap()) */
	inpline = 1;
	include_stack_ptr++;
	inpspecial = !fil;	/* whether special-lines should apply to this include - see SPECMATRIXLINE */
	return 0;
}
Exemplo n.º 2
0
    void statePushVlg() {
	yy_push_state(STATE_VERILOG_RECENT);
    }