<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">% here's the example
\input generic.tex
\input bnf.tex

\begingrammar
%		
&lt;input&gt;:	{$\phi$};
		&lt;statement&gt;.\par

&lt;statement&gt;:	"$\{$" &lt;compound&gt; "$\}$" [";"] ;
		&lt;single&gt; [";"] ;
		";".

&lt;compound&gt;:	&lt;single&gt; ";" &lt;compound&gt; ;
		&lt;single&gt;.

&lt;single&gt;:	"if" "(" &lt;expression&gt; ")" &lt;statement&gt; ["else" &lt;statement&gt;];
		"case" "$\{$" &lt;case-body&gt; "$\}$";
		"for" "(" &lt;expression&gt; ";" &lt;expression&gt; ";" &lt;expression&gt; ")",
			&lt;statement&gt;;
		"while" "(" &lt;expression&gt; ")" &lt;statement&gt;;
		"do" &lt;expression&gt; "while" "(" &lt;expression&gt; ")";
		"sum" "(" &lt;expression&gt; ";" &lt;expression&gt; ")" &lt;statment&gt;;
		"product" "(" &lt;expression&gt; ";" &lt;expression&gt; ")" &lt;statment&gt;;
		"break";
		"continue";
		"return" &lt;expression&gt;;
		"clear";
		"load" &lt;expression&gt;;
		"save" &lt;expression&gt;;
		"release" &lt;expression&gt;;
		"show" ["variables" | "functions" | "set" | "all" | &lt;expression&gt;];
		"set"  ["prompt" | "precision"] [&lt;expression&gt;];
		&lt;equation&gt;.

&lt;case-body&gt;:	"case" &lt;expression&gt; ":" &lt;compound&gt; &lt;case-body&gt;;
		 "default:" &lt;compound&gt;

&lt;equation&gt;:	&lt;var&gt; "=" &lt;expression&gt;;
		&lt;var&gt;"[" &lt;selector&gt; "]" = &lt;expression&gt;;
		&lt;function&gt; = &lt;input&gt;;
		&lt;expression&gt;.

&lt;selector&gt;:	&lt;factor&gt; "," &lt;factor&gt;;
		&lt;factor&gt; ",";
		"," &lt;factor&gt;.

&lt;expression&gt;:	&lt;term&gt; "+" &lt;expression&gt;;
		&lt;term&gt; "--" &lt;expression&gt;.		

&lt;term&gt;:		&lt;factor&gt; &lt;operator&gt; &lt;term&gt;.

&lt;factor&gt;	&lt;pre-op&gt; &lt;factor$'$&gt; &lt;post-op&gt;.

&lt;factor$'$&gt;:	&lt;number&gt;;
		"+" &lt;number&gt;;
		"--" &lt;number&gt;;
		"(" &lt;number&gt; ")";
		&lt;variable&gt;;
		&lt;variable&gt;"[" &lt;selector&gt; "]";
		&lt;string&gt;;
		&lt;matrix&gt;;
		&lt;function&gt;.

&lt;pre-op&gt;:	"++" | "--{\kern 1pt}--" | "$\sim$" | "!".

&lt;post-op&gt;:	"$\uparrow$" &lt;factor&gt; 
		| "**" &lt;factor&gt;;
		"++" | "--{\kern 1pt}--" | "!".		

&lt;matrix&gt;:	"[" &lt;row-list&gt; "]".

&lt;row-list&gt;:	"[" &lt;value-list&gt; "]" [","] &lt;row-list&gt;;
		"[" &lt;value-list&gt; "]" [","] &lt;row-list&gt;;
		&lt;value-list&gt;.

&lt;value-list&gt;:	[ &lt;string&gt; ] &lt;expression&gt; "," &lt;value-list&gt;;
		[ &lt;string&gt; ] &lt;expression&gt;.

&lt;function&gt;:	&lt;variable&gt; "(" &lt;arg-list&gt; ")".

&lt;arg-list&gt;:	$\phi$;
		&lt;variable&gt; "," &lt;arglist&gt;;
		"\dots".

&lt;string&gt;:	" `` "  &lt;anything&gt; " '' ".

&lt;number&gt;:	&lt;real-number&gt;;
		"$\{$" &lt;real-number&gt; "," &lt;real-number&gt; "$\}$";
		{$\backslash$}b[01][01]+;
		{$\backslash$}o[07][07]+;
		\$[0-9A-Fa-f][0-9A-Fa-f]+.

%&lt;real-number&gt;:	[\+--]?[0-9][0-9]+[\.[0-9]+]?[[eE][0-9][0-9]+].

&lt;operator&gt;:	"*" |	 "/"	|     "$\backslash$"	| "\%";
		"==" |	 "!="	|     "$&gt;$" 		| "$&lt;$"  
		| "$&lt;$=" | "$&gt;$=";
		"\ul ="	| "\ul !=" |  "\ul $&lt;$" | "\ul $&gt;$" 
		| "\ul$&lt;$=" | "\ul$&gt;$=";
		"\&amp;"	 | "$\vert$"  | "$\uparrow\uparrow$";
		"\&amp;\&amp;"	| "$\Vert$"  | "\ul$\uparrow$".
		
\endgrammar
\bye

</pre></body></html>