Форум: "Потрепаться";
Текущий архив: 2004.01.05;
Скачать: [xml.tar.bz2];
ВнизЯзыки программирования и синтаксис Найти похожие ветки
← →
ИМХО (2003-12-14 11:48) [0]Нужна таблица соответствий вроде такой:
Паскаль Си Бэйсик
:= =
and &&
or !!
(чем полнее - тем лучше)
Подскажите, плиз, где можно найти такую таблицу?
← →
JibSkeart (2003-12-14 11:53) [1]самому придется копатся :))
вопрос только для чего все это надо ?
← →
Думкин (2003-12-14 12:04) [2]У Тейксейры и Пачеко Д5. есть.
← →
REA (2003-12-14 12:38) [3]+= ?
← →
ИМХО (2003-12-14 15:14) [4]Нужно, чтобы перевести тексты программ на Си и Бэйсике - в Паскалевские.
← →
ИМХО (2003-12-15 00:14) [5]А в Инете где-нить лежит подобное?
← →
Anatoly Podgoretsky (2003-12-15 00:19) [6]Инет он большой
← →
ИМХО (2003-12-15 00:21) [7]Ясен перец. Но АП, это уже оффтоп пошел, замечаешь?
← →
OlegGashev (2003-12-15 00:26) [8]C Operator Pascal Equivalent Description
struc.field struc.field Obtain a field of a record (structure).
ptr->field ptr^.field Obtain a field of a pointer to a record.
* ptr ptr^ Dereference a pointer
& variable @ variable Return pointer to (address of) a variable
- expr - expr Unary negation
! expr NOT expr Logical negation
~ expr BNOT( expr) Bitwise negation (one’s complement)
++ var var := var + 1 Pre-increment (see notes below)
-- var var := var - 1 Pre-decrement (see below)
var ++ var := var + 1 Post-increment (see below)
var -- var := var - 1 Post-decrement (see below)
(type)expr type(expr) C: Type casting, Pascal: type coercion
sizeof expr Sizeof( expr ) C: sizeof operator, Pascal: Sizeof function
sizeof( type ) Sizeof( type ) C: sizeof operator, Pascal: Sizeof function
e1 * e2 e1 * e2 Mutiplication
e1 / e2 e1 / e2 ( e1 DIV e2 ) Division (see below)
e1 % e2 e1 MOD e2 Remainder (modulo operator)
e1 + e2 e1 + e2 Addition
e1 - e2 e1 - e2 Subtraction
e1 << e2 BSL(e1,e2) C: Left shift operator, Pascal: left shift function
e1 >> e2 BSR(e1,e2) Right shift
e1 < e2 e1 < e2 Relational “less than” comparison
e1 > e2 e1 > e2 Relational “greater than” comparison
e1 <= e2 e1 <= e2 Relational “less than or equal” comparison
e1 >=e2 e1 >= e2 Relational “greater than or equal” comparison
e1 == e2 e1 = e2 Equal to comparison
e1 != e2 e1 <> e2 Not equal to comparison
e1 & e2 BAND( e1, e2) Bitwise “and”
e1 ^ e2 BXOR( e1, e2) Bitwise “exclusive or”
e1 | e2 BOR( e1, e2) Bitwise “or”
e1 && e2 e1 & e2 Logical “and”
e1 || e2 e1 | e2 Logical “or”
e1 ? e2 : e3 see below The ternary “conditional” operator
var = expr var := expr Simple assignment
var += expr var := var + expr Add then assign
var -= expr var := var - expr Subtract then assign
var *= expr var := var * expr Multiply then assign
var /= expr var := var / expr Divide then assign
var >>= expr var := BSR(var,expr); Shift right then assign
var <<= expr var := BSL(var,expr); Shift left then assign
var &= expr var := BAND(var,expr); Bitwise “and” then assign
var ^= expr var := BXOR(var,expr); Bitwise “exclusive or” then assign
var |= expr var := BOR(var,expr); Bitwise “or” then assign
expr , expr see below Comma operator
Some important things to note: In C, the single equal sign is used for assignment, while in Pascal, the single equal sign is used for “equal to” comparison. C uses two equal signs for “equal to” comparison. In C, the single amperand ‘&’ is used both for the bitwise “and” operation (a binary operator) and for determining the address of a variable (a unary operator). In C, the asterisk ‘*’ is used both for multiplication (binary operator) and for dereferencing a pointer (unary operator). In C, parens are used both for determining order of operations, and also for type coercion (called casting in C). There are several C operators that translate to functions in Pascal (bitwise negation, sizeof, bit shifting, etc.). C does not have a built-in exponentiation operator to correspond to Pascal’s ‘**’ operator.
Unlike Pascal, C does not have two separate division operators. It performs integer division if both operators are of intergral types.
My table doesn’t tell the whole story of the very useful pre- and post-increment (and decrement) operators. These operators are probably best understood with an example. So here is a fragment of C code:
/* 3 */
a = ++b;
c = d++;
The Pascal equivalent is:
{4}
b := b + 1;
a := b;
c := d;
d := d + 1;
Both the pre and post increment operators will increment the given variable. The difference is when. The pre-increment operator increments the variable before using the variable’s value. The post-increment operator uses the existing value and then increments the variable.
The table doesn’t explain the C ternary “conditional” operator, ‘a ? b : c’. If the first operand evaluates to non-zero, then the “conditional” operator evaluates to its second operand, otherwise it evaluates to its third operand. This operator is also probably easiest to understand by example. Here is some C code:
/* 5 */
result = a ? b : c;
And the Pascal equavalent:
{ 6 }
IF a<>0 THEN result := b ELSE result := c;
The “comma” operator is another unusual one in C. It is used to group expressions (where you would usually expect to see only one expression) and it evaluates to the value of the right expression. Once again, here is a C example (calling a function that takes three parameters):
/* 7 */
result = myFunction( a, (b=3, b+2), c);
and the Pascal equvalent:
{ 8 }
b := 3;
result: = myFunction( a, b + 2, c );
Both of these code fragments end out assigning 3 to b, and end out passing 5 as the second parameter to myFunction.
← →
ИМХО (2003-12-15 01:12) [9]Олег, а для Бэйсика нет такого?
← →
OlegGashev (2003-12-15 01:38) [10]Прямого ответа я тебе не дам. С бейсиком очень давно не работал, а в гугле прямых ссылок не нахожу. К тому же бейсик есть различных версий. Поищи по сети, может на что-то наткнешься.
← →
Gero (2003-12-15 06:45) [11]На www.astonshell.com есть уже готовая прога, переводящая тексты C++ в Object Pascal
← →
ИМХО (2003-12-15 12:06) [12]А для Бэйсика???
Страницы: 1 вся ветка
Форум: "Потрепаться";
Текущий архив: 2004.01.05;
Скачать: [xml.tar.bz2];
Память: 0.48 MB
Время: 0.009 c