3 <<file
:__EnableUnstableFeatures('expression_trees')>>
8 // Spliced Expressions need to be ExprTrees
9 $y = Code`
__splice__($x)`
;
13 // Placeholder definition so we don't get naming/typing errors.
15 const type TAst
= mixed;
17 public function intLiteral(?ExprPos
$_, int $_): this
::TAst
{
18 throw new Exception();
20 public function boolLiteral(?ExprPos
$_, bool $_): this
::TAst
{
21 throw new Exception();
23 public function stringLiteral(?ExprPos
$_, string $_): this
::TAst
{
24 throw new Exception();
26 public function nullLiteral(?ExprPos
$_): this
::TAst
{
27 throw new Exception();
29 public function localVar(?ExprPos
$_, string $_): this
::TAst
{
30 throw new Exception();
32 public function lambdaLiteral(
35 vec
<this
::TAst
> $_body,
37 throw new Exception();
46 throw new Exception();
48 public function ampamp(
53 throw new Exception();
55 public function barbar(
60 throw new Exception();
62 public function exclamationMark(
66 throw new Exception();
71 vec
<this
::TAst
> $_args,
73 throw new Exception();
76 public function assign(
81 throw new Exception();
85 public function ifStatement(
88 vec
<this
::TAst
> $_then_body,
89 vec
<this
::TAst
> $_else_body,
91 throw new Exception();
93 public function whileStatement(
96 vec
<this
::TAst
> $_body,
98 throw new Exception();
100 public function returnStatement(
104 throw new Exception();
106 public function forStatement(
113 throw new Exception();
115 public function breakStatement(?ExprPos
$_): this
::TAst
{
116 throw new Exception();
118 public function continueStatement(?ExprPos
$_,): this
::TAst
{
119 throw new Exception();
123 public function splice
<T
>(
125 ExprTree
<this
, this
::TAst
, T
> $_,
127 throw new Exception();
130 // TODO: Discard unsupported syntax nodes while lowering
131 public function unsupportedSyntax(string $msg): this
::TAst
{
132 throw new Exception($msg);
136 final class ExprTree
<TVisitor
, TResult
, TInfer
>{
137 public function __construct(
138 private ?ExprPos
$pos,
139 private (function(TVisitor
): TResult
) $x,
140 private (function(): TInfer
) $err,
144 final class ExprPos
{
145 public function __construct(
146 private int $begin_line,
147 private int $begin_col,
148 private int $end_line,
149 private int $end_col,