.B *
multiplication
.TP
-.B %
-non-commutative multiplication
-.TP
.B /
division
.TP
.PP
The command
.RS
+.BI print_latex( expression );
+.RE
+prints a LaTeX representation of the given
+.IR expression .
+.PP
+The command
+.RS
+.BI print_csrc( expression );
+.RE
+prints the given
+.I expression
+in a way that can be used in a C or C++ program (complex numbers are not
+supported, though).
+.PP
+The command
+.RS
.BI iprint( expression );
.RE
prints the given
warranty return T_WARRANTY;
print return T_PRINT;
iprint return T_IPRINT;
+print_latex return T_PRINTLATEX;
+print_csrc return T_PRINTCSRC;
time return T_TIME;
xyzzy return T_XYZZY;
inventory return T_INVENTORY;
%token T_NUMBER T_SYMBOL T_LITERAL T_DIGITS T_QUOTE T_QUOTE2 T_QUOTE3
%token T_EQUAL T_NOTEQ T_LESSEQ T_GREATEREQ
-%token T_QUIT T_WARRANTY T_PRINT T_IPRINT T_TIME T_XYZZY T_INVENTORY T_LOOK T_SCORE
+%token T_QUIT T_WARRANTY T_PRINT T_IPRINT T_PRINTLATEX T_PRINTCSRC T_TIME
+%token T_XYZZY T_INVENTORY T_LOOK T_SCORE
/* Operator precedence and associativity */
%right '='
%left T_EQUAL T_NOTEQ
%left '<' '>' T_LESSEQ T_GREATEREQ
%left '+' '-'
-%left '*' '/' '%'
+%left '*' '/'
%nonassoc NEG
%right '^'
%nonassoc '!'
YYERROR;
}
}
+ | T_PRINTLATEX '(' exp ')' ';' {
+ try {
+ $3.print(print_latex(std::cout)); cout << endl;
+ } catch (exception &e) {
+ std::cerr << e.what() << endl;
+ YYERROR;
+ }
+ }
+ | T_PRINTCSRC '(' exp ')' ';' {
+ try {
+ $3.print(print_csrc_double(std::cout)); cout << endl;
+ } catch (exception &e) {
+ std::cerr << e.what() << endl;
+ YYERROR;
+ }
+ }
| '?' T_SYMBOL {print_help(ex_to<symbol>($2).get_name());}
| '?' T_TIME {print_help("time");}
| '?' '?' {print_help_topics();}