diff --git a/Source/SimpleParser/SimpleParser.Lexer.pas b/Source/SimpleParser/SimpleParser.Lexer.pas index 2257785..bc01580 100644 --- a/Source/SimpleParser/SimpleParser.Lexer.pas +++ b/Source/SimpleParser/SimpleParser.Lexer.pas @@ -574,6 +574,7 @@ procedure TmwBasePasLex.InitIdent; 141: FIdentFuncTable[I] := Func141; 142: FIdentFuncTable[I] := Func142; 143: FIdentFuncTable[I] := Func143; + 158: FIdentFuncTable[I] := Func158; 166: FIdentFuncTable[I] := Func166; 167: FIdentFuncTable[I] := Func167; 168: FIdentFuncTable[I] := Func168; diff --git a/Test/UnitTests/DelphiAST.Tests.pas b/Test/UnitTests/DelphiAST.Tests.pas index 9053210..b69a872 100644 --- a/Test/UnitTests/DelphiAST.Tests.pas +++ b/Test/UnitTests/DelphiAST.Tests.pas @@ -300,6 +300,23 @@ procedure TestRepeatedCallingConvention; end; end; +procedure TestUnicodeStringTypecast; +var + Root, CallNode, Callee: TSyntaxNode; +begin + Root := ParseSource('unit Example; interface implementation ' + + 'procedure Run(p: Pointer); var s: UnicodeString; begin s := UnicodeString(p^); end; end.'); + try + CallNode := FindDescendant(Root, ntCall); + AssertNotNil(CallNode, 'Missing call'); + Callee := CallNode.ChildNodes[0]; + AssertTrue(Callee.Typ = ntType, 'A UnicodeString typecast has a type as its callee.'); + AssertEquals('UnicodeString', Callee.GetAttribute(anName), 'Typecast type name.'); + finally + Root.Free; + end; +end; + procedure TestInvalidSyntax; var Root: TSyntaxNode; @@ -379,6 +396,7 @@ procedure RunAllTests; RunTest('Node.AttributeOverwrite', TestAttributeOverwrite); RunTest('Node.AttributeRemove', TestAttributeRemove); RunTest('AST.RepeatedCallingConvention', TestRepeatedCallingConvention); + RunTest('AST.UnicodeStringTypecast', TestUnicodeStringTypecast); RunTest('Parser.InvalidSyntax', TestInvalidSyntax); RunTest('Parser.UnexpectedEndOfFilePosition', TestUnexpectedEndOfFilePosition); {$IFNDEF FPC}