pascalabcnet/AdditionalLanguages/SPython/SyntaxTreeConverters/SPythonStandardTreeConverter/EraseSpythonOnlyNodesVisitor.cs
Александр Земляк 17f6a9b956
Spython test suite (#3362)
* Reorganize files in TestSuite dir for multiple languages

* Add SPython samples to TestSuite

* Update TestRunner to support multiple languages

* Delete dll files accidentally pushed

* Update .gitignore

* Revert "Delete dll files accidentally pushed"

This reverts commit 62bcba2b821d58ae51ec98e9dadcf621bb0fc003.

* Update testing dir path in Testing.cs

* Improve TestRunner output

* Add random module and it's usage sample

* Reorganize gitignore files

* Move pascal tests back to TestSuite and create new TestSuiteLanguagePlugins folder for SPython

* Revert "Update testing dir path in Testing.cs"

This reverts commit 7d94eafb25292421bce8315520b4f6a0de001bbd.

* Revert crlf changes in pascal tests

* Test changes of _RebuildReleaseAndRunTestsForGitHubActions.bat

* Revert "Test changes of _RebuildReleaseAndRunTestsForGitHubActions.bat"

This reverts commit 234ceae3e3a339fbc68a6170e2bd201dab14d67d.

* Test changes in StorageLocationPicker

* Another test changes in StorageLocationPicker.cs

* Rename LanguagePlugins folder to AdditionalLanguages

* Decouple TestRunner from language names and parameters

* Revert calling TestRunner without parameters in .bat files

* Fix formatter tests nogui exception handling

* Small refactoring in Testing.cs and TestRunner fix of working directory
2025-12-21 21:11:52 +03:00

45 lines
1.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using PascalABCCompiler.SyntaxTree;
using System;
namespace Languages.SPython.Frontend.Converters
{
public class EraseSpythonOnlyNodesVisitor : BaseChangeVisitor
{
public EraseSpythonOnlyNodesVisitor() {}
public override void visit(global_statement _global_statement)
{
DeleteInStatementList(_global_statement);
}
public override void visit(import_statement _import_statement)
{
var upper = UpperNode();
if (upper is interface_node _interface_node)
_interface_node.interface_definitions.ReplaceDescendant<syntax_tree_node, syntax_tree_node>(
_import_statement, new empty_statement());
else Replace(_import_statement, new empty_statement());
}
public override void visit(from_import_statement _from_import_statement)
{
var upper = UpperNode();
if (upper is interface_node _interface_node)
_interface_node.interface_definitions.ReplaceDescendant<syntax_tree_node, syntax_tree_node>(
_from_import_statement, new empty_statement());
else Replace(_from_import_statement, new empty_statement());
}
public override void visit(tuple_node tup)
{
var dn = new ident("CreateTuple", tup.source_context);
var mc = new method_call(dn, tup.el, tup.source_context);
//var sug = new sugared_expression(tup, mc, tup.source_context); - нет никакой семантической проверки - всё - на уровне синтаксиса!
//ReplaceUsingParent(tup, mc); - исправление #1199. Оказывается, ReplaceUsingParent и Replace не эквивалентны - у копии Parent на старого родителя
Replace(tup, mc);
visit(mc);
}
}
}