4 // Placeholder definition so we don't get naming/typing errors.
6 const type TAst
= mixed;
8 public function intLiteral(?ExprPos
$_, int $_): this
::TAst
{
11 public function boolLiteral(?ExprPos
$_, bool $_): this
::TAst
{
12 throw new Exception();
14 public function stringLiteral(?ExprPos
$_, string $_): this
::TAst
{
15 throw new Exception();
17 public function nullLiteral(?ExprPos
$_): this
::TAst
{
18 throw new Exception();
20 public function localVar(?ExprPos
$_, string $_): this
::TAst
{
21 throw new Exception();
23 public function lambdaLiteral(
26 vec
<this
::TAst
> $_body,
28 throw new Exception();
37 throw new Exception();
39 public function ampamp(
44 throw new Exception();
46 public function barbar(
51 throw new Exception();
53 public function exclamationMark(
57 throw new Exception();
62 vec
<this
::TAst
> $_args,
64 throw new Exception();
67 public function assign(
72 throw new Exception();
76 public function ifStatement(
79 vec
<this
::TAst
> $_then_body,
80 vec
<this
::TAst
> $_else_body,
82 throw new Exception();
84 public function whileStatement(
87 vec
<this
::TAst
> $_body,
89 throw new Exception();
91 public function returnStatement(
95 throw new Exception();
97 public function forStatement(
104 throw new Exception();
106 public function breakStatement(?ExprPos
$_): this
::TAst
{
107 throw new Exception();
109 public function continueStatement(?ExprPos
$_,): this
::TAst
{
110 throw new Exception();
114 public function splice
<T
>(
116 ExprTree
<this
, this
::TAst
, T
> $_,
118 throw new Exception();
121 // TODO: Discard unsupported syntax nodes while lowering
122 public function unsupportedSyntax(string $msg): this
::TAst
{
123 throw new Exception($msg);
127 final class ExprTree
<TVisitor
, TResult
, TInfer
>{
128 public function __construct(
129 private ?ExprPos
$pos,
130 private (function(TVisitor
): TResult
) $x,
131 private (function(): TInfer
) $err,
135 final class ExprPos
{
136 public function __construct(
137 private int $begin_line,
138 private int $begin_col,
139 private int $end_line,
140 private int $end_col,