Remove ads
来自维基百科,自由的百科全书
Nuva语言是一种面向对象的动态脚本语言。Nuva对应汉语的「女娲」(中国上古时代的神话传说人物)一词。
此條目没有列出任何参考或来源。 (2018年2月2日) |
设计目的是用于基于模板的代码生成。除了用于代码生成领域外,也能用于开发应用程序,如文本和数据处理、GUI应用程序等。
<.
if (a = b && c == d or e <> f)
?? foo()
function foo()
Result = 'foo'
end function
end if
.>
<.
var a = '1'
a ++
?? 'a' ~ a
// 结果为: a2
.>
[.='Hello, Nuva!'.]
<.='Hello, Nuva!'.>
[.='Hello, Nuva!'.>
<.='Hello, Nuva!'.]
<.
var text = System.File.Load('Regex_Test.nuva')
foreach(str = text.RegexMatchs('\w+', ''))
?? str
end foreach
.>
输出如下的结果:
var
text
System
File
Load
Regex_Test
nuva
foreach
str
text
RegexMatches
w
str
end
foreach
<.. "Hello, Nuva!" Demo ..>
<.
//======================================
// Hello, Nuva! (1)
//======================================
?? 'Hello, Nuva!'
/*======================================
Hello, Nuva! (2)
======================================*/
function HelloNuva()
?? "Hello, Nuva!";
end function
HelloNuva();
/*======================================
Hello, Nuva! (3)
======================================*/
class Nuva()
function Hello()
?? 'Hello, Nuva!';
end function
end class
var n = Nuva();
n.Hello();
.>
<.
function Foreach_Demo()
// Load Schema from a Xml file
var schema = System.Data.LoadSchema(
System.Path.ProjectPath ~ '..\Northwind\Northwind.xobject'
);
?? '--------------------'
?? 'Tables Order by Name'
?? '--------------------'
foreach(table = schema.Tables.OrderbyName)
?? table.Name
end foreach
?? '---------------------------------'
?? 'Tables Filter by Name.Length < 10'
?? '---------------------------------'
foreach(table = schema.Tables | table.Name.Length < 10)
?? table.Name
end foreach
end function
.>
<.
function File_Demo()
?? \r\n ~ '--Read file and Output here--'
file('codeexamples.nuvaproj') end file
// Read file and write to 'Target', overwrite it if exist
file('codeexamples.nuvaproj', true)
Target = 'temp.target'
end file
?? \r\n ~ '--Read file dynamically and Output here--'
file('')
FileName = System.Path.ProjectPath ~ 'output\temp.target'
end file
// Delete file
System.File.Delete(System.Path.ProjectPath ~ 'output\temp.target')
end function
.>
<.
function Assign_Demo()
// 'Result' assigned from the output in the assign statement
assign(Result).]
Generate Text ... @[.=System.Now.] ...
<.end assign
end function
.>
<.
/*--------------------------------------------------------
Factorial
--------------------------------------------------------*/
function Factorial ( N )
if (N <= 1)
Result = 1;
else
Result = N * Factorial(N - 1); // Recursion Call
end if;
end function;
.>
<.
function Class_Demo()
class ClassA()
function Do()
this.DynDo()
end function
function DynDo()
?? 'ClassA'
end function
end class
class ClassB = ClassA()
function DynDo()
?? 'ClassB'
end function
end class
var c1 = ClassA()
var c2 = ClassB()
c1.Do()
c2.Do()
end function
.>
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.