Skip to content

Names should not be stored in a TValuedSyntaxNode #222

Open

Description

@JBontes

The TValuedSyntaxNode has no benefit over a normal ntName node that stores the name in the [anName] attribute.

I suggest the following changes:

procedure TPasSyntaxTreeBuilder.AttributeArgumentName;
begin
  //FStack.AddValuedChild(ntName, Lexer.Token);
  FStack.AddChild(ntName).SetAttribute(anName,Lexer.Token);
  inherited;
end;

procedure TPasSyntaxTreeBuilder.AttributeName;
begin
  //FStack.AddValuedChild(ntName, Lexer.Token);
  FStack.AddChild(ntname).SetAttribute(anName, Lexer.Token);
  inherited;
end;

procedure TPasSyntaxTreeBuilder.ConstantName;
begin
  //FStack.AddValuedChild(ntName, Lexer.Token);
  FStack.AddChild(ntName).SetAttribute(anName, Lexer.Token);
  inherited;
end;

procedure TPasSyntaxTreeBuilder.ExceptionVariable;
begin
  FStack.Push(ntVariable);
  //FStack.AddValuedChild(ntName, Lexer.Token);
  FStack.AddChild(ntName).SetAttribute(anName, Lexer.Token);
  try
    inherited;
  finally
    FStack.Pop;
  end;
end;

procedure TPasSyntaxTreeBuilder.FieldName;
begin
  //FStack.AddValuedChild(ntName, Lexer.Token);
  FStack.AddChild(ntname).SetAttribute(anName, Lexer.Token);
  inherited;
end;

procedure TPasSyntaxTreeBuilder.FunctionMethodName;
begin
  //FStack.AddValuedChild(ntName, Lexer.Token);
  FStack.AddChild(ntName).SetAttribute(anName, Lexer.Token);
  inherited;
end;

procedure TPasSyntaxTreeBuilder.ObjectNameOfMethod;
begin
  //FStack.AddValuedChild(ntName, Lexer.Token);
  FStack.AddChild(ntName).SetAttribute(anName, Lexer.Token);
  inherited;
end;

procedure TPasSyntaxTreeBuilder.ParameterName;
begin
  //FStack.AddValuedChild(ntName, Lexer.Token);
  FStack.AddChild(ntname).SetAttribute(anName, Lexer.Token);
  inherited;
end;

procedure TPasSyntaxTreeBuilder.VarName;
begin
  //FStack.AddValuedChild(ntName, Lexer.Token);
  FStack.AddChild(ntname).SetAttribute(anName, Lexer.Token);
  inherited;
end;

This simplifies the code and avoids the duplication between the anName attribute and the FValue member. Why have the anName attribute if not to store the name?

Activity

  1. added a commit that references this issue on Oct 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions