
sawine@55: % here's the example
sawine@55: \input generic.tex
sawine@55: \input bnf.tex
sawine@55: 
sawine@55: \begingrammar
sawine@55: %		
sawine@55: <input>:	{$\phi$};
sawine@55: 		<statement>.\par
sawine@55: 
sawine@55: <statement>:	"$\{$" <compound> "$\}$" [";"] ;
sawine@55: 		<single> [";"] ;
sawine@55: 		";".
sawine@55: 
sawine@55: <compound>:	<single> ";" <compound> ;
sawine@55: 		<single>.
sawine@55: 
sawine@55: <single>:	"if" "(" <expression> ")" <statement> ["else" <statement>];
sawine@55: 		"case" "$\{$" <case-body> "$\}$";
sawine@55: 		"for" "(" <expression> ";" <expression> ";" <expression> ")",
sawine@55: 			<statement>;
sawine@55: 		"while" "(" <expression> ")" <statement>;
sawine@55: 		"do" <expression> "while" "(" <expression> ")";
sawine@55: 		"sum" "(" <expression> ";" <expression> ")" <statment>;
sawine@55: 		"product" "(" <expression> ";" <expression> ")" <statment>;
sawine@55: 		"break";
sawine@55: 		"continue";
sawine@55: 		"return" <expression>;
sawine@55: 		"clear";
sawine@55: 		"load" <expression>;
sawine@55: 		"save" <expression>;
sawine@55: 		"release" <expression>;
sawine@55: 		"show" ["variables" | "functions" | "set" | "all" | <expression>];
sawine@55: 		"set"  ["prompt" | "precision"] [<expression>];
sawine@55: 		<equation>.
sawine@55: 
sawine@55: <case-body>:	"case" <expression> ":" <compound> <case-body>;
sawine@55: 		 "default:" <compound>
sawine@55: 
sawine@55: <equation>:	<var> "=" <expression>;
sawine@55: 		<var>"[" <selector> "]" = <expression>;
sawine@55: 		<function> = <input>;
sawine@55: 		<expression>.
sawine@55: 
sawine@55: <selector>:	<factor> "," <factor>;
sawine@55: 		<factor> ",";
sawine@55: 		"," <factor>.
sawine@55: 
sawine@55: <expression>:	<term> "+" <expression>;
sawine@55: 		<term> "--" <expression>.		
sawine@55: 
sawine@55: <term>:		<factor> <operator> <term>.
sawine@55: 
sawine@55: <factor>	<pre-op> <factor$'$> <post-op>.
sawine@55: 
sawine@55: <factor$'$>:	<number>;
sawine@55: 		"+" <number>;
sawine@55: 		"--" <number>;
sawine@55: 		"(" <number> ")";
sawine@55: 		<variable>;
sawine@55: 		<variable>"[" <selector> "]";
sawine@55: 		<string>;
sawine@55: 		<matrix>;
sawine@55: 		<function>.
sawine@55: 
sawine@55: <pre-op>:	"++" | "--{\kern 1pt}--" | "$\sim$" | "!".
sawine@55: 
sawine@55: <post-op>:	"$\uparrow$" <factor> 
sawine@55: 		| "**" <factor>;
sawine@55: 		"++" | "--{\kern 1pt}--" | "!".		
sawine@55: 
sawine@55: <matrix>:	"[" <row-list> "]".
sawine@55: 
sawine@55: <row-list>:	"[" <value-list> "]" [","] <row-list>;
sawine@55: 		"[" <value-list> "]" [","] <row-list>;
sawine@55: 		<value-list>.
sawine@55: 
sawine@55: <value-list>:	[ <string> ] <expression> "," <value-list>;
sawine@55: 		[ <string> ] <expression>.
sawine@55: 
sawine@55: <function>:	<variable> "(" <arg-list> ")".
sawine@55: 
sawine@55: <arg-list>:	$\phi$;
sawine@55: 		<variable> "," <arglist>;
sawine@55: 		"\dots".
sawine@55: 
sawine@55: <string>:	" `` "  <anything> " '' ".
sawine@55: 
sawine@55: <number>:	<real-number>;
sawine@55: 		"$\{$" <real-number> "," <real-number> "$\}$";
sawine@55: 		{$\backslash$}b[01][01]+;
sawine@55: 		{$\backslash$}o[07][07]+;
sawine@55: 		\$[0-9A-Fa-f][0-9A-Fa-f]+.
sawine@55: 
sawine@55: %<real-number>:	[\+--]?[0-9][0-9]+[\.[0-9]+]?[[eE][0-9][0-9]+].
sawine@55: 
sawine@55: <operator>:	"*" |	 "/"	|     "$\backslash$"	| "\%";
sawine@55: 		"==" |	 "!="	|     "$>$" 		| "$<$"  
sawine@55: 		| "$<$=" | "$>$=";
sawine@55: 		"\ul ="	| "\ul !=" |  "\ul $<$" | "\ul $>$" 
sawine@55: 		| "\ul$<$=" | "\ul$>$=";
sawine@55: 		"\&"	 | "$\vert$"  | "$\uparrow\uparrow$";
sawine@55: 		"\&\&"	| "$\Vert$"  | "\ul$\uparrow$".
sawine@55: 		
sawine@55: \endgrammar
sawine@55: \bye
sawine@55: 




