mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 08:56:01 +02:00
codetools: c parser: implemented parsing function parameter names
git-svn-id: trunk@14570 -
This commit is contained in:
parent
fb6acb3313
commit
229b2913b9
@ -807,6 +807,8 @@ procedure TCCodeParserTool.ReadParameterList;
|
|||||||
// start on (, end on )
|
// start on (, end on )
|
||||||
var
|
var
|
||||||
StartPos: LongInt;
|
StartPos: LongInt;
|
||||||
|
TypePos: Integer;
|
||||||
|
NamePos: Integer;
|
||||||
begin
|
begin
|
||||||
CreateChildNode(ccnFuncParamList);
|
CreateChildNode(ccnFuncParamList);
|
||||||
StartPos:=AtomStart;
|
StartPos:=AtomStart;
|
||||||
@ -823,11 +825,51 @@ begin
|
|||||||
RaiseExpectedButAtomFound('parameter type');
|
RaiseExpectedButAtomFound('parameter type');
|
||||||
// read parameter
|
// read parameter
|
||||||
CreateChildNode(ccnFuncParameter);
|
CreateChildNode(ccnFuncParameter);
|
||||||
|
// examples:
|
||||||
|
// a a is the type
|
||||||
|
// a b a is type, b is name
|
||||||
|
// signed a a is the type
|
||||||
|
TypePos:=0;
|
||||||
|
NamePos:=0;
|
||||||
repeat
|
repeat
|
||||||
if AtomStart>SrcLen then break;
|
if AtomStart>SrcLen then break;
|
||||||
if AtomIs('(') or AtomIs('[') then
|
if AtomIs(')') then begin
|
||||||
ReadTilBracketClose(true);
|
// end of parameter list
|
||||||
if AtomIs(',') or AtomIs(')') then break;
|
break;
|
||||||
|
end else if AtomIs('[') then
|
||||||
|
ReadTilBracketClose(true)
|
||||||
|
else if AtomIs(',') then
|
||||||
|
break
|
||||||
|
else if IsIdentStartChar[Src[AtomStart]] then begin
|
||||||
|
if NamePos>0 then
|
||||||
|
RaiseExpectedButAtomFound(', or )');
|
||||||
|
if AtomIs('signed') or AtomIs('unsigned') or AtomIs('const') then
|
||||||
|
begin
|
||||||
|
// modifier
|
||||||
|
end else if AtomIs('short') or AtomIs('long') then begin
|
||||||
|
// modifier or type
|
||||||
|
TypePos:=AtomStart;
|
||||||
|
ReadNextAtom;
|
||||||
|
if AtomIs(')') or AtomIs(',') or AtomIs('(') then begin
|
||||||
|
// type
|
||||||
|
end else begin
|
||||||
|
// modifier
|
||||||
|
TypePos:=0;
|
||||||
|
end;
|
||||||
|
UndoReadNextAtom;
|
||||||
|
end else begin
|
||||||
|
// type or name
|
||||||
|
if TypePos<1 then begin
|
||||||
|
// type
|
||||||
|
TypePos:=AtomStart;
|
||||||
|
end else begin
|
||||||
|
// name
|
||||||
|
NamePos:=AtomStart;
|
||||||
|
CreateChildNode(ccnName);
|
||||||
|
EndChildNode;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
CurNode.EndPos:=SrcPos;
|
CurNode.EndPos:=SrcPos;
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
until false;
|
until false;
|
||||||
|
Loading…
Reference in New Issue
Block a user