[ Prev | Index | Next ]
Japanese English

Vnano as a Language

In this page, we explain main features/syntaxes of the Vnano as a script language.


What is Vnano?

The Vnano (VCSSL nano) is a programming language having simple C-like syntax. Language specifications of the Vnano is specialized for embedded use in applications, so compared with other programming languages, many features not necessary for the embedded use are omitted for making the implementation of the script engine compact. It is the concept for giving priority to customizability, maintainability, security, portability and so on than the functionality.

How to Run Example Scripts

To run example scripts on this page, copy code of a script and paste it on any text-editor, and save as a file of which file name ends with the extension ".vnano". There are multiple methods to run it, so select from the followings:

Use VCSSL Runtime

Most easy way is: Download and launch the VCSSL Runtime, and then choose the script file saved the above to run it. Syntax/features of the Vnano is a subset of the VCSSL, so you can run Vnano scripts by the VCSSL Runtime. All features of Vnano Standard Plug-ins are available by default. In addition, you can also run scripts by using "vcssl" command on your command-line terminal.

Use RINPn

If you are an user of a programmable calculator software RINPn, you can run Vnano scripts on it easily. Put a Vnano script into the folder of RINPn, and input its file name to RINPn to run it. For a script locating in other folder, you can run it by inputting its file path. On RINPn, all features of Vnano Standard Plug-ins are available by default.

Use Vnano Engine

The last method is: run a script by using command-line mode of the Vnano Engine, which is the script engine of the Vnano. On this method, you can use various options helping development, so it is recommended for developers of apps using Vnano. However, Vnano Standard Plug-ins providing fundmental features (containing "print" function) are not bundled by default, so it requires to introduce it by yourself. How to do it is explained by the document of command-line mode.

That's all about how to run example scripts. Let's move onto the main subject: language features and syntax of the Vnano.

Data Types

Vnano supports only int (=long), float (=double), bool, and string for data-types.

Nems of Data Types Descriptions
int (or long) The 64-bit signed integer type
float (or double) The 64-bit floating point number type
bool The boolean type
string The character string type

Other primitive data types, pointer, struct and class are not supported. On the other hand, array types of the data types in the above table are supported, and you can use it with C-like syntax.

However, please note that arrays in the Vnano (and VCSSL) behaves as value types, not reference types or pointers. The assignment operation (=) of an array behaves as the copy of all values of elements, not the copy of the reference to (address on) the memory. It is the same for character strings. In the Vnano, the "string" type which is the data type to store character strings behaves as the value type, not reference type.

In short, Vnano has no reference types, so all data types in the Vnano are value types. Because of that, the script engine of the Vnano has no garbage-collection (GC) modules.

By the way, if sizes of arrays at the left-hand and the right-hand of the assignment operation (=) are different, the size of the left-hand array will be adjusted to the same size with the right-hand array, by re-allocating memory of the left-hand array automatically.

Variable Declaration Statements

You can describe the variable declaration statements with C-like syntax.

Declaration of scalar variables

The following is an example code of declaration statements of scalar variables (non-array variables) :

The result on the command-line mode is:

1
2.3
true
Hello, World !

However, you can NOT declare multiple variable in 1 statement in the Vnano:

Declaration of Arrays

You can declare and use arrays as follows:

The result on the command-line mode is:

123

However, you can NOT use array initializers in the Vnano:

Control Statements

In control statements of C-like languages, Vnano supports "if" / "else" / "for" / "while" / "continue" / "break" statements.

"if" and "else" statements

The folloing is an example code of "if" and "else" statements:

The result is:

x is 1.

By the way, in the Vnano, after of "if" / "else" / "for" / "while" statements must be a block statement {...}. So you can NOT write single statement which is not enclosed by braces { } after the "if" statement as follows:

However, for "else" statement at just before of "if" statement (so-called "else if"), braces { } can be omitted.

"for" statement

The folloing is an example code of "for" statement:

Please note that braces { } can not be omitted. The result is:

i=1
i=2
i=3
i=4
i=5

"while" statement

The folloing is an example code of "while" statement:

Please note that braces { } can not be omitted. The result is:

a=500
a=377
a=254
a=131
a=8

"break" statement

The folloing is an example code of "break" statement:

The result is:

i=1
i=2
i=3

"continue" statement

The folloing is an example code of "continue" statement:

The result is:

i=1
i=2
i=4
i=5
i=7
i=8
i=10

Expressions

Elements of expressions

An expression is a series of tokens to describe operations, consists of operators, operands, and parentheses ( ). An expression can be a statement as an "expression statement" by itself (when it ends with ";"). In addition, expressions can be parts of other kinds of statements, e.g.: a condition expression of "if" statement.

As syntactic elements of expressions, "operators" are symbols of operations, e.g.: "+", "-", and so on. Values to be operated are called as "operands", e.g.: 1 and 2.3 for "1 + 2.3". More specifically, as syntactic elements, values directly described such as "1", "2.3" and so on are called as "literals". Besides literals, identifiers of variables (e.g.: "x"), and results of other operations can be operands.

