why the c/c++ parser use the parser2?

Help
ollydbg
2010-11-08
2014-01-10
  • ollydbg

    ollydbg - 2010-11-08

    Hi, from the source code c.c, I found that there are code like:

    extern parserDefinition* CParser (void)
    {
        static const char *const extensions [] = { "c", NULL };
        parserDefinition* def = parserNew ("C");
        def->kinds      = CKinds;
        def->kindCount  = KIND_COUNT (CKinds);
        def->extensions = extensions;
        def->parser2    = findCTags;
        def->initialize = initializeCParser;
        return def;
    }
    extern parserDefinition* CppParser (void)
    {
        static const char *const extensions [] = {
            "c++", "cc", "cp", "cpp", "cxx", "h", "h++", "hh", "hp", "hpp", "hxx",
    #ifndef CASE_INSENSITIVE_FILENAMES
            "C", "H",
    #endif
            NULL
        };
        parserDefinition* def = parserNew ("C++");
        def->kinds      = CKinds;
        def->kindCount  = KIND_COUNT (CKinds);
        def->extensions = extensions;
        def->parser2    = findCTags;
        def->initialize = initializeCppParser;
        return def;
    }
    

    I just wondering that why the parser2 is used? it seems the parser field is left, it is default set to NULL?

    thanks.

     
  • ollydbg

    ollydbg - 2010-11-08

    By the way, from the
    http://ctags.sourceforge.net/EXTENDING.html

    it seems that the "parser" field should be filled like:

    /* Create parser definition stucture */
    extern parserDefinition* SwineParser (void)
    {
        static const char *const extensions [] = { "swn", NULL };
        parserDefinition* def = parserNew ("Swine");
        def->kinds      = SwineKinds;
        def->kindCount  = KIND_COUNT (SwineKinds);
        def->extensions = extensions;
        def->parser     = findSwineTags;
        return def;
    }
    

    So, why c/c++ parser use "parser2" field???

    thanks.

     
  • Steve

    Steve - 2014-01-10

    A parserDefinition may use either parser or parser2, never both (and not neither). The difference is whether the parser is a "simple parser" or "rescanning parser". The findCTags parser can rescan with a different brace format if the first, normal, pass fails.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks