* mixed patches from Dmitry B, that fix the doc generation it seems.

git-svn-id: trunk@15687 -
This commit is contained in:
marco 2010-08-01 18:38:55 +00:00
parent 50861d26ab
commit 281f0f2a8c
3 changed files with 65 additions and 27 deletions

View File

@ -67,7 +67,7 @@ resourcestring
SPasTreeDestructorImpl = 'destructor implementation';
type
TPasExprKind = (pekIdent, pekNumber, pekString, pekSet, pekBoolConst, pekRange,
TPasExprKind = (pekIdent, pekNumber, pekString, pekSet, pekNil, pekBoolConst, pekRange,
pekUnary, pekBinary, pekFuncParams, pekArrayParams, pekListOfExp);
TExprOpCode = (eopNone,
@ -77,7 +77,7 @@ type
eopEqual, eopNotEqual, // Logical
eopLessThan,eopGreaterThan, eopLessthanEqual,eopGreaterThanEqual, // ordering
eopIn,eopIs,eopAs, eopSymmetricaldifference, // Specials
eopAddress,
eopAddress, eopDeref, // Pointers
eopSubIdent); // SomeRec.A, A is subIdent of SomeRec
{ TPasExpr }
@ -114,6 +114,13 @@ type
constructor Create(AKind: TPasExprKind; const ABoolValue : Boolean);
end;
{ TNilExpr }
TNilExpr = class(TPasExpr)
Value : Boolean;
constructor Create;
end;
{ TParamsExpr }
TParamsExpr = class(TPasExpr)
@ -2500,4 +2507,11 @@ begin
Values[i]:=AValue;
end;
{ TNilExpr }
constructor TNilExpr.Create;
begin
inherited Create(pekNil, eopNone);
end;
end.

View File

@ -143,7 +143,7 @@ type
function ParseComplexType(Parent : TPasElement = Nil): TPasType;
procedure ParseArrayType(Element: TPasArrayType);
procedure ParseFileType(Element: TPasFileType);
function DoParseExpression: TPasExpr;
function DoParseExpression(InitExpr: TPasExpr=nil): TPasExpr;
function DoParseConstValueExpression: TPasExpr;
function ParseExpression: String;
function ParseCommand: String; // single, not compound command like begin..end
@ -721,6 +721,7 @@ begin
tkNot : Result:=eopNot;
tkIn : Result:=eopIn;
tkDot : Result:=eopSubIdent;
tkCaret : Result:=eopDeref;
else
ParseExc(format('Not an operand: (%d : %s)',[AToken,TokenInfos[AToken]]));
end;
@ -741,6 +742,7 @@ begin
tkNumber: x:=TPrimitiveExpr.Create(pekNumber, CurTokenString);
tkIdentifier: x:=TPrimitiveExpr.Create(pekIdent, CurTokenText);
tkfalse, tktrue: x:=TBoolConstExpr.Create(pekBoolConst, CurToken=tktrue);
tknil: x:=TNilExpr.Create;
tkSquaredBraceOpen: x:=ParseParams(pekSet);
else
ParseExc(SParserExpectedIdentifier);
@ -809,7 +811,7 @@ begin
end;
end;
function TPasParser.DoParseExpression: TPasExpr;
function TPasParser.DoParseExpression(InitExpr: TPasExpr): TPasExpr;
var
expstack : TList;
opstack : TList;
@ -868,28 +870,50 @@ begin
repeat
AllowEnd:=True;
pcount:=0;
while CurToken in PrefixSym do begin
PushOper(CurToken);
inc(pcount);
NextToken;
end;
if CurToken = tkBraceOpen then begin
NextToken;
x:=DoParseExpression();
if CurToken<>tkBraceClose then Exit;
NextToken;
end else begin
x:=ParseExpIdent;
end;
if not Assigned(InitExpr) then
begin
// the first part of the expression has been parsed externally.
// this is used by Constant Expresion parser (CEP) parsing only,
// whenever it makes a false assuming on constant expression type.
// i.e: SI_PAD_SIZE = ((128/sizeof(longint)) - 3);
//
// CEP assumes that it's array or record, because the expression
// starts with "(". After the first part is parsed, the CEP meets "-"
// that assures, it's not an array expression. The CEP should give the
// first partback to the expression parser, to get the correct
// token tree according to the operations priority.
//
// quite ugly. type information is required for CEP to work clean
if not Assigned(x) then Exit;
expstack.Add(x);
for i:=1 to pcount do
begin
tempop:=PopOper;
expstack.Add( TUnaryExpr.Create( PopExp, TokenToExprOp(tempop) ));
while CurToken in PrefixSym do begin
PushOper(CurToken);
inc(pcount);
NextToken;
end;
if CurToken = tkBraceOpen then begin
NextToken;
x:=DoParseExpression();
if CurToken<>tkBraceClose then Exit;
NextToken;
end else begin
x:=ParseExpIdent;
end;
if not Assigned(x) then Exit;
expstack.Add(x);
for i:=1 to pcount do begin
tempop:=PopOper;
expstack.Add( TUnaryExpr.Create( PopExp, TokenToExprOp(tempop) ));
end;
end else
begin
expstack.Add(InitExpr);
InitExpr:=nil;
end;
if not (CurToken in EndExprToken) then begin
// Adjusting order of the operations
AllowEnd:=False;
@ -1020,7 +1044,8 @@ begin
Result:=r;
end;
else
Result:=x;
// Binary expression! ((128 div sizeof(longint)) - 3); ;
Result:=DoParseExpression(x);
end;
if CurToken<>tkBraceClose then ParseExc(SParserExpectedCommaRBracket);
NextToken;
@ -3130,8 +3155,7 @@ begin
if (s = 'sealed') or (s = 'abstract') then begin
TPasClassType(Result).Modifiers.Add(s);
NextToken;
end else
ExpectToken(tkSemicolon);
end;
end;
// Parse ancestor list

View File

@ -632,7 +632,7 @@ begin
Inc(TokenStr);
repeat
Inc(TokenStr);
until not (TokenStr[0] in ['0'..'9', 'A'..'F', 'a'..'F']);
until not (TokenStr[0] in ['0'..'9', 'A'..'F', 'a'..'f']);
end else
repeat
Inc(TokenStr);