Nop-Node
This commit is contained in:
@@ -9,6 +9,7 @@ uses
|
||||
|
||||
var
|
||||
// This BNF should always be kept up to date and valid. It is used to comunicate with LLMs.
|
||||
// (Nop isn't part of the language syntax.)
|
||||
|
||||
BNF: String =
|
||||
'''
|
||||
@@ -221,6 +222,7 @@ type
|
||||
procedure VisitAddSeriesItem(const Node: IAddSeriesItemNode); override;
|
||||
procedure VisitSeriesLength(const Node: ISeriesLengthNode); override;
|
||||
procedure VisitRecurNode(const Node: IRecurNode); override;
|
||||
procedure VisitNop(const Node: INopNode); override;
|
||||
end;
|
||||
|
||||
{ TLexer }
|
||||
@@ -716,7 +718,24 @@ begin
|
||||
end;
|
||||
tkIdentifier:
|
||||
begin
|
||||
Result.Node := TAst.Identifier(FCurrentToken.Text);
|
||||
// Check for the NOP token ('...')
|
||||
if FCurrentToken.Text = '...' then
|
||||
begin
|
||||
// The token '...' represents the Nop node, a non-compilable placeholder used exclusively
|
||||
// for visual representations (e.g., UI drag targets).
|
||||
//
|
||||
// We handle it as a special case of tkIdentifier instead of introducing a dedicated tkNop
|
||||
// TokenKind because of its **unofficial and transient status**.
|
||||
//
|
||||
// This allows the Parser to immediately apply the syntactic policy: mapping this
|
||||
// specific identifier string directly to the non-standard TAst.Nop node, ensuring
|
||||
// it bypasses the regular identifier creation and maintains its "placeholder" identity.
|
||||
Result.Node := TAst.Nop;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Result.Node := TAst.Identifier(FCurrentToken.Text);
|
||||
end;
|
||||
NextToken;
|
||||
end;
|
||||
tkLeftParen: Result.Node := ParseList;
|
||||
@@ -1068,6 +1087,13 @@ begin
|
||||
Append(')');
|
||||
end;
|
||||
|
||||
procedure TPrettyPrintVisitor.VisitNop(const Node: INopNode);
|
||||
begin
|
||||
// A placeholder node, usually for UI.
|
||||
//TODO Nop soll durch ein spezielles ...-Token repräsentiert werden. Analysiere, ob dies syntaktisch möglich ist. Wenn ja, soll der Parser "inoffiziell" in der Lage sein Nops zu lesen und zu erzeugen.
|
||||
Append('...');
|
||||
end;
|
||||
|
||||
procedure TPrettyPrintVisitor.VisitSeriesLength(const Node: ISeriesLengthNode);
|
||||
begin
|
||||
Append('(count ');
|
||||
|
||||
Reference in New Issue
Block a user