From 17fa3e9e0517662e7b49fcabdf68166a8914321c Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 7 Jul 2022 16:34:03 -0400 Subject: Add a precedence table to the syntax doc --- docs/doc/syntax.html | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) (limited to 'docs/doc') diff --git a/docs/doc/syntax.html b/docs/doc/syntax.html index 431156d3..94bace3c 100644 --- a/docs/doc/syntax.html +++ b/docs/doc/syntax.html @@ -6,6 +6,78 @@

Syntax overview

BQN syntax consists of expressions where computation is done, with a little organizing structure around them like assignment, functions, and list notation. Expressions are where the programmer is in control, so the design tries to do as much as possible with them before introducing special syntax.

+

Precedence

+

Here's a full table of precedence for BQN's glyphs (broader than "operator precedence", as an "operator" usually just corresponds to a function). Entries at the bottom make the biggest divisions in the program, while the ones further up are subdivisions.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LevelRoleAssociativityCharactersPlus
HighBrackets()⟨⟩{}[]
Field accessLeft-to-right.
Strandingn-ary
ModifierLeft-to-right∘⎉¨´ in Fn
FunctionRight-to-left+↕⊔⍉←↩⇐
Separator⋄, and newline?
Header:
LowBody;
+

While all of BQN's grammar fits into this table somehow, it's not really the whole story because subexpressions including parentheses and blocks might behave like functions or modifiers.

Special glyphs

The following glyphs are used for BQN syntax. Primitives (built-in functions and modifiers) are not listed in this table, and have their own page. Digits, characters, and the underscore _ are used for numbers and variable names.

@@ -53,6 +125,10 @@ + + + + -- cgit v1.2.3
Change
.Namespace field access
⋄, or newline Statement or element separator