accept anonymous procedure expressions, keyword-prefixed identifiers, and read/write accessor nodes in the grammar and generated parsers. sync ast tests, parser scripts, sample fixtures, and playbook config with the updated parser behavior.
105 lines
2.0 KiB
Plaintext
105 lines
2.0 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 read param1_ write 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
|
|
|
|
// 函数声明
|
|
function f(); // 无参数
|
|
function f(a, b); // 参数无类型
|
|
function f(a: real; b: DD); // 参数有类型
|
|
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"));
|
|
data.abc();
|
|
|
|
// 属性链
|
|
echo obj.name;
|
|
user.profile.email;
|
|
data.items.count;
|
|
data.abc(p1, p2).def;
|
|
obj["def"].name;
|
|
|
|
// 类变量声明,三元表达式(不应该有冲突)
|
|
a: string;
|
|
[weakref]b: MyClass;
|
|
a := def.acc;
|
|
gloabl a, b: number := 1;
|
|
var b: Saaa := "abc";
|
|
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 += abc;
|
|
|
|
// tsl-web块
|
|
<?tslx>
|
|
<HTML>
|
|
<Body>
|
|
<p>
|
|
<?tsl write("TSL Script");?>
|
|
</p>
|
|
</Body>
|
|
<?= "aaa", Date() ?>
|
|
</HTML>
|
|
<?tsl
|
|
|
|
|