当前位置: 首页>>代码示例>>C++>>正文


C++ Lexer::currentToken方法代码示例

本文整理汇总了C++中Lexer::currentToken方法的典型用法代码示例。如果您正苦于以下问题:C++ Lexer::currentToken方法的具体用法?C++ Lexer::currentToken怎么用?C++ Lexer::currentToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lexer的用法示例。


在下文中一共展示了Lexer::currentToken方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: readClassDeclaration

/*
    readDeclaration reads a declaration of a class
*/
static void readClassDeclaration()
{   
    ObjectHandle classObj, metaObj, vars;
    std::string className, superName;
    int i, size, instanceTop;
    // todo: fixed length variables array!
    ObjectHandle instanceVariables[15];
    // todo: horrible fixed length arrays!
    char metaClassName[100];
    char metaSuperClassName[100];

    if (ll.nextToken() != nameconst)
        sysError("bad file format","no name in declaration");
    className = ll.strToken();
    if (ll.nextToken() == nameconst) 
    { /* read superclass name */
        superName = ll.strToken();
        ll.nextToken();
    }
    // todo: sprintf eradication!
    sprintf(metaClassName, "Meta%s", className.c_str());
    if(!superName.empty())
        sprintf(metaSuperClassName, "Meta%s", superName.c_str());
    else
        sprintf(metaSuperClassName, "Class");

    metaObj = createRawClass(metaClassName, "Class", metaSuperClassName);
    classObj = createRawClass(className.c_str(), metaClassName, superName.c_str());
    classObj->_class = metaObj;

    // Get the current class size, we'll build on this as 
    // we add instance variables.
    size = getInteger(classObj->basicAt(sizeInClass));

    if (ll.currentToken() == nameconst) 
    {     /* read instance var names */
        instanceTop = 0;
        while (ll.currentToken() == nameconst) 
        {
            instanceVariables[instanceTop++] = createSymbol(ll.strToken().c_str());
            size++;
            ll.nextToken();
        }
        vars = newArray(instanceTop);
        for (i = 0; i < instanceTop; i++) 
        {
            vars->basicAtPut(i+1, instanceVariables[i]);
        }
        classObj->basicAtPut(variablesInClass, vars);
    }
    classObj->basicAtPut(sizeInClass, newInteger(size));
    classObj->basicAtPut(methodsInClass, newDictionary(39));
}
开发者ID:pgregory,项目名称:tumbleweed,代码行数:56,代码来源:filein.cpp

示例2: readRawClassDeclaration

/*
    readRawDeclaration reads a declaration of a class
*/
static void readRawClassDeclaration()
{   
    ObjectHandle classObj, vars;
    std::string className, metaName, superName;
    int i, size, instanceTop;
    // todo: fixed length variables array!
    ObjectHandle instanceVariables[15];

    if (ll.nextToken() != nameconst)
        sysError("bad file format","no name in declaration");
    className = ll.strToken();
    size = 0;
    if (ll.nextToken() == nameconst) 
    { /* read metaclass name */
        metaName = ll.strToken();
        ll.nextToken();
    }
    if (ll.currentToken() == nameconst) 
    { /* read superclass name */
        superName = ll.strToken();
        ll.nextToken();
    }

    classObj = createRawClass(className.c_str(), metaName.c_str(), superName.c_str());

    // Get the current class size, we'll build on this as 
    // we add instance variables.
    size = getInteger(classObj->basicAt(sizeInClass));

    if (ll.currentToken() == nameconst) 
    {     /* read instance var names */
        instanceTop = 0;
        while (ll.currentToken() == nameconst) 
        {
            instanceVariables[instanceTop++] = createSymbol(ll.strToken().c_str());
            size++;
            ll.nextToken();
        }
        vars = newArray(instanceTop);
        for (i = 0; i < instanceTop; i++) 
        {
            vars->basicAtPut(i+1, instanceVariables[i]);
        }
        classObj->basicAtPut(variablesInClass, vars);
    }
    classObj->basicAtPut(sizeInClass, newInteger(size));
    classObj->basicAtPut(methodsInClass, newDictionary(39));
}
开发者ID:pgregory,项目名称:tumbleweed,代码行数:51,代码来源:filein.cpp

示例3: fileIn

/*
    fileIn reads in a module definition
*/
void fileIn(FILE* fd, bool printit)
{
    textBuffer = new char[TextBufferSize];
    while(fgets(textBuffer, TextBufferSize, fd) != NULL) 
    {
        ll.reset(textBuffer);
        if (ll.currentToken() == inputend)
            ; /* do nothing, get next line */
        else if ((ll.currentToken() == binary) && ll.strToken().compare("*") == 0)
            ; /* do nothing, its a comment */
        else if ((ll.currentToken() == nameconst) && ll.strToken().compare("RawClass") == 0)
            readRawClassDeclaration();
        else if ((ll.currentToken() == nameconst) && ll.strToken().compare("Class") == 0)
            readClassDeclaration();
        else if ((ll.currentToken() == nameconst) && ll.strToken().compare("Methods") == 0)
            readMethods(fd, printit);
        else 
            sysError("unrecognized line", textBuffer);
        MemoryManager::Instance()->garbageCollect();
    }
    delete[](textBuffer);
}
开发者ID:pgregory,项目名称:tumbleweed,代码行数:25,代码来源:filein.cpp


注:本文中的Lexer::currentToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。