Skip to content

Or Statements

Benedict Albrecht edited this page Jun 2, 2026 · 4 revisions

Or Statements

Or statements define alternative paths - the parser matches one of the listed options.


Syntax

<| optionA <||> optionB <||> ... |>

Example

A function with an optional visibility modifier:

<:function:> <| private <||> public <||> |> function <<name>> ( ) { <---> } <:>
Input Matched Option
private function myFunc () { } private
public function myFunc () { } public
function myFunc () { } (empty - optional)

Tip: An empty option before |> makes the entire or-block optional (zero occurrences accepted).



In Practice

The Basics grammar uses or-statements in several places:

Object Or-statement Alternatives
import <| <<name:up>> <||> { <<name:up>> } |> Direct import (import X) or destructured import (import { X })
import <| ; <||> \n |> Import ends with semicolon or newline
class / function <| , <||> <<NAME:down>> |> Parameter preceded by comma, or first parameter (no comma)

In the Test_Repo, import { C2 } from './bridgeTest2.txt' matches the { <<name:up>> } branch, while import C3 from '../refFile.txt' would match the <<name:up>> branch.


Next: Repeat Statements - Matching a pattern zero or more times.

Clone this wiki locally