Tests for Parser
This commit is contained in:
@@ -16,6 +16,9 @@ uses
|
||||
Myc.Ast;
|
||||
|
||||
type
|
||||
// Exception specific to the binding phase (e.g. undefined symbols, invalid identifiers)
|
||||
EBinderException = class(EAstException);
|
||||
|
||||
IAstBinder = interface(IAstVisitor)
|
||||
function Execute(const RootNode: IAstNode; out Layout: IScopeLayout): IAstNode;
|
||||
end;
|
||||
@@ -236,7 +239,7 @@ begin
|
||||
if Node.Address.Kind = akUnresolved then
|
||||
begin
|
||||
if not ResolveSymbol(Node.Name, physAddr) then
|
||||
raise Exception.CreateFmt('Undefined identifier: "%s"', [Node.Name]);
|
||||
raise EBinderException.CreateFmt('Undefined identifier: "%s"', [Node.Name]);
|
||||
|
||||
if physAddr.ScopeDepth > 0 then
|
||||
begin
|
||||
@@ -262,7 +265,7 @@ var
|
||||
begin
|
||||
var identifier := Node.Target.AsIdentifier;
|
||||
if not IsValidIdentifier(identifier.Name) then
|
||||
raise Exception.CreateFmt('Invalid identifier name: "%s".', [identifier.Name]);
|
||||
raise EBinderException.CreateFmt('Invalid identifier name: "%s".', [identifier.Name]);
|
||||
|
||||
slot := FCurrentBuilder.Define(identifier.Name);
|
||||
addr := TResolvedAddress.Create(akLocalOrParent, 0, slot);
|
||||
|
||||
Reference in New Issue
Block a user