Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Code completion doesnt follow #include in struct

<< < (4/8) > >>

JGM:
So basically you created a definition file http://code.google.com/p/quexparser/source/browse/trunk/cppparser/cpp.qx and the quex library takes care of the rest?

mmm, i'm gonna read the manual http://voxel.dl.sourceforge.net/project/quex/HISTORY/Ancient/Documentation/quex-doc-09y08m01d.pdf seems to be a great project.

I'm sending you my email on a private message to stop hijacking this thread  :).

Ceniza:
Why do you keep insisting in creating an overcomplicated const expression evaluator? Evaluating a const expression after macro expansion is straight forward using the grammar from the standard. I have pointed to an implementation multiple times, but it is always ignored. All you have to do is feed it the tokens while skipping whitespace (comments belong here too, if retained).

Proper macro expansion is complicated, though, even more when handling concatenation, "stringification" and recursive replacements. Think of something like this:


--- Code: ---#include <cstdio>

#define STR_HELPER(x) # x
#define STR(x) STR_HELPER(x)
#define CONCAT2(x, y) x ## y
#define CONCAT3(x, y, z) CONCAT2(x ## y, z)

int main()
{
    std::printf(STR($%@!&*));
    std::printf(STR(CONCAT3(this, /* COMMENT */ is, a /* another comment */ test)));
}
--- End code ---

How many of you can actually tell me what the program is supposed to show on screen without compiling and running it? What if I replaced STR(x) to:


--- Code: ---#define STR(x) # x
--- End code ---

Would it show the same?

Ceniza:
There you go. The same code turned into something that should be easier to follow (it is, if you are not scared of pointers). All self contained, no templates. 4 tests included. Most of the conversion from the original code was made through find-and-replace. The grammar is included as documentation of each method.

JGM:
So does this code works to evaluate macro expressions/conditions like these ones for example?


--- Code: ---#if VERBOSE >= 2
  print("trace message");
#endif

#if !defined(WIN32) || defined(__MINGW32__)
...
#endif

--- End code ---

I'm not sure If I'm using the correct terminology (sorry for that I'm a dumb xD) It would be easier to talk you on spanish xD, theres many parsing terminology I'm not familiar with :(

JGM:
Well I documented and cleaned the code to some point here are the changes:

http://www.mediafire.com/?17skj2g70c86u50

Also I included a test case on the test folder, as my development environment is ubuntu/linux I created a shell script test/test.sh This script uses the debug binary of cpp_parser library and parses the test.hpp file also on test folder. (I took the example presented on this thread of #include on a typdef struct and made it part of the test case)

The original code on test.hpp is this one:


--- Code: ---#ifndef TEST_HPP
#define TEST_HPP

//Has multiply macro
#include "misc.h"

#ifndef MAX_VALUE
#define MAX_VALUE 10000
#endif

#ifndef MAX_VALUE
#define MAX_VALUE ShouldNotOccurre
#endif

typedef struct
{
//The content of the struct in another file
#include "object.h"
//Should only be included once
#include "object.h"
} Object;

namespace test
{
    int value = MAX_VALUE;
    int test = multiply;

    /**
     * Function one documentation
     * @return true otherwise false
     */
    bool function_one(const char &argument);

    /**
     * Function two documentation
     * @return The amount of characters found
     */
    unsigned int function_two(const char &argument);
};

//We undefine the MAX_VALUE macro
#undef MAX_VALUE

int value = MAX_VALUE;

#endif

--- End code ---

and the cpp_parser binary returns this:


--- Code: ---
 //Has multiply macro




typedef struct
{
  //The content of the struct in another file


unsigned value;
string test;


  //Should only be included once
} Object;

namespace test
{
    int value = 10000;
    int test = 4*5;
  
    /**
     * Function one documentation
     * @return true otherwise false
     */                                                                            
    bool function_one(const char &argument);

    /**
     * Function two documentation
     * @return The amount of characters found
     */                                                                                      
    unsigned int function_two(const char &argument);
};

 //We undefine the MAX_VALUE macro

int value = MAX_VALUE;

--- End code ---

There are things left to implement and fix but for now basic functionality is working :D

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version