Пример #1
0
void Lua::LuaGraphTreeModel::loadLuaModel( QString name, const Diluculum::LuaValue value, LuaGraphTreeItem* parent )
{
	if ( value.type() == 5 ) {
		LuaGraphTreeItem* newParent = new LuaGraphTreeItem( QList<QVariant>() << name << "", parent );
		parent->appendChild( newParent );
		Diluculum::LuaValueMap tableValue = value.asTable();
		for ( Diluculum::LuaValueMap::iterator i = tableValue.begin(); i != tableValue.end(); ++i ) {
			loadLuaModel( QString::fromStdString( i->first.asString() ), i->second, newParent );
		}
	}
	else {
		Lua::LuaInterface* lua = Lua::LuaInterface::getInstance();
		Diluculum::LuaValueList param;
		param.push_back( value );
		std::string textValue = lua->callFunction( "tostring", param )[0].asString();
		QList<QVariant> list = QList<QVariant>() << name << QString::fromStdString( textValue );
		parent->appendChild( new LuaGraphTreeItem( list, parent ) );
	}
}
Пример #2
0
void HLCmdLineApp::printDebugInfo ( const highlight::SyntaxReader *lang,
                                    const string & langDefPath )
{
    if (!lang) return;
    cerr << "\nLoading language definition:\n" << langDefPath;
    cerr << "\n\nDescription: " << lang->getDescription();

    Diluculum::LuaState* luaState=lang->getLuaState();
    if (luaState) {
        cerr << "\n\nLUA GLOBALS:\n" ;
        Diluculum::LuaValueMap::iterator it;
        Diluculum::LuaValueMap glob =luaState->globals();
        for(it = glob.begin(); it != glob.end(); it++)
        {
            Diluculum::LuaValue first = it->first;
            Diluculum::LuaValue second = it->second;
            std::cerr << first.asString()<<": ";
            switch (second.type()) {
            case  LUA_TSTRING:
                cerr << "string [ "<<second.asString()<<" ]";
                break;
            case  LUA_TNUMBER:
                cerr << "number [ "<<second.asNumber()<<" ]";
                break;
            case  LUA_TBOOLEAN:
                cerr << "boolean [ "<<second.asBoolean()<<" ]";
                break;
            default:
                cerr << second.typeName();
            }
            cerr << endl;
        }

    }
    /*
    cerr << "\nREGEX:\n";
    highlight::RegexElement *re=NULL;
    for ( unsigned int i=0; i<lang->getRegexElements().size(); i++ )
    {
        re = lang->getRegexElements() [i];
        cerr << "State "<<re->open<<":\t"<<re->rex. <<"\n";
    }*/
    cerr << "\nKEYWORDS:\n";
    highlight::KeywordMap::iterator it;
    highlight::KeywordMap keys=lang->getKeywords();
    for ( it=keys.begin(); it!=keys.end(); it++ )
    {
        cerr << " "<< it->first << "("<< it->second << ")";
    }
    cerr <<"\n\n";
}