3 <<file
:__EnableUnstableFeatures('expression_trees')>>
6 $addition = Code`
1 +
2`
;
11 // Placeholder definition so we don't get naming/typing errors.
13 const type TAst
= mixed;
15 public function intLiteral(int $_): this
::TAst
{
16 throw new Exception();
18 public function boolLiteral(bool $_): this
::TAst
{
19 throw new Exception();
21 public function stringLiteral(string $_): this
::TAst
{
22 throw new Exception();
24 public function nullLiteral(): this
::TAst
{
25 throw new Exception();
27 public function localVar(string $_): this
::TAst
{
28 throw new Exception();
30 public function lambdaLiteral(
32 vec
<this
::TAst
> $_body,
34 throw new Exception();
38 public function plus(this
::TAst
$_, this
::TAst
$_): this
::TAst
{
39 throw new Exception();
41 public function ampamp(this
::TAst
$_, this
::TAst
$_): this
::TAst
{
42 throw new Exception();
44 public function barbar(this
::TAst
$_, this
::TAst
$_): this
::TAst
{
45 throw new Exception();
47 public function exclamationMark(this
::TAst
$_): this
::TAst
{
48 throw new Exception();
50 public function call(string $_fnName, vec
<this
::TAst
> $_args): this
::TAst
{
51 throw new Exception();
54 public function assign(this
::TAst
$_, this
::TAst
$_): this
::TAst
{
55 throw new Exception();
59 public function ifStatement(
61 vec
<this
::TAst
> $_then_body,
62 vec
<this
::TAst
> $_else_body,
64 throw new Exception();
66 public function whileStatement(
68 vec
<this
::TAst
> $_body,
70 throw new Exception();
72 public function returnStatement(?this
::TAst
$_): this
::TAst
{
73 throw new Exception();
75 public function forStatement(
81 throw new Exception();
83 public function breakStatement(): this
::TAst
{
84 throw new Exception();
86 public function continueStatement(): this
::TAst
{
87 throw new Exception();
91 public function splice
<T
>(ExprTree
<this
, this
::TAst
, T
> $_): this
::TAst
{
92 throw new Exception();
95 // TODO: Discard unsupported syntax nodes while lowering
96 public function unsupportedSyntax(string $msg): this
::TAst
{
97 throw new Exception($msg);
101 final class ExprTree
<TVisitor
, TResult
, TInfer
>{
102 public function __construct(
103 private (function(TVisitor
): TResult
) $x,
104 private (function(): TInfer
) $err,