tsl-devkit/test/test.tsl

99 lines
1.9 KiB
Plaintext

// SYNTAX TEST "tsl"
// 注释 TODO
// TODO: 注释
{aaaaa TODO}
(* abcdef *)
// 数字
num6 := 123; // 数字
num7 := 1.23; // 浮点数
num1 := 0xAF123;
num2 := 0O12357;
num3 := 0B010111;
num4 := 1.2e-12;
num5 := +3E15;
// 字符串
string1 := '123';
string2 := "func2()";
// 类相关
type MyClass = class
public
function Create();
function Destroy();virtual;
function Func1(a, b);
function Func2(a: real; b: string): array of string;
function Func3(a: real = 1; b: string = "123"): array of string;
property P1 write param1_ read param1_;
private
[weakref]obj: integer;
[weakref]b: MyClass;
param1_: real;
param2_: array of string;
end;
function MyClass.Func1(a, b);
begin
end;
function MyClass.Func3(a: real = 1; b: string = "123"): array of string;
begin
obj.P1.P2;
self.P1;
end
// 属性链
echo obj.name;
user.profile.email;
data.items.count;
// 函数声明
function f(); // 无参数
function f(a, b); // 参数无类型
function f(a: real; b: DD); // 参数有类型1
function f(a: real, b: DD); // 参数有类型2
function f(a: real = 1; b: string = "123"; c: number = abc.CONST1): def; // 带返回类型
// 函数调用
f();
f(a, b);
f(a: 1; b: 's');
f(f(2, "111"));
// 类变量声明,三元表达式(不应该有冲突)
a: string;
[weakref]b: MyClass;
a ? b : c;
a ? b : c ? d : e;
return ifnil(rpr_.Caps) ? false : rpr_.Caps.IsApplied;
// select
Select ["test"] from table end;
vselect ["test"] from table end;
select distinct ["test"] from table where ['a'] = 1 end;
// array
a := array(1, 2);
b := array((1, 2), (3, 4));
sql += "update ts_xbcheck result set isvalid = "$status$remark$" where checkid in ('"$array2str
(checkid[(i-1)*len:], "','")$"');\r\n"
sql += 123;
// tsl-web块
<?tslx>
<HTML>
<Body>
<p>
<?tsl write("TSL Script");?>
</p>
</Body>
<?= "aaa", Date() ?>
</HTML>
<?tsl