3 <<file
:__EnableUnstableFeatures('expression_trees')>>
5 function test(): void
{
6 Code`
__splice__(1 +
__splice__(4))`
;
10 // Placeholder definition so we don't get naming/typing errors.
12 const type TAst
= mixed;
14 public function intLiteral(?ExprPos
$_, int $_): this
::TAst
{
15 throw new Exception();
17 public function boolLiteral(?ExprPos
$_, bool $_): this
::TAst
{
18 throw new Exception();
20 public function stringLiteral(?ExprPos
$_, string $_): this
::TAst
{
21 throw new Exception();
23 public function nullLiteral(?ExprPos
$_): this
::TAst
{
24 throw new Exception();
26 public function localVar(?ExprPos
$_, string $_): this
::TAst
{
27 throw new Exception();
29 public function lambdaLiteral(
32 vec
<this
::TAst
> $_body,
34 throw new Exception();
43 throw new Exception();
45 public function ampamp(
50 throw new Exception();
52 public function barbar(
57 throw new Exception();
59 public function exclamationMark(
63 throw new Exception();
68 vec
<this
::TAst
> $_args,
70 throw new Exception();
73 public function assign(
78 throw new Exception();
82 public function ifStatement(
85 vec
<this
::TAst
> $_then_body,
86 vec
<this
::TAst
> $_else_body,
88 throw new Exception();
90 public function whileStatement(
93 vec
<this
::TAst
> $_body,
95 throw new Exception();
97 public function returnStatement(
101 throw new Exception();
103 public function forStatement(
110 throw new Exception();
112 public function breakStatement(?ExprPos
$_): this
::TAst
{
113 throw new Exception();
115 public function continueStatement(?ExprPos
$_,): this
::TAst
{
116 throw new Exception();
120 public function splice
<T
>(
122 ExprTree
<this
, this
::TAst
, T
> $_,
124 throw new Exception();
127 // TODO: Discard unsupported syntax nodes while lowering
128 public function unsupportedSyntax(string $msg): this
::TAst
{
129 throw new Exception($msg);
133 final class ExprTree
<TVisitor
, TResult
, TInfer
>{
134 public function __construct(
135 private ?ExprPos
$pos,
136 private (function(TVisitor
): TResult
) $x,
137 private (function(): TInfer
) $err,
141 final class ExprPos
{
142 public function __construct(
143 private int $begin_line,
144 private int $begin_col,
145 private int $end_line,
146 private int $end_col,