parrotcode: Design and Implementation of Pipp | |
Contents | Language Implementations | Pipp |
internals - Design and Implementation of Pipp
See pipp.pod on where to get the code.
Not decided yet. Will be documented in pipp.pod. See also ../ROADMAP.
See testing.pod.
Parsing is done with Parrot Compiler Toolkit, PCT.
The parse tree is transformed to a Parrot Abstrace Syntax Tree. PIR und Bytecode is then generated from the PAST.
List of scopes and types of variables.
self
.
define
and defined
access this package scoped hash.
This approach works good enough for constants in the global namespace.
For namespaced constants the above approach could be extended to consider the namespace part of the constant,
the current namespace and the active namespace aliases.Another approach is to treat constants as namespaced variables and work with standard PAST techniques.
Experiments using that approach are underway.TODO: type hints in function declarations
There is a major bug in the implementation.
TODO: see t/php/closures.t
A namespace is introduced with the keyword namespace. The namespaced code can be enclosed in brackets. The namespace declaration needs to be the first statement in the file. With brackets, there can be multiple namespaces per file. Nesting is not possible. Namespaces don't carry over to included files. define() doesn't define in the current namespace. The backslash character serves as the namespace separator. Short names can be defined with use. Only classes, functions and constants are namespaced. The current namespace can be queried with __NAMESPACE__. Namespaces are case insensitive. No global code can precede the first namespace directive.
In order to ease implementation and testing, there are some divergences in Pipp.
require_once()
is supported,
but might have issues with variables.
Currently, Pipp has no support at all for extensions.
TODO: Embedding and Extending PHP, by Sahrah ... L<http://www.php.net/manual/en/internals2.php>
Using Modules from other HLLs. Inlining PIR and other languages.
See pipp.pod for a list of divergences.
See the Wiki. Roadsend, Zend, PHC.
Bernhard Schmalhofer - <Bernhard.Schmalhofer@gmx.de>
|