summaryrefslogtreecommitdiff
path: root/src/ops/latex.cc
blob: 01ccfc045b1bdb31b5a512977371d0e94b78a02f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*************************************************************************
 *
 * HTCd - Copyright (C) 1998-2006 Henrik Rydberg
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include <ops/express.h>
#include <math.h>

OP1_IMPL(minus) {out<<"-"<<a;}
OP1_IMPL(plus) {out<<"+"<<a;}
OP1_IMPL(plusminus) {out<<"\\pm"<<a;}
OP1_IMPL(minusplus) {out<<"\\mp"<<a;}

OP2_IMPL(minus) {out<<L<<"-"<<R;}
OP2_IMPL(plus) {out<<L<<"+"<<R;}
OP2_IMPL(plusminus) {out<<L<<"\\pm"<<R;}
OP2_IMPL(minusplus) {out<<L<<"\\mp"<<R;}

OP2_IMPL(mul) {out<<L<<"\times"<<R;}
OP2_IMPL(divide) {out<<L<<"/"<<R;}
OP2_IMPL(pow) {out<<L<<"<sup><font size=-1>"<<R<<"</font></sup>";}
OP1_IMPL(pow) {out<<"<sup><font size=-1>"<<a<<"</font></sup>";}
OP2_IMPL(sub) {out<<L<<"<sub><font size=-1>"<<R<<"</font></sub>";}
OP1_IMPL(sub) {out<<"<sub><font size=-1>"<<a<<"</font></sub>";}
OP2_IMPL(div) {out<<L<<"\\div"<<R;}

OP2_IMPL(lt) {out<<L<<"<"<<R;}
OP2_IMPL(le) {out<<L<<"\\leq"<<R;}
OP2_IMPL(eq) {out<<L<<"="<<R;}
OP2_IMPL(ne) {out<<L<<"\\neq"<<R;}
OP2_IMPL(ge) {out<<L<<"\\geq"<<R;}
OP2_IMPL(gt) {out<<L<<">"<<R;}

OP2_IMPL(equiv) {out<<L<<"\\equiv"<<R;}
OP2_IMPL(sim) {out<<L<<"\\sim"<<R;}
OP2_IMPL(simeq) {out<<L<<"\\simeq"<<R;}

OP1_IMPL(not) {out<<"!"<<a;}
OP2_IMPL(and) {out<<L<<" and "<<R;}
OP2_IMPL(or)  {out<<L<<" or "<<R;}
OP2_IMPL(xor) {out<<L<<" xor "<<R;}

OP2_IMPL(assign) {out<<L<<" = "<<R;}

OP2_IMPL(SP) {out<<L<<" "<<R;}

OP1_IMPL(semi) {out<<a;}
OP2_IMPL(semi) {out<<L<<R;}

void opAddLatex(opmap& M)
{
  OP_ADD(30,not,"logic not"); 

  OP_ADD2(30,28,sub,_,"sub index");
  OP_ADD2(30,27,pow,^,"raised index");

  OP_ADD2(30,24,plus,+,"plus");
  OP_ADD2(30,24,minus,-,"minus");
  OP_ADD2(30,24,plusminus,+-,"plusminus");
  OP_ADD2(30,24,minusplus,-+,"minusplus");

  OP_ADDN(26,mul,*,"multiply");
  OP_ADDN(25,divide,/,"divide");
  OP_ADD(25,div,"divide-sign");
  // plus/minus 24

  OP_ADDN(20,lt,<,"less than");
  OP_ADDN(20,le,<=,"less or equal");
  OP_ADDN(20,ge,>=,"greater or equal");
  OP_ADDN(20,gt,>,"greater than");

  OP_ADDN(18,eq,==,"equal");
  OP_ADDN(18,ne,!=,"not equal");
  OP_ADDN(18,equiv,===,"equivalent");
  OP_ADDN(18,sim,~,"similar");
  OP_ADDN(18,simeq,~=,"similar equal");

  OP_ADD(10,and,"logic and");
  OP_ADD(9,xor,"logic xor");
  OP_ADD(8,or,"logic or");

  OP_ADDN(4,assign,=,"assignment");

  OP_ADD(3,SP,"Whitespace padding");

  OP_ADD2(1,1,semi,;,"concatenation");
}