-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.txt
62 lines (54 loc) · 2.07 KB
/
test.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// A simple function declaration
// A variable prefixed by a % is a local variable
function print_line(%string)
{
// This function is part of the standard lib
// See stdlib.cpp
// @ is used for string concatenation,
// and C-style escaped character strings are supported
print(%string @ "\n");
}
// this function call is at global scope, so it will
// be called when this file is executed.
print_line("Hello, World!");
// This local variable is also at file-level scope.
// A file may be thought of as a function. Any variables
// prefixed by % at file-level scope will be cleaned up
// and deleted at the end of the execution of the file
%x = 0;
// A for loop
// Logical and comparison operators are fully supported:
// < > <= >=
// == !=
// && ||
// Also, the increment and decrement operators are supported.
// When used in the r-value of an expression, pre-increment
// and post-increment work as expected (like in C)
for(; %x < 10; ++%x)
{
// This is a global variable. Variables prefixed with a $
// are global across all scripts executed by the same dscript::context
// object. They exist until the context object is destroyed. It also
// happens to be an array. Arrays aren't *really* arrays, though. What
// happens is, the array index expressions are evaluated, and concatenated
// to the identifier of the array (in this case $names), separated
// by an underscore character.
$names[%x] = "Name " @ %x;
}
// If statement
if($names[0] != $names_0)
// These are now identical (see explanation on arrays above)
print_line("Sanity check failed!");
// Strings, Ints, and Doubles are the intrinsic data types.
%x = 0; // int
%y = "Test";
%z = 1.234567; // double
// Conversion between types is implicit. Ints are promoted to doubles
// if altered by an expression by a double, and strings are and promoted
// to a double when a number is expected (any string that doesn't contain
// numeric value is evaluated as 0).
%x = "2 test";
%y = 10 + %x; // %y == 12
%z = %y + "hello"; // %y still equal to twelve
// For any specific questions, see compiler.cpp, or email me at
// me@daerid.com