int V3PreProcImp::getFinalToken(string& buf) {
    // Return the next user-visible token in the input stream.
    // Includes and such are handled here, and are never seen by the caller.
    if (!m_finAhead) {
	m_finAhead = true;
	m_finToken = getStateToken();
	m_finBuf = string (yyourtext(), yyourleng());
    }
    int tok = m_finToken;
    buf = m_finBuf;
    if (0 && debug()>=5) {
	string bufcln = V3PreLex::cleanDbgStrg(buf);
	fprintf (stderr,"%d: FIN:      %-10s: %s\n",
		 m_lexp->m_tokFilelinep->lineno(), tokenName(tok), bufcln.c_str());
    }
    // Track `line
    const char* bufp = buf.c_str();
    while (*bufp == '\n') bufp++;
    if ((tok == VP_TEXT || tok == VP_LINE) && 0==strncmp(bufp,"`line ",6)) {
	int enter;
	m_finFilelinep->lineDirective(bufp, enter/*ref*/);
    }
    else {
	if (m_finAtBol && !(tok==VP_TEXT && buf=="\n")
	    && m_preprocp->lineDirectives()) {
	    if (int outBehind = m_lexp->m_tokFilelinep->lineno() - m_finFilelinep->lineno()) {
		if (debug()>=5) fprintf(stderr,"%d: FIN: readjust, fin at %d  request at %d\n",
					m_lexp->m_tokFilelinep->lineno(),
					m_finFilelinep->lineno(), m_lexp->m_tokFilelinep->lineno());
		m_finFilelinep = m_finFilelinep->create(m_lexp->m_tokFilelinep->filename(),m_lexp->m_tokFilelinep->lineno());
		if (outBehind > 0 && outBehind <= (int)V3PreProc::NEWLINES_VS_TICKLINE) {
		    // Output stream is behind, send newlines to get back in sync
		    // (Most likely because we're completing a disabled `endif)
		    if (m_preprocp->keepWhitespace()) {
			buf = string(outBehind,'\n');
			return VP_TEXT;
		    }
		} else {
		    // Need to backup, use `line
		    buf = m_finFilelinep->lineDirectiveStrg(0);
		    return VP_LINE;
		}
	    }
	}
	// Track newlines in prep for next token
	for (string::iterator cp=buf.begin(); cp!=buf.end(); ++cp) {
	    if (*cp == '\n') {
		m_finAtBol = true;
		m_finFilelinep->linenoIncInPlace();  // Increment in place to avoid new/delete calls.  It's private data.
	    } else {
		m_finAtBol = false;
	    }
	}
    }
    m_finAhead = false;  // Consumed the token
    return tok;
}
    void configure(FileLine* filelinep) {
	// configure() separate from constructor to avoid calling abstract functions
	m_preprocp = this;   // Silly, but to make code more similar to Verilog-Perl
	m_finFilelinep = filelinep->create(1);
	// Create lexer
	m_lexp = new V3PreLex (this, filelinep);
	m_lexp->m_keepComments = m_preprocp->keepComments();
	m_lexp->m_keepWhitespace = m_preprocp->keepWhitespace();
	m_lexp->m_pedantic = m_preprocp->pedantic();
	m_lexp->debug(debug()>=5 ? debug() : 0);  // See also V3PreProc::debug() method
    }