diff options
Diffstat (limited to 'src/ops/latex.cc')
| -rw-r--r-- | src/ops/latex.cc | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/src/ops/latex.cc b/src/ops/latex.cc new file mode 100644 index 0000000..01ccfc0 --- /dev/null +++ b/src/ops/latex.cc | |||
| @@ -0,0 +1,101 @@ | |||
| 1 | /************************************************************************* | ||
| 2 | * | ||
| 3 | * HTCd - Copyright (C) 1998-2006 Henrik Rydberg | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2 of the License, or | ||
| 8 | * (at your option) any later version. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this program; if not, write to the Free Software | ||
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 18 | */ | ||
| 19 | |||
| 20 | #include <ops/express.h> | ||
| 21 | #include <math.h> | ||
| 22 | |||
| 23 | OP1_IMPL(minus) {out<<"-"<<a;} | ||
| 24 | OP1_IMPL(plus) {out<<"+"<<a;} | ||
| 25 | OP1_IMPL(plusminus) {out<<"\\pm"<<a;} | ||
| 26 | OP1_IMPL(minusplus) {out<<"\\mp"<<a;} | ||
| 27 | |||
| 28 | OP2_IMPL(minus) {out<<L<<"-"<<R;} | ||
| 29 | OP2_IMPL(plus) {out<<L<<"+"<<R;} | ||
| 30 | OP2_IMPL(plusminus) {out<<L<<"\\pm"<<R;} | ||
| 31 | OP2_IMPL(minusplus) {out<<L<<"\\mp"<<R;} | ||
| 32 | |||
| 33 | OP2_IMPL(mul) {out<<L<<"\times"<<R;} | ||
| 34 | OP2_IMPL(divide) {out<<L<<"/"<<R;} | ||
| 35 | OP2_IMPL(pow) {out<<L<<"<sup><font size=-1>"<<R<<"</font></sup>";} | ||
| 36 | OP1_IMPL(pow) {out<<"<sup><font size=-1>"<<a<<"</font></sup>";} | ||
| 37 | OP2_IMPL(sub) {out<<L<<"<sub><font size=-1>"<<R<<"</font></sub>";} | ||
| 38 | OP1_IMPL(sub) {out<<"<sub><font size=-1>"<<a<<"</font></sub>";} | ||
| 39 | OP2_IMPL(div) {out<<L<<"\\div"<<R;} | ||
| 40 | |||
| 41 | OP2_IMPL(lt) {out<<L<<"<"<<R;} | ||
| 42 | OP2_IMPL(le) {out<<L<<"\\leq"<<R;} | ||
| 43 | OP2_IMPL(eq) {out<<L<<"="<<R;} | ||
| 44 | OP2_IMPL(ne) {out<<L<<"\\neq"<<R;} | ||
| 45 | OP2_IMPL(ge) {out<<L<<"\\geq"<<R;} | ||
| 46 | OP2_IMPL(gt) {out<<L<<">"<<R;} | ||
| 47 | |||
| 48 | OP2_IMPL(equiv) {out<<L<<"\\equiv"<<R;} | ||
| 49 | OP2_IMPL(sim) {out<<L<<"\\sim"<<R;} | ||
| 50 | OP2_IMPL(simeq) {out<<L<<"\\simeq"<<R;} | ||
| 51 | |||
| 52 | OP1_IMPL(not) {out<<"!"<<a;} | ||
| 53 | OP2_IMPL(and) {out<<L<<" and "<<R;} | ||
| 54 | OP2_IMPL(or) {out<<L<<" or "<<R;} | ||
| 55 | OP2_IMPL(xor) {out<<L<<" xor "<<R;} | ||
| 56 | |||
| 57 | OP2_IMPL(assign) {out<<L<<" = "<<R;} | ||
| 58 | |||
| 59 | OP2_IMPL(SP) {out<<L<<" "<<R;} | ||
| 60 | |||
| 61 | OP1_IMPL(semi) {out<<a;} | ||
| 62 | OP2_IMPL(semi) {out<<L<<R;} | ||
| 63 | |||
| 64 | void opAddLatex(opmap& M) | ||
| 65 | { | ||
| 66 | OP_ADD(30,not,"logic not"); | ||
| 67 | |||
| 68 | OP_ADD2(30,28,sub,_,"sub index"); | ||
| 69 | OP_ADD2(30,27,pow,^,"raised index"); | ||
| 70 | |||
| 71 | OP_ADD2(30,24,plus,+,"plus"); | ||
| 72 | OP_ADD2(30,24,minus,-,"minus"); | ||
| 73 | OP_ADD2(30,24,plusminus,+-,"plusminus"); | ||
| 74 | OP_ADD2(30,24,minusplus,-+,"minusplus"); | ||
| 75 | |||
| 76 | OP_ADDN(26,mul,*,"multiply"); | ||
| 77 | OP_ADDN(25,divide,/,"divide"); | ||
| 78 | OP_ADD(25,div,"divide-sign"); | ||
| 79 | // plus/minus 24 | ||
| 80 | |||
| 81 | OP_ADDN(20,lt,<,"less than"); | ||
| 82 | OP_ADDN(20,le,<=,"less or equal"); | ||
| 83 | OP_ADDN(20,ge,>=,"greater or equal"); | ||
| 84 | OP_ADDN(20,gt,>,"greater than"); | ||
| 85 | |||
| 86 | OP_ADDN(18,eq,==,"equal"); | ||
| 87 | OP_ADDN(18,ne,!=,"not equal"); | ||
| 88 | OP_ADDN(18,equiv,===,"equivalent"); | ||
| 89 | OP_ADDN(18,sim,~,"similar"); | ||
| 90 | OP_ADDN(18,simeq,~=,"similar equal"); | ||
| 91 | |||
| 92 | OP_ADD(10,and,"logic and"); | ||
| 93 | OP_ADD(9,xor,"logic xor"); | ||
| 94 | OP_ADD(8,or,"logic or"); | ||
| 95 | |||
| 96 | OP_ADDN(4,assign,=,"assignment"); | ||
| 97 | |||
| 98 | OP_ADD(3,SP,"Whitespace padding"); | ||
| 99 | |||
| 100 | OP_ADD2(1,1,semi,;,"concatenation"); | ||
| 101 | } | ||
