Ch interpreter

Ch interpreter

) is a cross-platform interpreter for the computer programming languages C and C++. It is useful for scripting, shell programming, 2D/3D plotting, numerical computing, and can be embedded in other applications to add scripting capability. Ch can be used for both server-side and client-side web development. It runs under Windows, Linux, Mac OS X and some versions of Unix. Ch supports C90 and major C99 features, but it doesn't support full C++ features.

Features

C/C++ compatible interpreter

Ch supports the 1999 ISO C Standard (C99) and C++ classes. It is superset of C withC++ classes. C99 major features such as complex numbers, variable length arrays (VLAs), IEEE-754 floating-point arithmetic and generic mathematical functions are supported. Wide characters in Addendum 1 for C90 is also supported.

Embeddable scripting

As a C/C++ interpreter, Ch can be used as a scripting engine for your applications. It extends your applications with a C compatible scripting language.

Shell programming and cross-platform scripting

Ch is a C-compatible shell similar to C-shell (csh). It can be used as login shell. Ch has a built-in string type for automatic memory allocation and de-allocation.

2D/3D plotting and numerical computing

Ch has built-in 2D/3D graphical plotting features and computational arrays for numerical computing. A 2D linear equation of the form "b = A*x" can be written verbatim in Ch.

Examples

"Hello, world!" in Ch

There are two ways to run Ch code. One is:

#!/bin/ch printf("Hello world! ");

Another is:

#!/bin/ch #include int main() { printf("Hello world! "); }

Note: #!/bin/ch is optional.

Ch also supports interactive shell command and C statements.

> int i, *p, **p2 // i is an integer, p pointer, p2 double pointer > i=10 // i is assigned value 10 10 > p=&i // p points to address of i 00D847C0 > *p // the memory pointed by p has value 10 10 > p2=&p // p2 points to address of p 00D84D30 > **p2 // the memory pointed by the pointer at p2 has value 10 10 >

Numerical computing in Ch

#include #include int main() { array double A [2] [3] = {1, 2, 3, 4, 5, 6}; array double B [3] [2] ; printf("A= %f ", A+A); B = 2*transpose(A); printf("B= %f ", B); }

The output is:

A= 2.000000 4.000000 6.000000 8.000000 10.000000 12.000000 B= 2.000000 8.000000 4.000000 10.000000 6.000000 12.000000

Shell programming

Find and compile all .c files into .o in the current directory for which the .o file is old or absent:

#!/bin/ch #include <sys/stat.h> struct stat cstat, ostat; string_t c, o; foreach (c; `find . -name "*.c"`) { o=`echo $c | sed 's/.c$/.o/'`; stat(o, &ostat); stat(c, &cstat); if (ostat.st_mtime > cstat.st_mtime) { echo "compiling $c to $o"; gcc -c -o "$o" "$c"; } }

2D/3D plotting in Ch

To plot a sine wave:

#include #include int main() { int numpoints = 36; array double x [numpoints] , y [numpoints] ; linspace(x, 0, 360); // assign x with values from 0 to 360 linearly y = sin(x*M_PI/180); plotxy(x, y, "Ch plot", "xlabel", "ylabel"); }

See also

* CINT

External links

* [http://www.softintegration.com SoftIntegration Home Page]
* [http://sourceforge.net/projects/chsqlite SQLite in Ch]
* [http://sourceforge.net/projects/chpcre Perl Compatible Reg. Expressions in Ch]
* [http://sourceforge.net/projects/chscite ChScite]
* [http://sourceforge.net/projects/chmxml Ch Mini-XML]
* [http://sourceforge.net/projects/chgsl GNU Scientific Library in Ch]
* [http://sourceforge.net/projects/chlibxml2 Ch libxml2 package]
* [http://sourceforge.net/projects/chopenal ChOpenAL]


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • interpréter — [ ɛ̃tɛrprete ] v. tr. <conjug. : 6> • 1155 ; lat. interpretari 1 ♦ Expliquer, rendre clair (ce qui est obscur dans un texte). ⇒ commenter, expliquer, gloser. Interpréter un document. Interpréter abusivement, tendancieusement un texte. ⇒… …   Encyclopédie Universelle

  • Interpreter of Maladies —   Cover of paperback edition …   Wikipedia

  • interpreter — Interpreter. v. a. Expliquer quelque chose, en estre l interprete. Interpreter bien. interpreter mal. interpreter fidellement, mot à mot. ceux qui ont interpreté l Escriture sainte, interpreté Aristote, &c. comment interpretez vous ce passage?… …   Dictionnaire de l'Académie française

  • interpreter — in‧ter‧pret‧er [ɪnˈtɜːprtə ǁ ˈtɜːrprtər] noun [countable] 1. someone who translates what someone says from one language into another, especially as their job: • Speaking through an interpreter, the Foreign Minister explained how impressed he… …   Financial and business terms

  • Interpreter (Begriffsklärung) — Interpreter bezeichnet einen allgemeinen Begriff aus der Softwaretechnik; siehe Interpreter in der objektorientierten Programmierung ein Entwurfsmuster; siehe Interpreter (Entwurfsmuster) den englischen Ausdruck für Dolmetscher den amerikanischen …   Deutsch Wikipedia

  • Interpreter-Sprache — Interpreter Sprache,   eine Programmiersprache, deren Quellprogramme mit einem Interpreter (und nicht mit einem Compiler) übersetzt werden bzw. als Interpreter vorliegen. Die Programmiersprache Basic in ihrer ursprünglichen Form sowie die meisten …   Universal-Lexikon

  • interpreter — et donner à cognoistre, Interpretari. Interpreter à mal, Recte facta detorquere. Interpreter le faict d aucun estre fait par despit de soy, In contumeliam suam vertere quod alius gesserit. Interpreter quelque chose en bonne partie, In optima spe… …   Thresor de la langue françoyse

  • Interpreter — Шаблон Interpreter(также известный как Интерпретатор) – Шаблон проектирования Поведенческий шаблон (Behavioral). Решает часто встречающуюся, подверженную изменениям задачу. Содержание 1 Описание 2 Проблема 3 Решение …   Википедия

  • interpreter — intèrpreter m DEFINICIJA inform. program koji prevodi instrukcije iz višeg programskog jezika u strojni jezik i izvršava ih, instrukciju po instrukciju, opr. kompajler ETIMOLOGIJA engl. interpreter ← lat. interpretari …   Hrvatski jezični portal

  • Interpreter — In*ter pret*er, n. [Cf. OF. entrepreteur, L. interpretator.] One who or that which interprets, explains, or expounds; a translator; especially, a person who translates orally between two parties. [1913 Webster] We think most men s actions to be… …   The Collaborative International Dictionary of English

  • interpreter — index judge Burton s Legal Thesaurus. William C. Burton. 2006 …   Law dictionary

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”