The syntactic definition of expressions like above is complicated and difficult, so Let's see a typical example:

The above is an expression. In this expression, "+" and "*" are operators, "x" and "2" and "3" are operands, "(" and ")" are parentheses.

However, the result of the addition "(x + 2)" is also an operand for the "*" operator, so the word "operands" is ambiguous. For disambiguation, sometimes minimum units of operands such as "x" and "2" and "3" are syntactically called as "leaf operands".

By the way, in the Vnano, as the same with the C programming language, the symbol of the assignment "=" is an operator, so the following is also an expression:

Operators

The following is the list of operators supported in the Vnano. Note that, smaller "precedence" value gives higher precedence.

Operator Precedence Syntax Associativity Data Types of Operands Data Type of Result
Function Call
( ... , ... , ... )
1000 multiary
(multiary)
left any any
Array Indices
[ ... ][ ... ][ ... ]
1000 multiary left int any
++ (Post-increment) 1000 postfix left int int
-- (Post-decrement) 1000 postfix left int int
++ (Pre-increment) 2000 prefix int int
-- (Pre-decrement) 2000 prefix int int
+ (Unary plus) 2000 prefix right int int
- (Unary minus) 2000 prefix right int int
! 2000 prefix right bool bool
Cast
(...)
2000 prefix right any any
* 3000 binary left int, float int, float (See the next table)
/ 3000 binary left int, float int, float
% 3000 binary left int, float int, float
+ 3100 binary left int, float, string int, float, string
- 3100 binarytd> left int, float int, float
< 4000 binary left int, float bool
<= 4000 binary left int, float bool
> 4000 binary left int, float bool
>= 4000 binary left int, float bool
== 4100 binary left any bool
!= 4100 binary left any bool
&& 5000 binary left bool bool
|| 5100 binary left bool bool
= 6000 binary right any any
*= 6000 binary right int, float int, float
/= 6000 binary right int, float int, float
%= 6000 binary right int, float int, float
+= 6000 binary right int, float, string int, float, string
-= 6000 binary right int, float int, float

The value type (the data-type of the operated value) of binary arithmetic operators (*, /, %, +, -) and compound arithmetic assignment operators (*=, /=, %=, +=, -=) are decided by the following table:

- Data Types of the Results of Arithmetic & Compound Arithmetic-Assignment Operations -
Type of Operand A Type of Operand B Type of Operated Value
int int int
int float float
int string string ( available only for +, += )
float int float
float float float
float string string ( available only for +, += )
string int string ( available only for +, += )
string float string ( available only for +, += )
string string string ( available only for +, += )

Where you can choose the right or the left operand as the operand A (or operand B) freely in the above table.

Function (Internal Function)

You can declare and call functions in the Vnano script code with C-like syntax.

Note that, the Vnano does not support recursive calls of functions, because allocations of local variables are implemented in very simple way in the script engine of the Vnano.

Also, in the Vnano, functions declared in scripts are called as "internal functions", in contrast to that, functions provided by plug-ins connectet to the script engine are called as "external functions".

Scalar input/output functions

The following is an example code of the function of which arguments and the return value is scalar (non-array) values:

The result on the command-line mode is:

3

Array input/output functions

If you want to return an array, or get arrays as arguments, the following code is an example:

The result is:

z[0]=3
z[1]=5
z[2]=7

Please note that, as we mentioned in the section of Data Types, arrays in the Vnano (and VCSSL) behaves as value types, not reference types or pointers.

Assignment operations of arguments and the return value behaves as the copy of all values of elements, not the copy of the reference to (address on) the memory. In addition, the size of the array will be adjusted automatically when an array having different size will copied to it.

Therefore, we omitted to specify size of array declarations in several places in the above code, e.g.: "int a[]", "int b[]", and "int z[] = fun(x, y, 3)".

Formal parameters and actual arguments

The parameter-variable declared in a function declaration like as "a" in the following example is called as "formal parameter". In contrast, the value/variable passed to a function like as "x" in the following example is called as "actual argument".

Call by value

By default, change of values of formal parameters in functions don't affect to values of actual arguments of caller-side, For example:

The result is:

x = 0
y[0] = 0
y[1] = 0
y[2] = 0

As demonstrated by the above result, actual arguments of caller-side "x" and "y" have not changed although formal parameters "a" and "b" changed in the function "fun".

This is because, by default, actual arguments will be simply copied once to formal parameters when the function is called. This behaviour is called as "call-by-value".

Call by reference

If you want to affect changed values of formal parameters in functions to values of actual arguments of caller-side, describe the symbol "&" before the name of formal parameters in declarations of them. For example:

The result is:

x = 2
y[0] = 10
y[1] = 11
y[2] = 12

