Beispiel #1
0
nl_convert_eagle_t::tokenizer::tokenizer(nl_convert_eagle_t &convert, plib::putf8_reader &strm)
	: plib::ptokenizer(strm)
	, m_convert(convert)
{
	set_identifier_chars("abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_.-");
	set_number_chars(".0123456789", "0123456789eE-."); //FIXME: processing of numbers
	set_whitespace(pstring("").cat(' ').cat(9).cat(10).cat(13));
	/* FIXME: gnetlist doesn't print comments */
	set_comment("/*", "*/", "//");
	set_string_char('\'');
	m_tok_ADD = register_token("ADD");
	m_tok_VALUE = register_token("VALUE");
	m_tok_SIGNAL = register_token("SIGNAL");
	m_tok_SEMICOLON = register_token(";");
	/* currently not used, but required for parsing */
	register_token(")");
	register_token("(");
}
Beispiel #2
0
nl_convert_rinf_t::tokenizer::tokenizer(nl_convert_rinf_t &convert, plib::putf8_reader &strm)
	: plib::ptokenizer(strm)
	, m_convert(convert)
{
	set_identifier_chars(".abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_-");
	set_number_chars("0123456789", "0123456789eE-."); //FIXME: processing of numbers
	set_whitespace(pstring("").cat(' ').cat(9).cat(10).cat(13));
	/* FIXME: gnetlist doesn't print comments */
	set_comment("","","//"); // FIXME:needs to be confirmed
	set_string_char('"');
	m_tok_HEA = register_token(".HEA");
	m_tok_APP = register_token(".APP");
	m_tok_TIM = register_token(".TIM");
	m_tok_TYP = register_token(".TYP");
	m_tok_ADDC = register_token(".ADD_COM");
	m_tok_ATTC = register_token(".ATT_COM");
	m_tok_NET = register_token(".ADD_TER");
	m_tok_TER = register_token(".TER");
	m_tok_END = register_token(".END");
}
Beispiel #3
0
bool parser_t::parse(const char *buf, const pstring nlname)
{
	ppreprocessor prepro;

	pstring processed = prepro.process(buf);
	m_buf = processed.cstr();

	reset(m_buf);
	set_identifier_chars("abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_.-");
	set_number_chars(".0123456789", "0123456789eE-."); //FIXME: processing of numbers
	char ws[5];
	ws[0] = ' ';
	ws[1] = 9;
	ws[2] = 10;
	ws[3] = 13;
	ws[4] = 0;
	set_whitespace(ws);
	set_comment("/*", "*/", "//");
	m_tok_param_left = register_token("(");
	m_tok_param_right = register_token(")");
	m_tok_comma = register_token(",");

	m_tok_ALIAS = register_token("ALIAS");
	m_tok_DIPPINS = register_token("DIPPINS");
	m_tok_NET_C = register_token("NET_C");
	m_tok_FRONTIER = register_token("OPTIMIZE_FRONTIER");
	m_tok_PARAM = register_token("PARAM");
	m_tok_NET_MODEL = register_token("NET_MODEL");
	m_tok_INCLUDE = register_token("INCLUDE");
	m_tok_LOCAL_SOURCE = register_token("LOCAL_SOURCE");
	m_tok_LOCAL_LIB_ENTRY = register_token("LOCAL_LIB_ENTRY");
	m_tok_SUBMODEL = register_token("SUBMODEL");
	m_tok_NETLIST_START = register_token("NETLIST_START");
	m_tok_NETLIST_END = register_token("NETLIST_END");
	m_tok_TRUTHTABLE_START = register_token("TRUTHTABLE_START");
	m_tok_TRUTHTABLE_END = register_token("TRUTHTABLE_END");
	m_tok_TT_HEAD = register_token("TT_HEAD");
	m_tok_TT_LINE = register_token("TT_LINE");
	m_tok_TT_FAMILY = register_token("TT_FAMILY");

	bool in_nl = false;

	while (true)
	{
		token_t token = get_token();

		if (token.is_type(ENDOFFILE))
		{
			return false;
			//error("EOF while searching for <%s>", nlname.cstr());
		}

		if (token.is(m_tok_NETLIST_END))
		{
			require_token(m_tok_param_left);
			if (!in_nl)
				error("Unexpected NETLIST_END");
			else
			{
				in_nl = false;
			}
			require_token(m_tok_param_right);
		}
		else if (token.is(m_tok_NETLIST_START))
		{
			if (in_nl)
				error("Unexpected NETLIST_START");
			require_token(m_tok_param_left);
			token_t name = get_token();
			require_token(m_tok_param_right);
			if (name.str() == nlname || nlname == "")
			{
				parse_netlist(name.str());
				return true;
			} else
				in_nl = true;
		}
	}
}
Beispiel #4
0
bool netlist_parser::parse(const char *buf, const pstring nlname)
{
    m_buf = buf;

    reset(buf);
    set_identifier_chars("abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_.-");
    set_number_chars("01234567890eE-."); //FIXME: processing of numbers
    char ws[5];
    ws[0] = ' ';
    ws[1] = 9;
    ws[2] = 10;
    ws[3] = 13;
    ws[4] = 0;
    set_whitespace(ws);
    set_comment("/*", "*/", "//");
    m_tok_param_left = register_token("(");
    m_tok_param_right = register_token(")");
    m_tok_comma = register_token(",");

    m_tok_ALIAS = register_token("ALIAS");
    m_tok_NET_C = register_token("NET_C");
    m_tok_PARAM = register_token("PARAM");
    m_tok_NET_MODEL = register_token("NET_MODEL");
    m_tok_INCLUDE = register_token("INCLUDE");
    m_tok_SUBMODEL = register_token("SUBMODEL");
    m_tok_NETLIST_START = register_token("NETLIST_START");
    m_tok_NETLIST_END = register_token("NETLIST_END");

    bool in_nl = false;

    while (true)
    {
        token_t token = get_token();

        if (token.is_type(ENDOFFILE))
        {
            return false;
            //error("EOF while searching for <%s>", nlname.cstr());
        }

        if (token.is(m_tok_NETLIST_END))
        {
            require_token(m_tok_param_left);
            if (!in_nl)
                error("Unexpected NETLIST_END");
            else
            {
                in_nl = false;
            }
            require_token(m_tok_param_right);
        }
        else if (token.is(m_tok_NETLIST_START))
        {
            if (in_nl)
                error("Unexpected NETLIST_START");
            require_token(m_tok_param_left);
            token_t name = get_token();
            require_token(m_tok_param_right);
            if (name.str() == nlname || nlname == "")
            {
                parse_netlist(name.str());
                return true;
            } else
                in_nl = true;
        }
    }
}