From bd40b2a638d33c2e7f12a309514a0fe38f1986c5 Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 13 Mar 2015 00:06:00 +0000 Subject: [PATCH] codetools: fixed parsing class n:t; public in targetcpu=jvm git-svn-id: trunk@48326 - --- components/codetools/pascalparsertool.pas | 30 +++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas index b89da164a8..30f7665587 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -3285,7 +3285,21 @@ procedure TPascalParserTool.ReadVariableType; var ParentNode: TCodeTreeNode; HasSemicolon: Boolean; - CanExternal: Boolean; + + function CanExternal: Boolean; inline; + begin + Result:=(CurNode.Parent.Desc in [ctnVarSection,ctnClassClassVar]) + and ((CurNode.Parent.Parent.Desc in AllCodeSections) + or ((CurNode.Parent.Parent.Desc in (AllClassBaseSections+AllClassInterfaces)) + and Scanner.Values.IsDefined('CPUJVM'))); + end; + + function CanPublic: Boolean; inline; + begin + Result:=(CurNode.Parent.Desc in [ctnVarSection]) + and (CurNode.Parent.Parent.Desc in AllCodeSections); + end; + begin ReadNextAtom; // type @@ -3340,12 +3354,9 @@ begin end; //if UpAtomIs('EXTERNAL') then // debugln(['TPascalParserTool.ReadVariableType ',CurNode.Parent.Parent.DescAsString,' ',CurNode.Parent.DescAsString,' ',CurNode.DescAsString]); - CanExternal:=(CurNode.Parent.Desc in [ctnVarSection,ctnClassClassVar]) - and ((CurNode.Parent.Parent.Desc in AllCodeSections) - or ((CurNode.Parent.Parent.Desc in (AllClassBaseSections+AllClassInterfaces)) - and Scanner.Values.IsDefined('CPUJVM'))); - if CanExternal and (UpAtomIs('PUBLIC') or UpAtomIs('EXPORT') - or UpAtomIs('EXTERNAL') or UpAtomIs('WEAKEXTERNAL')) then + if ((UpAtomIs('EXPORT') or UpAtomIs('EXTERNAL') or UpAtomIs('WEAKEXTERNAL')) + and CanExternal) + or (UpAtomIs('PUBLIC') and CanPublic) then begin // examples: // a: b; public; @@ -3354,7 +3365,6 @@ begin // a: b; external c; // a: b; external name 'c'; // a: b; external 'library' name 'c'; - // a: b; section 'c'; if UpAtomIs('EXTERNAL') or UpAtomIs('WEAKEXTERNAL') then begin // read external identifier ReadNextAtom; @@ -3381,8 +3391,8 @@ begin end; if CurPos.Flag<>cafSemicolon then SaveRaiseCharExpectedButAtomFound(';'); - end else if CanExternal and Scanner.Values.IsDefined('EMBEDDED') - and UpAtomIs('SECTION') then begin + end else if UpAtomIs('SECTION') and CanExternal and Scanner.Values.IsDefined('EMBEDDED') + then begin // section 'sectionname' ReadNextAtom; if (not AtomIsStringConstant)