### Deprecated bnfgrammar Environment Example Source: https://github.com/zeta611/simplebnf/blob/master/simplebnf-doc.tex An example demonstrating the usage of the deprecated bnfgrammar environment for typesetting grammars. This environment is replaced by the 'bnf' environment in newer versions. ```latex \begin{bnfgrammar} a : Variables \in \textit{Vars} || expr : Expressions ::= expr + term | term || term ::= term * a || a \end{bnfgrammar} ``` -------------------------------- ### Customizing BNF Grammar Layout Source: https://github.com/zeta611/simplebnf/blob/master/simplebnf-doc.tex Demonstrates advanced layout customization for a BNF grammar. This example shows how to set production delimiters, row separators, and detailed column specifications using options passed to the tabularray package. ```latex \begin{center} \begin{bnf}( prod-delim = {--}, or-sym = {}, prod-sep = 5pt, )[ colspec = {|[2pt, gray5]llcll}, column{1} = {font = \sffamily}, column{2} = {mode = dmath}, column{4} = {font = \ttfamily}, column{5} = {font = \itshape}, cell{9}{4} = {cmd = \fbox}, row{-} = {bg = azure9}, ] \tau : Type ::= | num : numbers | str : strings -- e : Expr ::= | $x$ : variable | $n$ : numeral | $e$ + $e$ : add | $e$ * $e$ : mult | $e$ \textasciicircum{} $e$ : concat | len($e$) : length | let $x$ = $e_1$ in $e_2$ : definition \end{bnf} \end{center} ``` -------------------------------- ### Line-break Delimiter Example Source: https://github.com/zeta611/simplebnf/blob/master/simplebnf-doc.tex Demonstrates the use of the line-break delimiter (\\) to force manual line breaks within a single alternative. This aligns continuation under the RHS column without repeating symbols. ```latex \begin{center} \begin{bnf} $e$ : Expr ::= | verylongtoken verylongtoken verylongtoken verylongtoken \\ continued tokens still part of the same alternative : long form \end{bnf} \end{center} ``` -------------------------------- ### Basic BNF Environment Usage Source: https://github.com/zeta611/simplebnf/blob/master/simplebnf-doc.tex Demonstrates the fundamental usage of the \begin{bnf} environment to typeset a BNF grammar. No specific column customization is applied here. ```latex \begin{center} \begin{bnf} \tau : \textsf{Type} ::= | \texttt{num} : numbers | \texttt{str} : strings ;; $e$ : \textsf{Expr} ::= | $x$ : variable | $n$ : numeral | \texttt{$e$ + $e$} : addition | \texttt{$e$ * $e$} : multiplication | \texttt{$e$ \textasciicircum{} $e$} : concatenation | \texttt{len($e$)} : length | \texttt{let $x$ = $e_1$ in $e_2$} : definition \end{bnf} \end{center} ``` -------------------------------- ### Setting Global BNF Layout with \SetBNFLayout Source: https://github.com/zeta611/simplebnf/blob/master/simplebnf-doc.tex Illustrates how to define a default configuration for all subsequent \begin{bnf} environments using the \SetBNFLayout command. This is useful for applying consistent styling across multiple grammars. ```latex % Some where above... \SetBNFLayout{ colspec = {llcll}, column{1} = {font = \sffamily}, column{2} = {mode = dmath}, column{4} = {font = \ttfamily}, } % ... \begin{bnf} \tau : Type ::= | num : numbers | str : strings ;; e : Expr ::= | $x$ : variable | $n$ : numeral | $e$ + $e$ : addition | $e$ * $e$ : multiplication | $e$ \textasciicircum{} $e$ : concatenation | len($e$) : length | let $x$ = $e_1$ in $e_2$ : definition \end{bnf} ``` -------------------------------- ### Customizing BNF Columns with Environment Options Source: https://github.com/zeta611/simplebnf/blob/master/simplebnf-doc.tex Shows how to customize font styles and modes for individual columns within a BNF grammar using options passed directly to the \begin{bnf} environment. This includes setting column specifications and specific column properties. ```latex \begin{bnf}[ colspec = {llcll}, column{1} = {font = \sffamily}, column{2} = {mode = dmath}, column{4} = {font = \ttfamily}, ] \tau : Type ::= | num : numbers | str : strings ;; e : Expr ::= | $x$ : variable | $n$ : numeral | $e$ + $e$ : addition | $e$ * $e$ : multiplication | $e$ \textasciicircum{} $e$ : concatenation | len($e$) : length | let $x$ = $e_1$ in $e_2$ : definition \end{bnf} ``` -------------------------------- ### Or-sym with Ensuremath Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Shows an empty or-sym configuration, implying default behavior or that \ensuremath is used implicitly. This tests the library's handling of minimal configurations. ```bnf $d$ : Decl ::= `val` // `fun` // `type` ``` -------------------------------- ### Globally Set SimpleBNF Configuration Source: https://github.com/zeta611/simplebnf/blob/master/simplebnf-doc.tex Configure SimpleBNF globally using \texttt{SetBNFConfig} before the \texttt{bnf} environment. This applies the specified delimiters and symbols to all subsequent grammars. ```latex % Some where above... \SetBNFConfig{ prod-delim = {--}, new-line-delim = {&}, single-line-delim = {&&}, comment = {;}, relation-sym-map = { {->} = {\ensuremath{\hookrightarrow}}, {:in:} = {\ensuremath{\in}}, }, or-sym = {} } % ... \begin{bnf}[ colspec = {llcll}, column{1} = {font = \sffamily}, column{2} = {mode = dmath}, column{4} = {font = \ttfamily}, ] \tau ; Type -> & num ; numbers & str ; strings -- e ; Expr -> & $x$ ; variable & $n$ ; numeral & $e$ + $e$ ; addition & $e$ * $e$ ; multiplication & $e$ \textasciicircum{} $e$ ; concatenation & len($e$) ; length & let $x$ = $e_1$ in $e_2$ ; definition \end{bnf} ``` -------------------------------- ### Single Alternative (No //) Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Demonstrates a grammar rule with only a single alternative, meaning no or-sym separator is needed. This tests the parser's handling of minimal productions. ```bnf $e$ : Expr ::= $\lambda x.e$ : lambda abstraction ``` -------------------------------- ### Many Single-line Alternatives Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Shows a rule with numerous single-line alternatives separated by backslash or-sym ('\;|\;'). This tests the library's performance and correctness with a high number of options. ```bnf $e$ : Expr ::= | $a$ // $b$ // $c$ // $d$ // $e$ // $f$ : lots of forms ``` -------------------------------- ### Customize SimpleBNF Grammar Configuration Source: https://github.com/zeta611/simplebnf/blob/master/simplebnf-doc.tex Use this syntax to customize delimiters and symbols for grammar typesetting within the \texttt{bnf} environment. The layout options are applied after the configuration options. ```latex \begin{center} \begin{bnf}( prod-delim = {--}, new-line-delim = {&}, single-line-delim = {&&}, comment = {;}, relation-sym-map = { {->} = {\ensuremath{\hookrightarrow}}, {:in:} = {\ensuremath{\in}}, }, or-sym = {} )[ colspec = {llcll}, column{1} = {font = \sffamily}, column{2} = {mode = dmath}, column{4} = {font = \ttfamily}, ] \tau ; Type -> & num ; numbers & str ; strings -- e ; Expr -> & $x$ ; variable & $n$ ; numeral & $e$ + $e$ ; addition & $e$ * $e$ ; multiplication & $e$ \textasciicircum{} $e$ ; concatenation & len($e$) ; length & let $x$ = $e_1$ in $e_2$ ; definition \end{bnf} \end{center} ``` -------------------------------- ### Multiple Relations (::=, ->, :in:) Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Shows the use of different relation symbols (::=, ->, :in:) within the same grammar file. This tests the library's support for varied rule definitions. ```bnf $\tau$ : Type ::= | `num` | `str` ;; ``` ```bnf $e$ : Expr ::= | $x$ | $\lambda x.e$ ;; ``` ```bnf $\Gamma$ : Context :in: ($x$ : $\tau$) list ``` -------------------------------- ### Or-sym with Negative Thin Space (! | !) Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Uses a negative thin space ('!|!') as the or-sym separator. This demonstrates fine control over spacing, potentially for tighter layouts. ```bnf $e$ ::= $x$ // $n$ // $e + e$ ``` -------------------------------- ### Full-line Comments with bnfcomment Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Demonstrates the use of full-line comments, indicated by '//', within grammar definitions. This allows for explanatory notes alongside rules. ```bnf Types $\tau$ : Type ::= `num` // `str` ;; ``` ```bnf Expressions $e$ : Expr ::= $x$ // $n$ // $e$ + $e$ ``` -------------------------------- ### Multiple Productions with Backslash Or-sym Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Tests the backslash or-sym ('\;|\;') with multiple alternative productions for a single rule. This ensures correct parsing of complex alternatives. ```bnf $\tau$ : Type ::= | `num` | `str` ;; ``` ```bnf $e$ : Expr ::= | $x$ // $\lambda x.e$ // $e\;e$ ``` -------------------------------- ### Or-sym with Mid (|) Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Illustrates using a plain vertical bar '|' as the or-sym separator. This is a common and concise way to define alternatives. ```bnf $e$ : Expr ::= $x$ // $n$ // $e + e$ ``` -------------------------------- ### Adding Full-Line Comments in BNF Source: https://github.com/zeta611/simplebnf/blob/master/simplebnf-doc.tex Illustrates how to insert full-line comments within a BNF grammar using the \bnfcomment command. This helps in organizing and annotating grammar rules. ```latex \begin{center} \begin{bnf} \bnfcomment{Types} $\tau$ : Type ::= \texttt{num} // \texttt{str} ;; \bnfcomment{Expressions} $e$ : Expr ::= $x$ // $n$ // $e$ + $e$ \end{bnf} \end{center} ``` -------------------------------- ### Custom Single-line Delimiter with Backslash Or-sym Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Demonstrates a custom single-line delimiter ('&&') combined with a backslash-escaped or-sym ('\;|\;'). This highlights the flexibility in defining grammar syntax. ```bnf ( single-line-delim = &&, or-sym = $\;|\;$, ) $e$ : Expr ::= $x$ && $n$ && $e + e$ : expressions ``` -------------------------------- ### Mixed New-line and Single-line Delimiters Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Combines new-line delimiters for some alternatives and single-line delimiters ('//') for others within the same rule. This showcases flexible grammar definition styles. ```bnf $e$ : Expr ::= | $x$ : variable | $n$ // $m$ : numerals | $e + e$ // $e - e$ : arithmetic | $\lambda x.e$ : abstraction ``` -------------------------------- ### Or-sym with Hspace Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Configures the or-sym separator with horizontal spacing using \hspace. This allows for fine-grained visual control over the layout of alternatives. ```bnf $p$ : Pat ::= $x$ // $\_$ // $(p, p)$ ``` -------------------------------- ### Temporary Buffer Manipulation for Comments Source: https://github.com/zeta611/simplebnf/blob/master/src/engine/comment-rows.tex Demonstrates setting, replacing, and appending to a temporary buffer (`_tmpb_tl`) during comment row processing. It uses `_set`, `_replace_once`, and `_after` operations. ```bnf _set:Nn _tmpb_tl #1 _replace_once:Nnn _tmpb_tl _replace_once:nnN + _tmpb_tl _after:wN __simplebnf_emit_comment_row:nw _tmpb_tl _stop ``` -------------------------------- ### Or-sym with Vert (|) Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Demonstrates using a vertical bar '|' (vert) as the or-sym separator. Similar to the plain mid, it clearly separates alternatives. ```bnf $v$ : Value ::= $n$ // $\lambda x.e$ ``` -------------------------------- ### Define OR Symbol Source: https://github.com/zeta611/simplebnf/blob/master/src/config/keys.tex Sets the delimiter for the OR symbol in SimpleBNF. ```simplebnf or-sym .tl_set:N = __simplebnf_or_sym_tl ``` -------------------------------- ### Or-sym with Purely Backslash Commands (|) Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Shows the use of a plain pipe '|' as the or-sym, emphasizing that it can be defined using backslash commands even if it looks like a standard character. ```bnf $t$ : Term ::= $x$ // $\lambda x.t$ // $t\;t$ ``` -------------------------------- ### Or-sym with Thin Space (, | ,) Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Shows the use of a comma with thin space (\,|\,) as the or-sym separator. This provides subtle visual spacing between alternatives. ```bnf $k$ : Kind ::= $\star$ // $k \to k$ ``` -------------------------------- ### Or-sym with Backslash Command Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Demonstrates using a backslash command for the or-sym separator in grammar rules. This is useful for specific formatting or control characters. ```bnf $e$ : Expr ::= | $x$ // $\lambda x.e$ ``` -------------------------------- ### Table Top-Left Handling Source: https://github.com/zeta611/simplebnf/blob/master/src/engine/comment-rows.tex Handles the top-left portion of a table (`__simplebnf_table_tl`), including conditional logic for blank rows and production separators. ```bnf _put_right:Nn __simplebnf_table_tl l #1 &&&& _if_blank:nF #2 ``` -------------------------------- ### Define New Production Rule Source: https://github.com/zeta611/simplebnf/blob/master/src/deprecated/typeset-production.tex Defines a new production rule with a given name and associated grammar. ```bnf _new:Nn @dep__simplebnf_typeset_production:n _split:nnNTF ::= #1 __simplebnf_lhs_rhs_pair_seq _pop_left:NN __simplebnf_lhs_rhs_pair_seq __simplebnf_lhs_tl _pop_left:NN __simplebnf_lhs_rhs_pair_seq __simplebnf_rhs_tl @dep__simplebnf_typeset_lhs:n__simplebnf_lhs_tl _put_right:Nn __simplebnf_table_tl & & ``` -------------------------------- ### Or-sym with Plain Math Pipe (|) Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Uses the default plain math pipe symbol '|' as the or-sym separator. This is the standard behavior when no specific separator is defined. ```bnf $s$ : Stmt ::= $x$ // $n$ // $e + e$ ``` -------------------------------- ### Default Or-sym with Single-line Delimiters Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Illustrates using default or-sym separators within a grammar that uses single-line delimiters (;;). This combines different syntax elements. ```bnf $\tau$ : Type ::= | `num` // `str` ;; ``` ```bnf $e$ : Expr ::= $x$ // $n$ // $e + e$ ``` -------------------------------- ### Line-break Delimiter Inside Alternative Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Illustrates how long tokens within an alternative are handled when line breaks are used as delimiters. This tests the parser's ability to manage long productions. ```bnf $e$ : Expr ::= | verylongtoken verylongtoken verylongtoken verylongtoken continued tokens still part of the same alternative : long form ``` -------------------------------- ### Define Production Delimiter Source: https://github.com/zeta611/simplebnf/blob/master/src/config/keys.tex Sets the delimiter for production rules in SimpleBNF. ```simplebnf prod-delim .tl_set:N = __simplebnf_prod_delim_tl ``` -------------------------------- ### Handle Comment Production Source: https://github.com/zeta611/simplebnf/blob/master/src/engine/comment-rows.tex Defines the `__simplebnf_handle_comment_production` function, likely used to process comment productions within the parsing context. ```bnf _new:Nn __simplebnf_handle_comment_production:n ``` -------------------------------- ### Configure Unicode Math Font for Coloneqq Symbol Source: https://github.com/zeta611/simplebnf/blob/master/simplebnf-doc.tex Sets the Garamond-Math font for the \Coloneqq symbol when using the unicode-math package. Ensure the font provides the required symbol. ```latex \setmathfont{Garamond-Math.otf}[ Scale = MatchUppercase, range = {\Coloneq} ] ``` -------------------------------- ### Or-sym with Quad Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Shows the use of a quad (four spaces) as the or-sym separator. This provides visual separation in grammar definitions. ```bnf $\tau$ : Type ::= | `int` // `bool` // `string` ``` -------------------------------- ### Define Comment Delimiter Source: https://github.com/zeta611/simplebnf/blob/master/src/config/keys.tex Sets the delimiter for comments in SimpleBNF. ```simplebnf comment .tl_set:N = __simplebnf_comment_tl ``` -------------------------------- ### Table Production Separator Logic Source: https://github.com/zeta611/simplebnf/blob/master/src/engine/comment-rows.tex Manages table production separators, checking if a row is within a specific context and handling comment or typeset productions accordingly. ```bnf _put_right:Nn __simplebnf_table_tl [__simplebnf_prod_sep_dim] _if_in:nnTF #2 __simplebnf_handle_comment_production:n #2 __simplebnf_typeset_production:n #2 ``` -------------------------------- ### Define Production Separator Source: https://github.com/zeta611/simplebnf/blob/master/src/config/keys.tex Sets the dimension for production separators in SimpleBNF. ```simplebnf prod-sep .dim_set:N = __simplebnf_prod_sep_dim ``` -------------------------------- ### Define Single-line Delimiter Source: https://github.com/zeta611/simplebnf/blob/master/src/config/keys.tex Sets the delimiter for single lines in SimpleBNF. ```simplebnf single-line-delim .tl_set:N = __simplebnf_single_line_delim_tl ``` -------------------------------- ### Define Production Rule with Left-Hand Side and Right-Hand Side Pair Sequence Source: https://github.com/zeta611/simplebnf/blob/master/src/deprecated/typeset-production.tex Defines a production rule that splits into a sequence of left-hand and right-hand side pairs. ```bnf _split:nnNTF in #1 __simplebnf_lhs_rhs_pair_seq _pop_left:NN __simplebnf_lhs_rhs_pair_seq __simplebnf_lhs_tl _pop_left:NN __simplebnf_lhs_rhs_pair_seq __simplebnf_rhs_tl @dep__simplebnf_typeset_lhs:n__simplebnf_lhs_tl _put_right:Nn __simplebnf_table_tl & $\in$ & ``` -------------------------------- ### Define Line-break Delimiter Source: https://github.com/zeta611/simplebnf/blob/master/src/config/keys.tex Sets the delimiter for line breaks in SimpleBNF. ```simplebnf line-break-delim .tl_set:N = __simplebnf_line_break_delim_tl ``` -------------------------------- ### SimpleBNF Metagrammar Definition Source: https://github.com/zeta611/simplebnf/blob/master/simplebnf-doc.tex This LaTeX code defines the metagrammar for the simplebnf DSL, including production rules, delimiters, and comments. It is used for typesetting the grammar. ```latex \def\colonincolon{:in:} \def\doubleslash{//} \def\doublebslash{\char`\\char`\\} \def\metabnfcomment{\char`\\bnfcomment} \begin{bnf}( prod-delim = ;;;, new-line-delim = !, single-line-delim = ?, comment = //, relation = {:::=|:in:}, relation-sym-map = { {:::=} = $\Coloneqq$, {:in:} = $\in$, }, )[ colspec = lrcll, column{2} = {mode=dmath}, column{4} = {mode=text, font=\ttfamily}, ] G // Grammar :::= ! $P$ // production ! $P$ \fatsemi {} ! $P$ \fatsemi G // production sequence ! \texttt{\metabnfcomment\char`{$c$\char`}} // full-line comment ! \texttt{\metabnfcomment\char`{$c$\char`}\, $P$} // commented production ;;; P // Production :::= $L \rightarrowtriangle R$ ;;; L // LHS :::= ! $v$ // metavariable ! $v!\fatslash\,c$ // commented metavariable ;;; R // RHS :::= ! $A$ // alternative ! $A$ \talloblong R // alternative sequence ;;; A // Alternative :::= ! $f$ // syntactic form ! $f\fatbslash A$ // line-broken syntactic form ! $f!\fatslash\,c$ // commented syntactic form ;;; \fatsemi // Prod. delimiter :::= ! ;; // default symbol ! $\cdots$ // user-defined ;;; \rightarrowtriangle // Rule relation :::= ! ::= // $\Coloneqq$ ! -> // $\to$ ! \colonincolon // $\in$ ! $\cdots$ // user-defined ;;; \fatslash // Annot. symbol :::= ! : // default symbol ! $\cdots$ // user-defined ;;; \talloblong // Alt. delimiter :::= ! | // new-line delimiter ! \doubleslash // single-line delimiter ! $\cdots$ // user-defined ;;; \fatbslash // Line-break delim :::= ! \doublebslash // default symbol ! $\cdots$ // user-defined ;;; v, f, c :in: \textsf{\TeX{} tl} // valid \TeX{} token lists ;;; \end{bnf} ``` -------------------------------- ### Process Alternative Sequence with Newline Delimiter Source: https://github.com/zeta611/simplebnf/blob/master/src/deprecated/typeset-production.tex Splits an alternative sequence using a newline delimiter and processes the right-hand side. ```bnf _split:NVN __simplebnf_new_line_delim_regex __simplebnf_rhs_tl __simplebnf_alternative_seq _set_true:N __simplebnf_first_alternative_bool _map_function:NN __simplebnf_alternative_seq @dep__simplebnf_typeset_rhs:n ``` -------------------------------- ### Define Relation Symbol Map Source: https://github.com/zeta611/simplebnf/blob/master/src/config/keys.tex Maps relation symbols using a key-value set in SimpleBNF. ```simplebnf relation-sym-map .code:n = _set_from_keyval:Nn __simplebnf_relation_sym_map_prop #1 ``` -------------------------------- ### Emit Comment Row Function Source: https://github.com/zeta611/simplebnf/blob/master/src/engine/comment-rows.tex Defines the `__simplebnf_emit_comment_row` function, which is responsible for emitting comment rows. It takes two arguments, likely representing row identifiers or states. ```bnf _new:Npn __simplebnf_emit_comment_row:nw #1 #2 _stop ``` -------------------------------- ### Define Newline Delimiter Source: https://github.com/zeta611/simplebnf/blob/master/src/config/keys.tex Sets the delimiter for newlines in SimpleBNF. ```simplebnf new-line-delim .tl_set:N = __simplebnf_new_line_delim_tl ``` -------------------------------- ### Handle Parse Errors Source: https://github.com/zeta611/simplebnf/blob/master/src/deprecated/typeset-production.tex Defines a rule to handle and report parse errors. ```bnf _error:nnn simplebnf parse-error #1 ``` -------------------------------- ### Define Row Separator Source: https://github.com/zeta611/simplebnf/blob/master/src/config/keys.tex Sets the dimension for row separators in SimpleBNF. ```simplebnf row-sep .dim_set:N = __simplebnf_row_sep_dim ``` -------------------------------- ### Define Relation Delimiter Source: https://github.com/zeta611/simplebnf/blob/master/src/config/keys.tex Sets the delimiter for relations in SimpleBNF. ```simplebnf relation .tl_set:N = __simplebnf_relation_tl ``` -------------------------------- ### BNF Metagrammar Definition Source: https://github.com/zeta611/simplebnf/blob/master/simplebnf-doc.tex This snippet defines the metagrammar of the DSL used for typesetting grammars in BNF. It specifies delimiters, relations, and the structure of grammar rules. ```BNF // ` ` bnfcomment ( prod-delim = ;;;, new-line-delim = !, single-line-delim = ?, comment = //, relation = :::=|:in:, relation-sym-map = :::= = $\Coloneqq$, :in: = $\in$, , )[ colspec = lrcll, column2 = mode=dmath, column4 = mode=text, font=, ] G // Grammar :::= ! $P$ // production ! $P \fatsemi {}$ // production w/ a trailing delimiter ! $P \fatsemi G$ // production sequence ! ``$c$`` // full-line comment ! ``$c$`$P$` // commented production ;;; P // Production :::= $L \rightarrowtriangle R$ ;;; L // LHS :::= ! $v$ // metavariable ! $v!\fatslash\,c$ // commented metavariable ;;; R // RHS :::= ! $A$ // alternative ! $A \talloblong R$ // alternative sequence ;;; A // Alternative :::= ! $f$ // syntactic form ! $f\fatbslash A$ // line-broken syntactic form ! $f!\fatslash\,c$ // commented syntactic form ;;; // Prod. delimiter :::= ! ;; // default symbol ! $\cdots$ // user-defined ;;; // Rule relation :::= ! ::= // $\Coloneqq$ ! -> // $\to$ ! // $\in$ ! $\cdots$ // user-defined ;;; // Annot. symbol :::= ! : // default symbol ! $\cdots$ // user-defined ;;; // Alt. delimiter :::= ! | // new-line delimiter ! // single-line delimiter ! $\cdots$ // user-defined ;;; // Line-break delim :::= ! // default symbol ! $\cdots$ // user-defined ;;; v, f, c :in: ** tl** // valid token lists ;;; ``` -------------------------------- ### Commented LHS Source: https://github.com/zeta611/simplebnf/blob/master/test/regression-tests.tex Tests grammar definitions where the Left-Hand Side (LHS) of a rule is commented out. This ensures that commented-out rules are ignored during parsing. ```bnf $x$ : Variable ::= $a$ // $b$ // $c$ ;; ``` ```bnf $n$ : Number ::= $0$ // $1$ // $\ldots$ ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.