github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/parser/curly-brace.md (about)

     1  # `{ Curly Brace }`
     2  
     3  > Initiates or terminates a code block
     4  
     5  ## Description
     6  
     7  Curly braces are used to denote the start and end of a code block. Like with
     8  the single quotation marks (`'`), any code inside a curly brace is not parsed.
     9  Also unlike any other quotation tokens, the curly brace is included as part
    10  of the parsed string.
    11  
    12  ```
    13  » out {example}
    14  {example}
    15  ```
    16  
    17  Also like the brace quote (`(`, `)`), the curly brace character is only
    18  recognized as a curly brace token if it is the start of a parameter.
    19  
    20  Curly braces are also used for other fields besides code blocks. For example
    21  inlining JSON.
    22  
    23  
    24  
    25  ## Detail
    26  
    27  ### Multiline Blocks
    28  
    29  Curly braces can work over multiple lines
    30  
    31  ```
    32  » out {foo
    33  » bar}
    34  {foo
    35  bar}
    36  ```
    37  
    38  ### Code Golfing
    39  
    40  Curly braces can be used to terminate the parsing of the command name and/or
    41  parameters too:
    42  
    43  ```
    44  if{true}{out Yipee}
    45  ```
    46  
    47  ### Nesting
    48  
    49  Curly braces can be nested:
    50  
    51  ```
    52  » out {{foo} bar}
    53  {{foo} bar}
    54  ```
    55  
    56  ### ANSI Constants
    57  
    58  Some builtins (like `out`) also support infixing using the curly brace. eg
    59  
    60  ```
    61  out "{GREEN}PASSED{RESET}"
    62  ```
    63  
    64  This is a separate layer of parsing and happens at the parameter level for
    65  specific builtins which opt to support ANSI constants. See the ANSI Constant
    66  user guide (link below) for more information on supporting builtins and which
    67  constants are available.
    68  
    69  ## See Also
    70  
    71  * [ANSI Constants](../user-guide/ansi.md):
    72    Infixed constants that return ANSI escape sequences
    73  * [Array (`@`) Token](../parser/array.md):
    74    Expand values as an array
    75  * [Code Block Parsing](../user-guide/code-block.md):
    76    Overview of how code blocks are parsed
    77  * [Tilde (`~`) Token](../parser/tilde.md):
    78    Home directory path variable
    79  * [`"Double Quote"`](../parser/double-quote.md):
    80    Initiates or terminates a string (variables expanded)
    81  * [`%(Brace Quote)`](../parser/brace-quote.md):
    82    Initiates or terminates a string (variables expanded)
    83  * [`'Single Quote'`](../parser/single-quote.md):
    84    Initiates or terminates a string (variables not expanded)
    85  * [`(brace quote)`](../parser/brace-quote-func.md):
    86    Write a string to the STDOUT without new line (deprecated)
    87  * [`err`](../commands/err.md):
    88    Print a line to the STDERR
    89  * [`out`](../commands/out.md):
    90    Print a string to the STDOUT with a trailing new line character
    91  * [`set`](../commands/set.md):
    92    Define a local variable and set it's value
    93  * [`string` (stringing)](../types/str.md):
    94    string (primitive)
    95  * [`tout`](../commands/tout.md):
    96    Print a string to the STDOUT and set it's data-type
    97  
    98  <hr/>
    99  
   100  This document was generated from [gen/parser/codeblock_doc.yaml](https://github.com/lmorg/murex/blob/master/gen/parser/codeblock_doc.yaml).