From 5df79c53745fde5d6c3340a2979b1429cd5892c1 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Sat, 8 Oct 2011 20:30:28 +0200 Subject: Initial import of htcd system 1.0 Signed-off-by: Henrik Rydberg --- src/ops/basic.cc | 269 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 269 insertions(+) create mode 100644 src/ops/basic.cc (limited to 'src/ops/basic.cc') diff --git a/src/ops/basic.cc b/src/ops/basic.cc new file mode 100644 index 0000000..b30e351 --- /dev/null +++ b/src/ops/basic.cc @@ -0,0 +1,269 @@ +/************************************************************************* + * + * 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 +#include + +OP1_IMPL(exp) { out<>atoi(R));} + +OP1_IMPL(bitnot) {out<<~atoi(a);} +OP2_IMPL(bitand) {out<<(atoi(L)&atoi(R)); } +OP2_IMPL(bitor) {out<<(atoi(L)|atoi(R)); } +OP2_IMPL(bitxor) {out<<(atoi(L)^atoi(R)); } + +OP2_IMPL(SP) {out<>, + "C style\n" + "Shift right\n" + "Syntax: (int) >> (int)\n" + "Returns: (int)\n" + ); + + OP_ADD(18,eq, + "Lexicographic equal\n" + "Syntax: (string) eq (string)\n" + "Returns: (int)\n" + ); + OP_ADD(18,eqn, + "Lexicographic equal, case insensitive\n" + "Syntax: (string) eqn (string)\n" + "Returns: (int)\n" + ); + OP_ADDN(18,eqf,==, + "Arithmetic equal\n" + "Syntax: (real) == (real)\n" + "Returns: (int)\n" + ); + OP_ADD(18,ne, + "Lexicographic not equal\n" + "Syntax: (string) ne (string)\n" + "Returns: (int)\n" + ); + OP_ADD(18,nen, + "Lexicographic not equal, case insensitive\n" + "Syntax: (string) nen (string)\n" + "Returns: (int)\n" + ); + OP_ADDN(18,nef,!=, + "Arithmetic not equal\n" + "Syntax: (real) != (real)\n" + "Returns: (int)\n" + ); + + OP_ADDN(16,bitand,&, + "C style\n" + "Bitwise AND\n" + "Syntax: (int) & (int)\n" + "Returns: (int)\n" + ); + OP_ADDN(14,bitxor,^, + "C style\n" + "Bitwise XOR\n" + "Syntax: (int) ^ (int)\n" + "Returns: (int)\n" + ); + OP_ADDN(12,bitor,|, + "C style\n" + "Bitwise OR\n" + "Syntax: (int) | (int)\n" + "Returns: (int)\n" + ); + + OP_ADDN(10,and,&&, + "C style\n" + "Logical AND\n" + "Syntax: (int) && (int)\n" + "Returns: (int)\n" + ); + OP_ADDN(9,xor,^^, + "Logical XOR\n" + "Syntax: (int) ^^ (int)\n" + "Returns: (int)\n" + ); + OP_ADDN(8,or,||, + "C style\n" + "Logical OR\n" + "Syntax: (int) || (int)\n" + "Returns: (int)\n" + ); + + /* + OP_ADD(3,SP, + "Whitespace padding\n" + "Syntax: a ws OR ws a OR a ws b\n" + "Returns: a b\n" + ); + */ + + M.add(new op_t(",",2,impl_comma, + "C style\n" + "Separate expression\n" + "Syntax: a , b\n" + "Returns: b\n" + )); + OP_ADD2(1,1,semi,;, + "C style\n" + "End expression\n" + "Syntax: a ; OR a ; b\n" + "Returns: nothing\n" + ); +} -- cgit v1.2.3