Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
Pointer/Array not recognized
daniloz:
Hi All,
I don't know exactly what's the technical name of what I'm doing, but look at the following code:
--- Code: ---float *pFloat;
float **pFloat2;
float (*pFloatPar)[3];
int main()
{
pFloat;
pFloat2;
pFloat
}
--- End code ---
I've declared pFloatPar as a double array in a way that the compiler knows about the second dimension size and then I can write pFloatPar[2][1].
However, the actual code completion doesn't recognize the declaration (see the attached screenshot). My assumption is that CC cannot correctly parse the parenthesis...
ollydbg:
I have put your code in our parsertest project, and the result looks below:
--- Code: -----------------M-a-i-n--L-o-g--------------
000001. ParserDummy() : ParserBase() : Instantiation of Parser object.
000002. InitTokenizer() : m_Filename='test.h', m_FileSize=108.
000003. Init() : m_Filename='test.h'
000004. test.h
000005. Parse() : Parsing 'test.h'
000006. DoParse() : Loop:m_Str='', token='float'
000007. DoParse() : Loop:m_Str='float ', token='*'
000008. DoParse() : Loop:m_Str='float ', token='pFloat'
000009. DoAddToken() : Created token='pFloat', file_idx=1, line=1, ticket=
000010. GetActualTokenType() : Searching within m_Str='float'
000011. GetActualTokenType() : Compensated m_Str='float'
000012. GetActualTokenType() : Found 'float'
000013. DoAddToken() : Prepending ''
000014. DoAddToken() : Added/updated token 'pFloat' (0), kind 'variable', type 'float*', actual 'float'. Parent is (-1)
000015. DoParse() : Loop:m_Str='float', token=';'
000016. DoParse() : Loop:m_Str='', token='float'
000017. DoParse() : Loop:m_Str='float ', token='*'
000018. DoParse() : Loop:m_Str='float ', token='*'
000019. DoParse() : Loop:m_Str='float ', token='pFloat2'
000020. DoAddToken() : Created token='pFloat2', file_idx=1, line=2, ticket=
000021. GetActualTokenType() : Searching within m_Str='float'
000022. GetActualTokenType() : Compensated m_Str='float'
000023. GetActualTokenType() : Found 'float'
000024. DoAddToken() : Prepending ''
000025. DoAddToken() : Added/updated token 'pFloat2' (1), kind 'variable', type 'float**', actual 'float'. Parent is (-1)
000026. DoParse() : Loop:m_Str='float', token=';'
000027. DoParse() : Loop:m_Str='', token='float'
000028. ReadParentheses(): (* pFloatPar), line=3
000029. DoParse() : Loop:m_Str='', token=';'
000030. DoParse() : Loop:m_Str='', token='int'
000031. DoParse() : Loop:m_Str='int ', token='main'
000032. ReadParentheses(): (), line=5
000033. HandleFunction() : Adding function 'main': m_Str='int '
000034. HandleFunction() : name='main', args='()', peek='{'
000035. HandleFunction() : !(Ctor/Dtor) 'main', m_Str='int ', localParent='<none>'
000036. HandleFunction() : Adding function 'main', ': m_Str='int ', enc_ns='nil'.
000037. HandleFunction() : Add token name='main', args='()', return type='int '
000038. GetBaseArgs() : args='()'.
000039. GetBaseArgs() : baseArgs='()'.
000040. DoAddToken() : Created token='main', file_idx=1, line=5, ticket=
000041. GetActualTokenType() : Searching within m_Str='int'
000042. GetActualTokenType() : Compensated m_Str='int'
000043. GetActualTokenType() : Found 'int'
000044. DoAddToken() : Prepending ''
000045. DoAddToken() : Added/updated token 'main' (2), kind 'function', type 'int', actual 'int'. Parent is (-1)
000046. ParserDummy() : ~ParserBase() : Destruction of Parser object.
--------------T-r-e-e--L-o-g--------------
000047. float* pFloat [1,0]
000048. float** pFloat2 [2,0]
000049. main() [5,5]
--------------L-i-s-t--L-o-g--------------
000050. variable float* pFloat [1,0]
000051. variable float** pFloat2 [2,0]
000052. function int main() [5,5]
--- End code ---
Yes. The parser just skip the "[3]".
The proposed fix is try to peek the token after the right parenthesis, and if it is a "[", then we can guess that is is a second level pointer.
daniloz:
--- Quote from: ollydbg on November 15, 2011, 10:17:44 am ---Yes. The parser just skip the "[3]".
--- End quote ---
Even if the parser does so, the result should be float *pFloatPar; and the parser should treat it as a pointer to a float. This would, of course, be wrong, but it seems the parser is just dropping this symbol completely.
--- Quote from: ollydbg on November 15, 2011, 10:17:44 am ---The proposed fix is try to peek the token after the right parenthesis, and if it is a "[", then we can guess that is is a second level pointer.
--- End quote ---
That sounds good to me, however I'm not that familiar with the CC plugin to try a patch, sorry... ;-)
ollydbg:
--- Quote from: daniloz on November 15, 2011, 02:20:40 pm ---
--- Quote from: ollydbg on November 15, 2011, 10:17:44 am ---The proposed fix is try to peek the token after the right parenthesis, and if it is a "[", then we can guess that is is a second level pointer.
--- End quote ---
That sounds good to me, however I'm not that familiar with the CC plugin to try a patch, sorry... ;-)
--- End quote ---
I think I will take some time to fix it. :D
daniloz:
--- Quote from: ollydbg on November 15, 2011, 02:47:40 pm ---I think I will take some time to fix it. :D
--- End quote ---
That'd be great... Thanks! 8)
Navigation
[0] Message Index
[#] Next page
Go to full version