=====================
Frost Programming Language
developed by
Fabio de Albuquerque Dela Antonio
fabio914@gmail.com
fabioada@usp.br
fabio914.blogspot.com
====================
.:. About Frost Language .:.
- Interpreted programming language.
(compatible with Linux, and OS X)
- Structured programming language
(partially Object-Oriented)
- Interpreter written in C.
(You can call C functions from your
script, using dynamic libraries).
- Dynamic variables
(automatic malloc and free,
and dynamically typed variables).
- Reflection.
====================
Version 0.1.5
.:. Changelog .:.
[0.1.4] -> [0.1.5]
+ You can now call functions named by strings.
var str = "print";
[~str string:"called function: %s\n" format:{str}];
+ New special variables: functionList, globalList, and callList.
+ Call trace stack is printed in case of error.
+ New code insertion operator "::". Now it is possible to
append code during runtime.
var newCode = "myFunc { return 10; }\n"; // ATTENTION: Don't forget to add "\n"!
:: newCode ::;
[print string:"%v\n" format:{[myFunc]}];
+ New syntax for threads! (NOTE THAT THREADS ARE NOT SUPPORTED YET
THIS WILL REQUIRE A MAJOR CODE REFACTORING).
[0.1.3] -> [0.1.4]
+ Minor changes! Now it is possible to compile
this on Raspberry Pi using gcc 4.6.3.
[0.1.2] -> [0.1.3]
+ Major changes (read the language syntax).
+ Added named array positions (attributes)!
var a = { .ten 10, .twenty 20, .zero nil, .arr {1,2,3} };
a.zero = 0;
a.arr[0] = 1;
if(a.arr.length == 3) {
...
}
[0.1.1] -> [0.1.2]
+ Added "foreach"
foreach(v in array) {
[print string:"%s " format:{v}];
}
// Is the same as...
for(i = 0; i < array.length; i = i + 1) {
var v = array[i];
[print string:"%s " format:{v}];
}
// ATTENTION: Note that, THIS:
for(i = 0; i < array.length; i = i + 1) {
array[i] = 10;
}
// Is not the same as this:
foreach(v in array) {
v = 10;
}
+ Small bug fix (length of an empty array).
[0.1] -> [0.1.1]
+ Added reference to functions.
@func
+ Added support for calling function references.
var a = @func;
[~a];
+ Added function blocks.
^ { ... }
+ Minor bug fixes.
====================
.:. How to install .:.
Linux and OS X:
$ make
$ make install_libs
$ sudo make install
.:. How to uninstall .:.
Linux and OS X:
$ make uninstall_libs
$ sudo make uninstall
.:. How to test .:.
$ cd examples/
$ frost helloWorld.frost
(HINT: Run other examples…)
.:. How to use .:.
$ frost <script file> [args]
.:. How to program .:.
Read the language syntax (below), and
read some examples… It should be easy
to program if you already know how to
program in C, C++, Objective-C or Java.
(NOTE: this language is right-associative)
.:. Where is io.frost? .:.
After installing: ~/.frost/libs/
====================
Language Syntax:
'//' : commentary until end of line.
.:. BNF .:.
<program> ::= "import" <string> ";" <program>
| "var" <global-var> ";" <program>
| "const" <const-var> ";" <program>
| "external" "(" <string> ")" <func-def> ";" <program>
| <func-def> <block> <program>
| ""
<global-var> ::= <name> <more-global-var>
| <name> "=" <const-expression> <more-global-var>
<more-global-var> ::= "," <global-var> | ""
<const-var> ::= <name> "=" <const-expression> <more-const-var>
<more-const-var> ::= "," <const-var> | ""
<const-expression> ::= <const-array>
| "@" <name>
| "^" <func-def-args> <block>
| <char>
| <string>
| <name>
| <number>
<const-array> ::= "{" <const-array-item> "}"
<const-array-item> ::= <named-position> <const-expression> <more-const-array-item> | ""
<named-position> ::= "." <name> | ""
<more-const-array-item> ::= "," <named-position> <const-expression> <more-const-array-item> | ""
<func-def> ::= <name> <func-def-args>
<func-def-args> ::= ":" <name>
| ":" "[" <args-def> "]"
| ""
<args-def> ::= <name> <more-args-def> | ""
<more-args-def> ::= "," <name> <more-args-def> | ""
<block> ::= "{" <commands> "}"
<commands> ::= "var" <local-var> ";" <commands>
| "for" "(" <expression> ";" <expression> ";" <expression> ")" <block> <commands>
| "foreach" "(" <name> "in" <expression> ")" <block> <commands>
| "if" "(" <expression> ")" <block> <else> <commands>
| "do" <block> "while" "(" <expression> ")" ";" <commands>
| "while" "(" <expression> ")" <block> <commands>
| "return" <ret> ";" <commands>
| "::" <expression> "::" ";" <commands>
| <expression> ";" <commands>
| ""
<local-var> ::= <name> <more-local-var>
| <name> "=" <expression> <more-local-var>
<more-local-var> ::= "," <local-var> | ""
<else> ::= "else" <block> | ""
<ret> ::= <expression> | ""
<expression> ::= <lor_expression>
<lor_expression> ::= <land_expression>
| <land_expression> "||" <lor_expression>
<land_expression> ::= <equality_expression>
| <equality_expression> "&&" <land_expression>
<equality_expression> ::= <relational_expression>
| <relational_expression> "==" <equality_expression>
| <relational_expression> "!=" <equality_expression>
<relational_expression> ::= <shift_expression>
| <shift_expression> ">" <relational_expression>
| <shift_expression> "<" <relational_expression>
| <shift_expression> ">=" <relational_expression>
| <shift_expression> "<=" <relational_expression>
<shift_expression> ::= <additive_expression>
| <additive_expression> ">>" <shift_expression>
| <additive_expression> "<<" <shift_expression>
<additive_expression> ::= <multiplicative_expression>
| <multiplicative_expression> "+" <additive_expression>
| <multiplicative_expression> "-" <additive_expression>
<multiplicative_expression> ::= <unary_expression>
| <unary_expression> "*" <multiplicative_expression>
| <unary_expression> "/" <multiplicative_expression>
| <unary_expression> "%" <multiplicative_expression>
<unary_expression> ::= <id> | "!" <id>
<id> ::= <get-var> <attribute> <assign-var>
| <call-func> <attribute>
| <get-string> <attribute>
| <get-array> <attribute>
| <char> <attribute>
| "<<<" <expression>
| ">>>" <expression>
| "$" <name>
| "@" <name> <attribute>
| "^" <func-def-args> <block> <attribute>
| "(" <expression> ")" <attribute>
| <number>
<get-var> ::= <name>
<assign-var> ::= "=" <expression> | ""
<array-pos> ::= "[" <expression> "]"
<call-func> ::= "[" <call-func-name> <args> "]"
<call-func-name> ::= <name>
| "~" <expression>
<args> ::= <name> ":" <expression> <args> | ""
<get-string> ::= <string> <array-pos>
<get-array> ::= "{" <array-item> "}"
<array-item> ::= <named-position> <expression> <more-array-item> | ""
<more-array-item> ::= "," <named-position> <expression> <more-array-item> | ""
<get-char> ::= <char>
<attribute> ::= "." "length" <attribute>
| "." "at" "(" <expression> ")" <attribute>
| "." "string" <attribute>
| "." "int" <attribute>
| "." "char" <attribute>
| "." "type" <attribute>
| "." "protected" <attribute>
| "." <name> <attribute>
| <array-pos> <attribute>
| ""
.:. Others .:.
<name> : single-word string.
<string> : multi-word string between double quotes (\n, \r, \t, \\, and \" are accepted).
<char> : single character between single quotes (\n, \r, \t, \\, \', and \" are accepted)
<number> : integer or float number.
====================
.:. Types .:.
bool, uint, int, char,
uchar, float, array, function
.:. Constant variables .:.
* --------------------------- *
| Variable | Type |
| --------- | --------------- |
| nil | nil |
| true | bool/uint |
| false | bool/uint |
| version | array (string) |
| system | array (string) |
| char | uint |
| uchar | uint |
| int | uint |
| uint | uint |
| bool | uint |
| float | uint |
| array | uint |
| function | uint |
* --------------------------- *
.:. Special variables .:.
These variables are not constant, they are computed
every time you use them (like an inline function).
* ---------------------------------- *
| Variable | Type |
| ------------- | ------------------ |
| functionList | array (of strings) |
| globalList | array (of strings) |
| callList | array (of strings) |
* ---------------------------------- *
.:. Common attributes .:.
Every variable has these attributes:
* --------------------------------------------------------------------------- *
| Attribute | Action | Read/Write |
| --------- | --------------------------------------------- | --------------- |
| length | returns array length | Read only. |
| at(...) | same as [...] (item of an array) | Read and write. |
| string | returns a string representation | Read only. |
| int | returns an integer representation | Read only. |
| char | returns a char representation | Read only. |
| type | returns the type of this var (uint) | Read only. |
| protected | returns whether this var is a constant (bool) | Read only. |
* --------------------------------------------------------------------------- *
====================