The memory-reference to data of a formal parameter declared with "&" will be shared with reference to data of an actual argument.

Hence, as demonstrated by the above result, after values of formal parameters "a" and "b" in the function "fun" changed, actual arguments "x" and "y" of caller-side also changed to same values with "a" and "b". This behaviour is called as "call-by-reference".

"import" and "include" Declarations

In the VCSSL, which is the "parent language" of the Vnano, we can describe "import" / "include" declarations in scripts, for loading specified libraries. For example:

If we execute the above code as a VCSSL script, the "ExampleLibrary" will be loaded automatically by the line "import ExampleLibrary;", and then its member function "exampleFunction" will be available in the script.

On the other hand, in the Vnano (is a subset of the VCSSL for embedded use), scripts can not request the scripting engine to load libraries/plug-ins. All libraries/plug-ins must be loaded/specified by application-side code or setting files (see Main Features of Vnano Engine, and Examples), not scripts. This is a restriction for keeping security in embedded use.

However, it is possible to "import" or "include" declarations in Vnano scripts, though the specified libraries/plug-ins will not load automatically. If an "import" / "include" declaration exists in a Vnano script, the scripting engine confirms that whether the specified library (or the plug-in providing the same namespace) has been loaded. If it has not been loaded, the engine notify the user of missing the library/plug-in, as an error message.

For example, if we execute the above example code as a Vnano script, and the library "ExampleLibrary" (or the plug-in prividing "ExampleLibrary" namespace) is not loaded, the following error message will be displayed:

This script requires features of "ExampleLibrary", but no library or plug-in providing them is not loaded. Check the settings to load libraries/plug-ins.

Also, if we removed the line "import ExampleLibrary;" from the script, the error message changes to the following:

Unknown function "exampleFunction(float)" is called.

The former error message is more user friendly than the latter one, because the user can grasp what they should do for solving the problem.

When the specified librarie or plug-in has been loaded and is available, nothing occurs by the "import" / "include" declaration. Hence, "import" / "include" declarations are not mandatory for Vnano scripts, but they give the advantage shown in the above.


Japanese English
Index
News From RINEARN
* VCSSL is developed by RINEARN.

Released the Latest Versions of RINEARN Graph and VCSSL - Now Supporting Customizable Tick Positions and Labels!
2024-11-24 - Starting with this update, a new "MANUAL" tick mode is now supported, allowing users to freely specify the positions and labels of ticks on the graph. We'll explain the details and how to use it.

Released Exevalator 2.2: Now Compatible with TypeScript and Usable in Web Browsers
2024-10-22 - The open-source expression evaluation library, Exevalator, has been updated to version 2.2. It now supports TypeScript and can be used for evaluating expressions directly in web browsers. Explains the details.

Behind the Scenes of Creating an Assistant AI (Part 1: Fundamental Knowledge)
2024-10-07 - The first part of a series on how to create an Assistant AI. In this article, we introduce the essential knowledge you need to grasp before building an Assistant AI. What exactly is an LLM-based AI? What is RAG? And more.

Launching an Assistant AI to Support Software Usage!
2024-09-20 - We've launched an Assistant AI that answers questions about how to use RINEARN software and helps with certain tasks. Anyone with a ChatGPT account can use it for free. We'll explain how to use it.

Software Updates: Command Expansion in RINEARN Graph, and English Support in VCSSL
2024-02-05 - We updated our apps. This updates include "Enhancing the Command-Line Features of RINEARN Graph" and "Adding English Support to VCSSL." Dives into each of them!

Inside the Repetitive Execution Speedup Impremented in Vnano Ver.1.1
2024-01-17 - Delves into the update in Vnano 1.1 from a developer's viewpoint, providing detailed insights into the specific improvements made to the internal structure of the script engine.

Scripting Engine Vnano Ver.1.1 Released: Dramatic Speed Improvement for Repetitive Executions of the Same Content
2023-12-22 - Released the Vnano script engine Ver.1.1. In this version, we've made significant enhancements in processing speed by reducing the overhead of handling requests. Explains the details.

RINEARN Graph 3D Updated and Next Version (Ver.6) Development Has Begun!
2023-09-04 - We have released RINEARN Graph 3D Ver.5.6.34. In addition, we have initiated the development of the next major version, Ver.6! Details inside.

Updated Contents
Circular Wave Animation

Draws the circular wave as 3D animation, under the specified wave parameters.
2022-12-14
Sine Wave Animation

Draws the sine wave as animation, under the specified wave parameters.
2022-11-26
Tool For Converting Units of Angles: Degrees and Radians

A GUI tool for converting the angle in degrees into radians, or radians into degrees.
2022-11-22
Connector Fatal Exception - Specification
The unchecked exception thrown when errors have occurred, caused by incorrect implementations (might be bugs).
2022-09-26
Connector Exception - Specification
The checked exception thrown when errors have occurred, cause by expected normal problems.
2022-09-26