aboutsummaryrefslogtreecommitdiff
path: root/docs/book/SYNTAX.html
diff options
context:
space:
mode:
authorJJ2024-01-28 09:32:52 +0000
committerJJ2024-01-28 09:32:52 +0000
commit22c4776f9fddef47a6ce3f309e4eafa2fbdc3a65 (patch)
tree49101d75a3f980eb8f8560f464f816a6fb9c564a /docs/book/SYNTAX.html
parenta409dd7ea7d6d363d5ef971526b81d95e6add51d (diff)
docs: host mdbook
Diffstat (limited to 'docs/book/SYNTAX.html')
-rw-r--r--docs/book/SYNTAX.html412
1 files changed, 412 insertions, 0 deletions
diff --git a/docs/book/SYNTAX.html b/docs/book/SYNTAX.html
new file mode 100644
index 0000000..6aa71e8
--- /dev/null
+++ b/docs/book/SYNTAX.html
@@ -0,0 +1,412 @@
+<!DOCTYPE HTML>
+<html lang="en" class="light" dir="ltr">
+ <head>
+ <!-- Book generated using mdBook -->
+ <meta charset="UTF-8">
+ <title>Syntax - The Puck Programming Language</title>
+
+
+ <!-- Custom HTML head -->
+
+ <meta name="description" content="">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="theme-color" content="#ffffff">
+
+ <link rel="icon" href="favicon.svg">
+ <link rel="shortcut icon" href="favicon.png">
+ <link rel="stylesheet" href="css/variables.css">
+ <link rel="stylesheet" href="css/general.css">
+ <link rel="stylesheet" href="css/chrome.css">
+ <link rel="stylesheet" href="css/print.css" media="print">
+
+ <!-- Fonts -->
+ <link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
+ <link rel="stylesheet" href="fonts/fonts.css">
+
+ <!-- Highlight.js Stylesheets -->
+ <link rel="stylesheet" href="highlight.css">
+ <link rel="stylesheet" href="tomorrow-night.css">
+ <link rel="stylesheet" href="ayu-highlight.css">
+
+ <!-- Custom theme stylesheets -->
+
+ </head>
+ <body class="sidebar-visible no-js">
+ <div id="body-container">
+ <!-- Provide site root to javascript -->
+ <script>
+ var path_to_root = "";
+ var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light";
+ </script>
+
+ <!-- Work around some values being stored in localStorage wrapped in quotes -->
+ <script>
+ try {
+ var theme = localStorage.getItem('mdbook-theme');
+ var sidebar = localStorage.getItem('mdbook-sidebar');
+
+ if (theme.startsWith('"') && theme.endsWith('"')) {
+ localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
+ }
+
+ if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
+ localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
+ }
+ } catch (e) { }
+ </script>
+
+ <!-- Set the theme before any content is loaded, prevents flash -->
+ <script>
+ var theme;
+ try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
+ if (theme === null || theme === undefined) { theme = default_theme; }
+ var html = document.querySelector('html');
+ html.classList.remove('light')
+ html.classList.add(theme);
+ var body = document.querySelector('body');
+ body.classList.remove('no-js')
+ body.classList.add('js');
+ </script>
+
+ <input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
+
+ <!-- Hide / unhide sidebar before it is displayed -->
+ <script>
+ var body = document.querySelector('body');
+ var sidebar = null;
+ var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
+ if (document.body.clientWidth >= 1080) {
+ try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
+ sidebar = sidebar || 'visible';
+ } else {
+ sidebar = 'hidden';
+ }
+ sidebar_toggle.checked = sidebar === 'visible';
+ body.classList.remove('sidebar-visible');
+ body.classList.add("sidebar-" + sidebar);
+ </script>
+
+ <nav id="sidebar" class="sidebar" aria-label="Table of contents">
+ <div class="sidebar-scrollbox">
+ <ol class="chapter"><li class="chapter-item expanded affix "><a href="../index.html">The Puck Programming Language</a></li><li class="chapter-item expanded "><a href="OVERVIEW.html"><strong aria-hidden="true">1.</strong> Basic Usage</a></li><li><ol class="section"><li class="chapter-item expanded "><div><strong aria-hidden="true">1.1.</strong> Variables and Comments</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">1.2.</strong> Basic Types</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">1.3.</strong> Functions and Calls</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">1.4.</strong> Boolean and Integer Operations</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">1.5.</strong> Conditionals and Control Flow</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">1.6.</strong> Error Handling</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">1.7.</strong> Loops and Iterators</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">1.8.</strong> Modules</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">1.9.</strong> Compile-time Programming</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">1.10.</strong> Async and Threading</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">1.11.</strong> Advanced Types</div></li></ol></li><li class="chapter-item expanded "><a href="SYNTAX.html" class="active"><strong aria-hidden="true">2.</strong> Syntax</a></li><li><ol class="section"><li class="chapter-item expanded "><div><strong aria-hidden="true">2.1.</strong> Indentation Rules [todo]</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">2.2.</strong> Reserved Keywords</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">2.3.</strong> A Formal Grammar</div></li></ol></li><li class="chapter-item expanded "><a href="TYPES.html"><strong aria-hidden="true">3.</strong> Type System</a></li><li><ol class="section"><li class="chapter-item expanded "><div><strong aria-hidden="true">3.1.</strong> Basic Types</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">3.2.</strong> Parameter Types</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">3.3.</strong> Reference Types</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">3.4.</strong> Abstract Types</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">3.5.</strong> Advanced Types</div></li></ol></li><li class="chapter-item expanded "><a href="MODULES.html"><strong aria-hidden="true">4.</strong> Module System</a></li><li><ol class="section"><li class="chapter-item expanded "><div><strong aria-hidden="true">4.1.</strong> Using Modules</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">4.2.</strong> Implicit Modules</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">4.3.</strong> Defining Module Interfaces [todo]</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">4.4.</strong> Defining an External API [todo]</div></li></ol></li><li class="chapter-item expanded "><a href="ERRORS.html"><strong aria-hidden="true">5.</strong> Error Handling</a></li><li><ol class="section"><li class="chapter-item expanded "><div><strong aria-hidden="true">5.1.</strong> Errors as Monads</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">5.2.</strong> Errors as Catchable Exceptions</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">5.3.</strong> Errors and Void Functions [todo]</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">5.4.</strong> Unrecoverable Exceptions</div></li></ol></li><li class="chapter-item expanded "><a href="ASYNC.html"><strong aria-hidden="true">6.</strong> Async System</a></li><li><ol class="section"><li class="chapter-item expanded "><div><strong aria-hidden="true">6.1.</strong> Threading [todo]</div></li></ol></li><li class="chapter-item expanded "><a href="METAPROGRAMMING.html"><strong aria-hidden="true">7.</strong> Metaprogramming</a></li><li class="chapter-item expanded "><div><strong aria-hidden="true">8.</strong> Memory Management [todo]</div></li><li><ol class="section"><li class="chapter-item expanded "><div><strong aria-hidden="true">8.1.</strong> Reference Counting Optimizations</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">8.2.</strong> Annotations and Ownership</div></li></ol></li><li class="chapter-item expanded "><a href="INTEROP.html"><strong aria-hidden="true">9.</strong> Language Interop [draft]</a></li><li><ol class="section"><li class="chapter-item expanded "><div><strong aria-hidden="true">9.1.</strong> Rust, Swift, Nim</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">9.2.</strong> Java, Kotlin</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">9.3.</strong> Python, Racket, C</div></li></ol></li><li class="chapter-item expanded "><div><strong aria-hidden="true">10.</strong> Refinement Types [draft]</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">11.</strong> Dependent Types [draft]</div></li><li class="chapter-item expanded "><div><strong aria-hidden="true">12.</strong> Effects System [draft]</div></li></ol>
+ </div>
+ <div id="sidebar-resize-handle" class="sidebar-resize-handle">
+ <div class="sidebar-resize-indicator"></div>
+ </div>
+ </nav>
+
+ <!-- Track and set sidebar scroll position -->
+ <script>
+ var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox');
+ sidebarScrollbox.addEventListener('click', function(e) {
+ if (e.target.tagName === 'A') {
+ sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop);
+ }
+ }, { passive: true });
+ var sidebarScrollTop = sessionStorage.getItem('sidebar-scroll');
+ sessionStorage.removeItem('sidebar-scroll');
+ if (sidebarScrollTop) {
+ // preserve sidebar scroll position when navigating via links within sidebar
+ sidebarScrollbox.scrollTop = sidebarScrollTop;
+ } else {
+ // scroll sidebar to current active section when navigating via "next/previous chapter" buttons
+ var activeSection = document.querySelector('#sidebar .active');
+ if (activeSection) {
+ activeSection.scrollIntoView({ block: 'center' });
+ }
+ }
+ </script>
+
+ <div id="page-wrapper" class="page-wrapper">
+
+ <div class="page">
+ <div id="menu-bar-hover-placeholder"></div>
+ <div id="menu-bar" class="menu-bar sticky">
+ <div class="left-buttons">
+ <label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
+ <i class="fa fa-bars"></i>
+ </label>
+ <button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
+ <i class="fa fa-paint-brush"></i>
+ </button>
+ <ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
+ <li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
+ <li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
+ <li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
+ <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
+ <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
+ </ul>
+ <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
+ <i class="fa fa-search"></i>
+ </button>
+ </div>
+
+ <h1 class="menu-title">The Puck Programming Language</h1>
+
+ <div class="right-buttons">
+ <a href="print.html" title="Print this book" aria-label="Print this book">
+ <i id="print-button" class="fa fa-print"></i>
+ </a>
+
+ </div>
+ </div>
+
+ <div id="search-wrapper" class="hidden">
+ <form id="searchbar-outer" class="searchbar-outer">
+ <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
+ </form>
+ <div id="searchresults-outer" class="searchresults-outer hidden">
+ <div id="searchresults-header" class="searchresults-header"></div>
+ <ul id="searchresults">
+ </ul>
+ </div>
+ </div>
+
+ <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
+ <script>
+ document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
+ document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
+ Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
+ link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
+ });
+ </script>
+
+ <div id="content" class="content">
+ <main>
+ <h1 id="syntax-a-casual-and-formal-look"><a class="header" href="#syntax-a-casual-and-formal-look">Syntax: A Casual and Formal Look</a></h1>
+<blockquote>
+<p>! This section is <strong>incomplete</strong>. Proceed with caution.</p>
+</blockquote>
+<h2 id="reserved-keywords"><a class="header" href="#reserved-keywords">Reserved Keywords</a></h2>
+<p>The following keywords are reserved:</p>
+<ul>
+<li>variables: <code>let</code> <code>var</code> <code>const</code></li>
+<li>control flow: <code>if</code> <code>elif</code> <code>else</code></li>
+<li>pattern matching: <code>match</code> <code>of</code></li>
+<li>loops: <code>loop</code> <code>while</code> <code>for</code> <code>in</code></li>
+<li>blocks: <code>block</code> <code>break</code> <code>continue</code> <code>return</code></li>
+<li>functions: <code>func</code> <code>mut</code> <code>static</code> <code>varargs</code></li>
+<li>modules: <code>pub</code> <code>mod</code> <code>use</code> <code>as</code></li>
+<li>error handling: <code>try</code> <code>catch</code> <code>finally</code></li>
+<li>metaprogramming: <code>macro</code> <code>quote</code> <code>when</code></li>
+<li>types: <code>type</code> <code>distinct</code> <code>ref</code></li>
+<li>types: <code>struct</code> <code>tuple</code> <code>union</code> <code>enum</code> <code>interface</code></li>
+<li>reserved:
+<ul>
+<li><code>impl</code> <code>object</code> <code>class</code> <code>concept</code> <code>auto</code> <code>empty</code> <code>effect</code> <code>case</code></li>
+<li><code>suspend</code> <code>resume</code> <code>spawn</code> <code>pool</code> <code>thread</code> <code>closure</code></li>
+<li><code>cyclic</code> <code>acyclic</code> <code>sink</code> <code>move</code> <code>destroy</code> <code>copy</code> <code>trace</code> <code>deepcopy</code></li>
+</ul>
+</li>
+</ul>
+<p>The following identifiers are in use by the standard prelude:</p>
+<ul>
+<li>logic: <code>not</code> <code>and</code> <code>or</code> <code>xor</code> <code>shl</code> <code>shr</code> <code>div</code> <code>mod</code> <code>rem</code></li>
+<li>logic: <code>+</code> <code>-</code> <code>*</code> <code>/</code> <code>&lt;</code> <code>&gt;</code> <code>&lt;=</code> <code>&gt;=</code> <code>==</code> <code>!=</code> <code>is</code></li>
+<li>async: <code>async</code> <code>await</code></li>
+<li>types: <code>int</code> <code>uint</code> <code>float</code>
+<ul>
+<li><code>i8</code> <code>i16</code> <code>i32</code> <code>i64</code> <code>i128</code></li>
+<li><code>u8</code> <code>u16</code> <code>u32</code> <code>u64</code> <code>u128</code></li>
+<li><code>f32</code> <code>f64</code> <code>f128</code></li>
+<li><code>dec64</code> <code>dec128</code></li>
+</ul>
+</li>
+<li>types: <code>bool</code> <code>byte</code> <code>char</code> <code>str</code></li>
+<li>types: <code>void</code> <code>never</code></li>
+<li>strings: <code>&amp;</code> (string append)</li>
+</ul>
+<p>The following punctuation is taken:</p>
+<ul>
+<li><code>=</code> (assignment)</li>
+<li><code>.</code> (chaining)</li>
+<li><code>,</code> (params)</li>
+<li><code>;</code> (statements)</li>
+<li><code>:</code> (types)</li>
+<li><code>#</code> (comment)</li>
+<li><code>_</code> (unused bindings)</li>
+<li><code>|</code> (generics)</li>
+<li><code>\</code> (string/char escaping)</li>
+<li><code>()</code> (params, tuples)</li>
+<li><code>{}</code> (scope, structs)</li>
+<li><code>[]</code> (generics, lists)</li>
+<li><code>&quot;&quot;</code> (strings)</li>
+<li><code>''</code> (chars)</li>
+<li><code>``</code> (unquoting)</li>
+<li>unused: <code>~</code> <code>@</code> <code>$</code> <code>%</code></li>
+</ul>
+<h2 id="a-formal-grammar"><a class="header" href="#a-formal-grammar">A Formal Grammar</a></h2>
+<p>We now shall take a look at a more formal description of Puck's syntax. </p>
+<p>Syntax rules are described in <a href="https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form">extended Backus–Naur form</a> (EBNF): however, most rules surrounding whitespace, and scope, and line breaks, are modified to how they would appear after a lexing step.</p>
+<h3 id="identifiers"><a class="header" href="#identifiers">Identifiers</a></h3>
+<pre><code>Ident ::= (Letter | '_') (Letter | Digit | '_')*
+Letter ::= 'A'..'Z' | 'a'..'z' | '\x80'..'\xff' # todo
+Digit ::= '0'..'9'
+</code></pre>
+<h3 id="literals"><a class="header" href="#literals">Literals</a></h3>
+<pre><code>Int ::= '-'? (DecLit | HexLit | OctLit | BinLit)
+Float ::= '-'? DecLit '.' DecLit
+BinLit ::= '0b' BinDigit ('_'? BinDigit)*
+OctLit ::= '0o' OctDigit ('_'? OctDigit)*
+HexLit ::= '0x' HexDigit ('_'? HexDigit)*
+DecLit ::= Digit ('_'? Digit)*
+BinDigit ::= '0'..'1'
+OctDigit ::= '0'..'7'
+HexDigit ::= Digit | 'A'..'F' | 'a'..'f'
+</code></pre>
+<h3 id="chars-strings-and-comments"><a class="header" href="#chars-strings-and-comments">Chars, Strings, and Comments</a></h3>
+<pre><code>CHAR ::= '\'' (PRINT - '\'' | '\\\'')* '\''
+STRING ::= SINGLE_LINE_STRING | MULTI_LINE_STRING
+COMMENT ::= SINGLE_LINE_COMMENT | MULTI_LINE_COMMENT | EXPRESSION_COMMENT
+SINGLE_LINE_STRING ::= '&quot;' (PRINT - '&quot;' | '\\&quot;')* '&quot;'
+MULTI_LINE_STRING ::= '&quot;&quot;&quot;' (PRINT | '\n' | '\r')* '&quot;&quot;&quot;'
+SINGLE_LINE_COMMENT ::= '#' PRINT*
+MULTI_LINE_COMMENT ::= '#[' (PRINT | '\n' | '\r' | MULTI_LINE_COMMENT)* ']#'
+EXPRESSION_COMMENT ::= '#;' SINGLE_STMT
+PRINT ::= LETTER | DIGIT | OPR |
+ '&quot;' | '#' | &quot;'&quot; | '(' | ')' | # notably the dual of OPR
+ ',' | ';' | '[' | ']' | '_' |
+ '`' | '{' | '}' | ' ' | '\t'
+</code></pre>
+<h3 id="values"><a class="header" href="#values">Values</a></h3>
+<pre><code>Value ::= Int | Float | String | Char | Array | Tuple | Struct
+Array ::= '[' (Expr (',' Expr)*)? ']'
+Tuple ::= '(' (Ident ':')? Expr (',' (Ident ':')? Expr)* ')'
+Struct ::= '{' Ident ':' Expr (',' Ident ':' Expr)* '}'
+</code></pre>
+<h3 id="variables"><a class="header" href="#variables">Variables</a></h3>
+<pre><code>Decl ::= Let | Var | Const | Func | Type
+Let ::= 'let' Pattern Annotation? '=' Expr
+Var ::= 'var' Pattern Annotation? ('=' Expr)?
+Const ::= 'pub'? 'const' Pattern Annotation? '=' Expr
+Pattern ::= Char | String | Number | Float | Ident | '(' Pattern (',' Pattern)* ')'
+ Ident '(' Pattern (',' Pattern)* ')'
+</code></pre>
+<h3 id="declarations"><a class="header" href="#declarations">Declarations</a></h3>
+<pre><code>Func ::= 'pub'? 'func' Ident Generics? Parameters? Annotation? '=' Body
+Macro ::= 'pub'? 'macro' Ident Generics? Parameters? Annotation? '=' Body
+Generics ::= '[' Ident Annotation? (',' Ident Annotation?)* ']'
+Parameters ::= '(' Ident Annotation? (',' Ident Annotation?)* ')'
+Annotation ::= ':' Type
+</code></pre>
+<h3 id="types"><a class="header" href="#types">Types</a></h3>
+<pre><code>TypeDecl ::= 'pub'? 'type' Ident Generics? '=' Type
+Type ::= StructType | TupleType | EnumType | UnionType | Interface |
+ (('distinct' | 'ref' | 'ptr' | 'mut' | 'static') (Type | ('[' Type ']'))?)
+StructType ::= 'struct' ('[' Ident ':' Type (',' Ident ':' Type)* ']')?
+UnionType ::= 'union' ('[' Ident ':' Type (',' Ident ':' Type)* ']')?
+TupleType ::= 'tuple' ('[' (Ident ':')? Type (',' (Ident ':')? Type)* ']')?
+EnumType ::= 'enum' ('[' Ident ('=' Expr)? (',' Ident ('=' Expr)?)* ']')?
+Interface ::= 'interface' ('[' Signature (',' Signature)* ']')?
+Signature ::= Ident Generics? ('(' Type (',' Type)* ')')? Annotation?
+</code></pre>
+<h2 id="control-flow"><a class="header" href="#control-flow">Control Flow</a></h2>
+<pre><code>If ::= 'if' Expr ':' Body ('elif' Expr ':' Body)* ('else' ':' Body)?
+When ::= 'when' Expr ':' Body ('elif' Expr ':' Body)* ('else' ':' Body)?
+Try ::= 'try' ':' Body
+ ('except' Ident ('as' Ident)? (',' Ident ('as' Ident)?)*) ':' Body)*
+ ('finally' ':' Body)?
+Match ::= 'match' Expr ('of' Pattern (',' Pattern)* ('where' Expr)? ':' Body)+
+Block ::= 'block' Ident? ':' Body
+Block ::= 'static' ':' Body
+Loop ::= 'loop' ':' Body
+While ::= 'while' Expr ':' Body
+For ::= 'for' Pattern 'in' Expr Body
+</code></pre>
+<h2 id="modules"><a class="header" href="#modules">Modules</a></h2>
+<pre><code>Mod ::= 'pub'? 'mod' Ident ':' Body
+Use ::= 'use' Ident ('/' Ident)* ('/' ('[' Ident (',' Ident)* ']'))?
+</code></pre>
+<h3 id="operators"><a class="header" href="#operators">Operators</a></h3>
+<pre><code>Operator ::= 'and' | 'or' | 'not' | 'xor' | 'shl' | 'shr' |
+ 'div' | 'mod' | 'rem' | 'is' | 'in' |
+ Opr+
+Opr ::= '=' | '+' | '-' | '*' | '/' | '&lt;' | '&gt;' |
+ '@' | '$' | '~' | '&amp;' | '%' | '|' |
+ '!' | '?' | '^' | '.' | ':' | '\\'
+</code></pre>
+<h2 id="calls-and-expressions"><a class="header" href="#calls-and-expressions">Calls and Expressions</a></h2>
+<pre><code>Call ::= Ident ('[' Call (',' Call)* ']')? ('(' (Ident '=')? Call (',' (Ident '=')? Call)* ')')? |
+ Ident Call (',' Call)* |
+ Call Operator Call? |
+ Call ':' Body
+Expr ::= Let | Var | Const | Func | Type | Mod | Use | Block | Static |
+ For | While | Loop | If | When | Try | Match | Call
+Body ::= Expr | ('{' Expr (';' Expr)* '}')
+</code></pre>
+<hr />
+<p>References:</p>
+<ul>
+<li><a href="https://www.joshwcomeau.com/javascript/statements-vs-expressions/">Statements vs. Expressions</a></li>
+<li><a href="https://docs.swift.org/swift-book/ReferenceManual/LexicalStructure.html">Swift's Lexical Structure</a></li>
+<li><a href="https://nim-lang.github.io/Nim/manual.html">The Nim Programming Language</a></li>
+<li><a href="https://pgrandinetti.github.io/compilers/">Pietro's Notes on Compilers</a></li>
+</ul>
+
+ </main>
+
+ <nav class="nav-wrapper" aria-label="Page navigation">
+ <!-- Mobile navigation buttons -->
+ <a rel="prev" href="OVERVIEW.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
+ <i class="fa fa-angle-left"></i>
+ </a>
+
+ <a rel="next prefetch" href="TYPES.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
+ <i class="fa fa-angle-right"></i>
+ </a>
+
+ <div style="clear: both"></div>
+ </nav>
+ </div>
+ </div>
+
+ <nav class="nav-wide-wrapper" aria-label="Page navigation">
+ <a rel="prev" href="OVERVIEW.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
+ <i class="fa fa-angle-left"></i>
+ </a>
+
+ <a rel="next prefetch" href="TYPES.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
+ <i class="fa fa-angle-right"></i>
+ </a>
+ </nav>
+
+ </div>
+
+ <!-- Livereload script (if served using the cli tool) -->
+ <script>
+ const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
+ const wsAddress = wsProtocol + "//" + location.host + "/" + "__livereload";
+ const socket = new WebSocket(wsAddress);
+ socket.onmessage = function (event) {
+ if (event.data === "reload") {
+ socket.close();
+ location.reload();
+ }
+ };
+
+ window.onbeforeunload = function() {
+ socket.close();
+ }
+ </script>
+
+
+
+ <script>
+ window.playground_copyable = true;
+ </script>
+
+
+ <script src="elasticlunr.min.js"></script>
+ <script src="mark.min.js"></script>
+ <script src="searcher.js"></script>
+
+ <script src="clipboard.min.js"></script>
+ <script src="highlight.js"></script>
+ <script src="book.js"></script>
+
+ <!-- Custom JS scripts -->
+
+
+ </div>
+ </body>
+</html>