I wrote a CC test case:
//Code completion and STM32 peripheral registers -
//http://forums.codeblocks.org/index.php/topic,21823.msg148685.html#msg148685
#define __IO
typedef struct
{
__IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */
__IO uint16_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */
uint16_t RESERVED0; /*!< Reserved, 0x06 */
__IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */
__IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */
__IO uint16_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */
uint16_t RESERVED1; /*!< Reserved, 0x12 */
__IO uint16_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */
uint16_t RESERVED2; /*!< Reserved, 0x16 */
__IO uint32_t BSRR; /*!< GPIO port bit set/reset registerBSRR, Address offset: 0x18 */
__IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */
__IO uint32_t AFR[2]; /*!< GPIO alternate function low register, Address offset: 0x20-0x24 */
__IO uint16_t BRR; /*!< GPIO bit reset register, Address offset: 0x28 */
uint16_t RESERVED3; /*!< Reserved, 0x2A */
}GPIO_TypeDef;
#define PERIPH_BASE ((uint32_t)0x40000000) /*!< Peripheral base address in the alias region */
#define AHB2PERIPH_BASE (PERIPH_BASE + 0x08000000)
#define GPIOA_BASE (AHB2PERIPH_BASE + 0x00000000)
#define GPIOA ((GPIO_TypeDef *) GPIOA_BASE)
//GPIOA->MO //MODER
And running this test case, I get the tree printed in the log window:
...
...
000079. MO
000080. ->
000081. ((((uint32_t)0x40000000)+0x08000000)+0x00000000)
000082. CAST
000083. *
000084. GPIO_TypeDef
So, I use the Tokenizer to preprocess the tokens of the statement "GPIOA->MO".
Now, the next step is: try to traverse the tree, and make the type resolving. Some code should be changed, such as the below function:
// Here's the meat of code-completion :)
// This function decides most of what gets included in the auto-completion
// list presented to the user.
// It's called recursively for each component of the std::queue argument.
// for example: objA.objB.function()
// The queue is like: 'objA' 'objB' 'function'. We deal with objA first.
//
// No critical section needed in this recursive function!
// All functions that call this recursive function, should already entered a critical section.
size_t NativeParserBase::FindAIMatches(TokenTree* tree,
std::queue<ParserComponent> components,
TokenIdxSet& result,
int parentTokenIdx,
bool isPrefix,
bool caseSensitive,
bool use_inheritance,
short int kindMask,
TokenIdxSet* search_scope)
{
Note that the second parameter "std::queue<ParserComponent> components" should be replaced by the tree.