diff --git a/lib/python/ast/Match.php b/lib/python/ast/Match.php deleted file mode 100644 index 6057ef0..0000000 --- a/lib/python/ast/Match.php +++ /dev/null @@ -1,15 +0,0 @@ -_self = \PyCore::import('ast')->Match(); - } - -} diff --git a/lib/python/ast/Return.php b/lib/python/ast/Return.php deleted file mode 100644 index 8890bb0..0000000 --- a/lib/python/ast/Return.php +++ /dev/null @@ -1,15 +0,0 @@ -_self = \PyCore::import('ast')->Return(); - } - -} diff --git a/lib/python/ast/Try.php b/lib/python/ast/Try.php deleted file mode 100644 index 6a45bf5..0000000 --- a/lib/python/ast/Try.php +++ /dev/null @@ -1,15 +0,0 @@ -_self = \PyCore::import('ast')->Try(); - } - -} diff --git a/lib/python/ast/While.php b/lib/python/ast/While.php deleted file mode 100644 index 3845962..0000000 --- a/lib/python/ast/While.php +++ /dev/null @@ -1,15 +0,0 @@ -_self = \PyCore::import('ast')->While(); - } - -} diff --git a/lib/python/ast/Yield.php b/lib/python/ast/Yield.php deleted file mode 100644 index 3df1ab8..0000000 --- a/lib/python/ast/Yield.php +++ /dev/null @@ -1,15 +0,0 @@ -_self = \PyCore::import('ast')->Yield(); - } - -} diff --git a/lib/python/ast/List.php b/lib/python/ast/_And.php similarity index 62% rename from lib/python/ast/List.php rename to lib/python/ast/_And.php index f7c0a30..2a7eb55 100644 --- a/lib/python/ast/List.php +++ b/lib/python/ast/_And.php @@ -3,13 +3,13 @@ /** */ -class List +class _And { private $_self; public function __construct() { - $this->_self = \PyCore::import('ast')->List(); + $this->_self = \PyCore::import('ast')->_And(); } } diff --git a/lib/python/ast/Global.php b/lib/python/ast/_Break.php similarity index 60% rename from lib/python/ast/Global.php rename to lib/python/ast/_Break.php index 020a714..d3d72c5 100644 --- a/lib/python/ast/Global.php +++ b/lib/python/ast/_Break.php @@ -3,13 +3,13 @@ /** */ -class Global +class _Break { private $_self; public function __construct() { - $this->_self = \PyCore::import('ast')->Global(); + $this->_self = \PyCore::import('ast')->_Break(); } } diff --git a/lib/python/ast/Continue.php b/lib/python/ast/_Continue.php similarity index 58% rename from lib/python/ast/Continue.php rename to lib/python/ast/_Continue.php index fe07792..8940e5e 100644 --- a/lib/python/ast/Continue.php +++ b/lib/python/ast/_Continue.php @@ -3,13 +3,13 @@ /** */ -class Continue +class _Continue { private $_self; public function __construct() { - $this->_self = \PyCore::import('ast')->Continue(); + $this->_self = \PyCore::import('ast')->_Continue(); } } diff --git a/lib/python/ast/If.php b/lib/python/ast/_For.php similarity index 62% rename from lib/python/ast/If.php rename to lib/python/ast/_For.php index 48ecde0..87ff774 100644 --- a/lib/python/ast/If.php +++ b/lib/python/ast/_For.php @@ -3,13 +3,13 @@ /** */ -class If +class _For { private $_self; public function __construct() { - $this->_self = \PyCore::import('ast')->If(); + $this->_self = \PyCore::import('ast')->_For(); } } diff --git a/lib/python/ast/_Global.php b/lib/python/ast/_Global.php new file mode 100644 index 0000000..f86b58e --- /dev/null +++ b/lib/python/ast/_Global.php @@ -0,0 +1,15 @@ +_self = \PyCore::import('ast')->_Global(); + } + +} diff --git a/lib/python/ast/And.php b/lib/python/ast/_If.php similarity index 62% rename from lib/python/ast/And.php rename to lib/python/ast/_If.php index bb6cd87..b997992 100644 --- a/lib/python/ast/And.php +++ b/lib/python/ast/_If.php @@ -3,13 +3,13 @@ /** */ -class And +class _If { private $_self; public function __construct() { - $this->_self = \PyCore::import('ast')->And(); + $this->_self = \PyCore::import('ast')->_If(); } } diff --git a/lib/python/ast/Break.php b/lib/python/ast/_List.php similarity index 61% rename from lib/python/ast/Break.php rename to lib/python/ast/_List.php index b4b1ad7..8f98da7 100644 --- a/lib/python/ast/Break.php +++ b/lib/python/ast/_List.php @@ -3,13 +3,13 @@ /** */ -class Break +class _List { private $_self; public function __construct() { - $this->_self = \PyCore::import('ast')->Break(); + $this->_self = \PyCore::import('ast')->_List(); } } diff --git a/lib/python/ast/_Match.php b/lib/python/ast/_Match.php new file mode 100644 index 0000000..a6e6acb --- /dev/null +++ b/lib/python/ast/_Match.php @@ -0,0 +1,15 @@ +_self = \PyCore::import('ast')->_Match(); + } + +} diff --git a/lib/python/ast/Or.php b/lib/python/ast/_Or.php similarity index 62% rename from lib/python/ast/Or.php rename to lib/python/ast/_Or.php index 5a660e3..b2bf192 100644 --- a/lib/python/ast/Or.php +++ b/lib/python/ast/_Or.php @@ -3,13 +3,13 @@ /** */ -class Or +class _Or { private $_self; public function __construct() { - $this->_self = \PyCore::import('ast')->Or(); + $this->_self = \PyCore::import('ast')->_Or(); } } diff --git a/lib/python/ast/_Return.php b/lib/python/ast/_Return.php new file mode 100644 index 0000000..8cde431 --- /dev/null +++ b/lib/python/ast/_Return.php @@ -0,0 +1,15 @@ +_self = \PyCore::import('ast')->_Return(); + } + +} diff --git a/lib/python/ast/For.php b/lib/python/ast/_Try.php similarity index 62% rename from lib/python/ast/For.php rename to lib/python/ast/_Try.php index e1d3b73..14beacc 100644 --- a/lib/python/ast/For.php +++ b/lib/python/ast/_Try.php @@ -3,13 +3,13 @@ /** */ -class For +class _Try { private $_self; public function __construct() { - $this->_self = \PyCore::import('ast')->For(); + $this->_self = \PyCore::import('ast')->_Try(); } } diff --git a/lib/python/ast/_While.php b/lib/python/ast/_While.php new file mode 100644 index 0000000..66f3ece --- /dev/null +++ b/lib/python/ast/_While.php @@ -0,0 +1,15 @@ +_self = \PyCore::import('ast')->_While(); + } + +} diff --git a/lib/python/ast/_Yield.php b/lib/python/ast/_Yield.php new file mode 100644 index 0000000..fb6892f --- /dev/null +++ b/lib/python/ast/_Yield.php @@ -0,0 +1,15 @@ +_self = \PyCore::import('ast')->_Yield(); + } + +} diff --git a/tools/src/Tool.php b/tools/src/Tool.php index 1a7567c..0456015 100644 --- a/tools/src/Tool.php +++ b/tools/src/Tool.php @@ -18,6 +18,22 @@ class Tool '__sizeof__', ]; + protected const KEYWORDS = [ + 'and', + 'break', + 'continue', + 'for', + 'global', + 'if', + 'list', + 'match', + 'or', + 'return', + 'try', + 'while', + 'yield', + ]; + static function render($tplFile, $outFile, $vars, $prefix = ''): void { extract($vars); @@ -65,6 +81,9 @@ static function valueToRepr($v, $python = false): ?string public static function parseClass($module_name, $class_name, $class): void { + if (in_array(strtolower($class_name), self::KEYWORDS)) { + $class_name = '_' . $class_name; + } $methods = []; $properties = []; $constructor = ['call' => '', 'args' => ''];