c-smile 一个语法类似与JS 又有点像C++的 编译器

源代码在线查看: test.csp

软件大小: 260 K
上传用户: sinba
关键词: c-smile 编译器
下载地址: 免注册下载 普通下载 VIP

相关代码

				package test;
				
				import tests;
				import T;
				
				class ttc {
				  var a;
				  var arr;
				  function ttc(p) { a = p; arr = [1,2];}
				  
				  function one() { print(a," one\n") ;}
				  function two() { print(a," two\n") ;}
				  function three() { return a + " three\n"; }
				  
				  static var disp = { "one":one, "two":two };
				  
				  function callme(str) { 
				    var f = disp[str];
				    if(f) (this @ f)();
				    else  print(str," not found!\n");  
				  }
				}
				
				function test(n)
				{
				    var i;
				    for (i = 0; i 						if (i % 2 == 0) continue;
						if (i > 10) break;
						print("i=",i,"\n");
				    }
				}
				
				function main()
				{
				    test(5);
				    test(12);
				            
				    var t = new ttc("hello");
				    var one = ttc::one;
				    var two = ttc::two;
				    
				    var A = [ t.one, t.two ];
				    
				    print(A);
				    A[0]();
				    A[1]();
				    
				    print(t.arr[0],t.arr[1]);
				    print(t.three());
				    
				    (t @ one)();
				    
				    t.callme("one");
				    t.callme("two");
				    t.callme("three");
				
				    var ttt = new tests::tclass(555);
				    print(ttt);
				              
				}
				
							

相关资源