C like interpreter - OfficinaTurini

Go to content
© Ida Hart Trust. All Rights Reserved.
BC é un interprete C similare.
É stato specificamente sviluppato per i sistemi embedded ma funziona anche su Windows.
BC significa "prima del C" o "prima di Cristo", personalmente preferisco la seconda essendo un grande fan di Johnny Hart.
Il tutto per dire .... che questo linguaggio non é potente come il GCC anzi é molto limitato, ma dalla sua ha che occupa poca memoria ed é veloce, insomma ideale per degli script per piccoli sistemi.
Ho avuto lo spunto per questo progetto da C4 su Github e passo dopo passo é diventato molto piú complesso ...

BC is a C like language interpreter.
It's developed for embedded system but also run on Windows.
BC means "before C" or "before Christ", I personally prefer the latter being a big fan of Johnny Hart.
All this to say .... that this language is not as powerful as the GCC but is very limited, but from its has that it takes up little memory and is fast, in short, ideal for scripts on small systems.
I was inspired by this project from C4 on Github and step by step has become much more complex.
Si presuppone che conosciate perfettamente il linguaggio C e qui sotto trovate una breve documentazione per definire le principali differenze fra il C e BC.
Fare comunque riferimento anche ad i numerosi esempi disponibili nella distribuzione.
It is assumed that you know the C language perfectly and below is a brief documentation to define the main differences between C and BC.
However, refer also to the numerous examples available in the distribution.
Il piú classico degli esempi ...
The most classic of the examples ...
// The only way to comment a line.
int main()
{
c.fwrite("Hello world!\n");
return 0;
}
TIPI VARIABILI
VARIABLE TYPES
Type
Value range
Declaration
1 byte
-128 to 127
char one = 't', second, third, * ptr;
2 bytes
-32,768 to 32,767
int i, c, k = 0, * len;
4 bytes
-2,147,483,648 to 2,147,483,647
long acc, tot = 0, * buff;
4 bytes
1.2E-38 to 3.4E+38 (6 decimal places)
float pi = 3.14, * mat;
4 bytes
-2,147,483,648 to 2,147,483,647
Integer number can be written also as hex mode: 0x1000 while float must be implicit like 1.324 or explicit 1324f
CONTROLLO DEL FLUSSO
FLOW CONTROL
statement
usage
explain
if (testExpression) {
      // statement(s) inside the body of if
}
else {
     // statement(s) inside the body of else
}
If test expression is evaluated to true:
statement(s) inside the body of if statement is executed
statement(s) inside the body of else statement is skipped from execution.

If test expression is evaluated to false:
statement(s) inside the body of else statement is executed
statement(s) inside the body of if statement is skipped.
for (initializationStatement; testExpression; updateStatement)
{
          // codes
}
The initialization statement is executed only once.

Then, the test expression is evaluated. If the test expression is false (0), for loop is terminated. But if the test expression is true (nonzero), codes inside the body of for loop is executed and the update expression is updated.

This process repeats until the test expression is false.

The for loop is commonly used when the number of iterations is known.
while (testExpression)
{
           //codes
}
The while loop evaluates the test expression.

If the test expression is true (nonzero), codes inside the body of while loop is executed. The test expression is evaluated again. The process goes on until the test expression is false.

When the test expression is false, the while loop is terminated.
do
{
         // codes
} while (testExpression);
The code block (loop body) inside the braces is executed once.

Then, the test expression is evaluated. If the test expression is true, the loop body is executed again. This process goes on until the test expression is evaluated to 0 (false).

When the test expression is false (nonzero), the do...while loop is terminated.
USO DEI PUNTATORI
USE OF POINTERS
LIBRERIA
La libreria é composta da una serie di classi predefinite che offrono diversi centinaia di metodi. Le classi possono essere selettivamente attivate per ridurre l'impatto in memoria.
LIBRARY
The library is composed of a series of predefined classes that offer several hundred of methods. Classes can be selectively activated to reduce memory impact.
CLASS
DESCRIPTION
ID
EXAMPLE
consoleConsole input/outputcc.fwrite("Hello world!\n");
dirDirectory managementdirdir.mk("\myDir");
fileFile I/O accessff.open("myFile.txt", f.FA_CREATE_ALWAYS);
memoryMemory managementmm.new(1024);
MathFloating point math libraryMM.sin(alpha);
stringString manipulationss.cpy(buff, "Hello");
timeTime relatedtt.time(&h, &m, &s);
PROVA BC!

Nel link sottostante si puó scaricare una versione di BC da linea di comando.
Per lanciare un file di script basta digitare:
bc_ script/nome_dello_script.c
Alternativamente  si puó usare l'editor SCITE presente, caricare un file dalla cartella SCRIPT e premere F5 per metterlo in esecuzione.
TRY BC!

In the link below you can download a command line version of BC.
To launch a script file just type:
bc_ script/name_of_script.c
Alternatively you can use the present SCITE editor, load a file from the SCRIPT folder and press F5 to run it.
We are working on the documentation soon to be updated ...
Free counters!
VAT IT 02230330504
(C) 2016-2020 Officina Turini, Tutti i diritti riservati
Back to content