65.9K
CodeProject 正在变化。 阅读更多。
Home

超新星编程语言

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.96/5 (39投票s)

2010年3月29日

CPOL

2分钟阅读

viewsIcon

101962

downloadIcon

1860

超新星是一种为Microsoft-Windows发布的现代脚本语言,以免费软件形式提供。

引言

我对使用人工智能技术实现编译器感兴趣,并将超新星(一种为Microsoft-Windows发布的简单脚本语言,以免费软件形式正式发布)作为我研究的成果。

超新星是一种小型编程语言(小于15MB),可用于快速简单的任务。它也适合儿童作为学习编程艺术的起点。

作为一种语言,超新星倾向于更接近我们的日常语言,我们使用纯人类语言的子集进行“基于虚构描述的编程”(PWFD)。

人类语言非常庞大,包含许多词汇,因此我们使用其子集来**降低问题的复杂性**并尽可能**获得可接受的性能**。

与其他基于语句的编程语言不同,超新星基于段落,段落包含许多使用忽略词(如“the”、“and”等)打包在一起的语句。

例如,以下两个命令:

  • 我想要一个窗口
  • 窗口标题是 hello

可以连接在一起形成一个更大的语句:

我想要一个窗口,并且窗口标题是 hello。

一系列大语句构成一个段落,一系列段落构成一个程序。

与其他编程语言不同,超新星编程语言的大多数语句都有一个描述其结构的规则,帮助用户在未来使用和记住该语句。

例如

规则:PVC 用于控制“我想要一个窗口”语句的结构

  • 规则:PVC = 代词 动词 类
  • 语句 = “我想要一个窗口”遵循 PVC 规则
  • 其中:-[我] = 代词,[想要] = 动词,[窗口] = 类

Using the Code

我有 5 个示例程序。

示例文件使用 .Nova 扩展名。

要运行这些文件,您需要超新星解释器 Nova.exe,除了交付示例之外。

它作为源代码 + 可执行文件附带,可以直接运行!!(即,使用超新星,您可以将您的应用程序作为可执行文件分发。此功能从 2010.03.30 版本开始添加)。

该语言解释器作为Microsoft-Windows的免费软件产品发布,可以从 http://sourceforge.net/projects/supernova/files 下载。

  1. Flash.nova 示例

    p1.JPG

    I want window and window title = Hello!!.
    Window back color = {5,155,255}.
    Window width = 330.  window height = 250.
    Window name = win1.
    
    I want button and button caption = Be my friend , click to say yes !!.
    The button top = 20. button width = 300.
    The button name = btn1.
    
    I want button the button top = 80.
    Button caption = . and the button name = btn2.
    
    I want button the button top = 130.
    Button caption = . and the button name = btn3.
    
    btn1 mouseclick. instructions are
        Btn2. button selected and button caption = Really !! ? .
    End of instructions
    
    btn2 mouseclick. instructions are
    Do while (True).
        Btn3. button selected and button caption = Hurrah.
        [x]. = the seconds. and do while "the seconds - [x] < (0.5)"
                        Do windows events
                    End while
        Btn3. button selected and button caption = .
        [x]. = the seconds. and do while "the seconds - [x] < (0.5)"
                        Do windows events
                    End while
    End while
    End of instructions
    
    btn3 mouseclick. instructions are
        You close window
    End of instructions
            €
  2. TheClock.nova 示例

    p4.JPG

    Application title = The Time.
    
    I want window and window title = The Time.
    window back color = {5,155,255}.
    window width = 330.  window height = 250.
    window name = win1.
    
    I want label
    The label font size = 40. and label width = 300.
    label height = 100.
    
    I want button and button caption = Close.
    the button name is btn1.
    button top = 150. and button left = 150.
    
    do while (True).
        label caption from (   ) the time.
        [x]. = the seconds. and do while the seconds - [x] < (1).
                        do windows events
                    end while
    end while
    
    btn1 mouseclick. instructions are
        You close application
    end of instructions     
  3. Delivery2.nova

    delivery.jpg

    The application title is "Delivery2"
    Set window auto show off
    Set window resize off
    
    [myarray]. = (3).
    [myarray]\(1). = (Tea).
    [myarray]\(2). = (Cafe).
    [myarray]\(3). = (Sandwich).
    
    I want window and the window title is "Delivery"
    Window width = 730. and window height = 530.
    
    I want label
    The label width is 700. and label height is 120.
    The label font size is 20.
    The label back color = white.
    The label caption is
    "
    	What do you want ?
    "
    
    I want label and label top is 140.
    label caption is Title :.
    label font name is "arial"
    label font size is "14"
    
    I want textbox
    textbox left is 80.
    textbox top is 140.
    textbox width is 500.
    textbox font name is arial.
    textbox font size is 14.
    textbox name is text1.
    
    I want listbox and listbox top is 180.
    Listbox width is 700. and listbox height is 250.
    The listbox font name is arial.
    The listbox font size is 14.
    
    [x]. = (1). and do while [x] <= [myarray].
    The listbox must add from [myarray]\[x].
    [x]. = [x] + (1).
    end while
    
    I want button and the button top is 450.
    The button left is 240. and button caption = "Ok"
    The button name is btn1.
    The button back color is white.
    
    I want button and the button top is 450.
    The button left is 360. and button caption = "Close"
    The button name is btnclose.
    The button fore color is white.
    The button back color is red.
    btnclose mouseclick. instructions are you close application ok
    
    listbox value is 1.
    
    You centre window and You show window
    
    btn1 mouseclick. instructions are
    	The listbox value to [x].
    	do if not [x] == (0).
    		"(
    			Delivery Application
    -------------------------------------------------------------------
    Date  :) thedate  (
    Time  :) thetime  (
    Month :) themonth (
    Day   :) theday   (
    Item  :---------------> ) [myarray]\[x] (
    -------------------------------------------------------------------)"
    		memory to file "(delivery.txt)"
    		execute file "delivery.txt"
    	end if
    end of instructions
    
    text1 change. instructions are
    	textbox value to [mystr].
    	[mystr]. = lower [mystr].
    	[x]. = (1).
    	do while [x] <= [myarray].
    		[myitem]. = lower [myarray]\[x].
    		[check]. = [mystr] at [myitem].
    		do if not [check] == (0).
    			listbox value from [x].
    		end if
    		[x]. = [x] + (1).
    	end while
    end of instructions
  4. COM.nova

    shot146.JPG

    I want window and the window title is COM Test.
    I want button and button caption is Open Word Application. button width = 150.
    button name = btn1.
    I want button and button caption is Hide Word.
    button name = btn2. and button left = 200.
    I want button and button caption is Show Word.
    button name = btn3. and button left = 350.
    
    procedure btn1 mouse click.
    	[myobj]. COM Object to create of type "(Word.Application)"
    	[myobj]. COM Object to use
    	"(Documents:Add)" COM method to call with parameters nothing.
    	(visible). COM Property to set (1).
    endprocedure
    
    procedure btn2 mouse click.
    	[myobj]. COM Object to use and (visible). COM Property to set (0).
    endprocedure
    
    procedure btn3 mouse click.
    	[myobj]. COM Object to use and (visible). COM Property to set (1).
    endprocedure
  5. ADODB.nova

    SHOT148.JPG

    I want window contains LISTBOX and the window title is Using ADODB.
    Window width = 600.  and WINDOW HEIGHT = 500.
    Window back color is white.
    
    Listbox width = 350. and LISTBOX HEIGHT = 450.
    Listbox back color is silver.
    Listbox fore color is Black.
    Listbox font name is arial.
    Listbox font size is 14.
    
    I want button and button caption is Test ADODB.
    Button name = btn1. and button LEFT = 400. and button width = 150.
    
    procedure btn1 mouse click.
    
    	:Note: " Connect to the Database Test.MDB"
    	[MYCON]. COM OBJECT TO CREATE OF TYPE "(ADODB.Connection)"
    	[MYCON]. COM Object to use
    	[MYARRAY]. = (1).
    	[MYARRAY]\(1)\(1). = (string).
    	[MYARRAY]\(1)\(2). = '(Provider=MSDASQL.1;Persist Security Info=False;
    	  Extended Properties="dsn=MS Access Database;
    		uid=";Initial Catalog=test.mdb)'
    	"(OPEN)" COM method to call with parameters MYARRAY.
    
    	:Note: " Open Table MainTable"
    	[MYRS]. COM OBJECT TO CREATE OF TYPE "(ADODB.Recordset)"
    	[MYRS]. COM Object to use
    	(CursorType). COM Property to set (3).
    	(LockType). COM Property to set (3).
    	(ActiveConnection). COM Property to set [MYCON].
    	[MYARRAY]. = (1).
    	[MYARRAY]\(1)\(1). = (String).
    	[MYARRAY]\(1)\(2). = '(Select * from MainTable)'
    	"(OPEN)" COM method to call with parameters MYARRAY.
    
    	:Note: " Delete All Records"
    	'(RECORDCOUNT)' COM PROPERTY TO GET [MYMAX].
    	doif [mymax] > (0).
    		[X]. = (1).
    		DoWhile [x] <= [MYMAX].
    			"(movefirst)" COM method to call with parameters .
    			"(delete)" COM method to call with parameters .
    			"(update)" COM method to call with parameters .
    			[x]. = [x] + (1).
    		endwhile
    	endif
    
    	:Note: " Add 10 Records "
    	[X]. = (1).
    	DoWhile [x] <= (10).
    		"(AddNew)" com method to call with parameters .
    		'|fields:item("Number"):value|' COM PROPERTY TO SET [x].
    		'|fields:item("Square"):value|' COM PROPERTY TO SET [x] x [x].
    		"(UPDATE)" COM method to call with parameters .
    		[x]. = [x] + (1).
    	EndWhile
    
    	:Note: " Show All Records "
    	"(movefirst)" COM method to call with parameters .
    	'(RECORDCOUNT)' COM PROPERTY TO GET [MYMAX].
    	listbox must add item --------------------------.
    	listbox must add from (Records Count = ) [MYMAX].
    	listbox must add item --------------------------.
    	listbox must add item Number 		     Square.
    	listbox must add item --------------------------.
    	[X]. = (1).
    	DoWhile [x] <= [MYMAX].
    		'|fields:item("Number"):value|' COM PROPERTY TO GET [V1].
    		'|fields:item("Square"):value|' COM PROPERTY TO GET [V2].
    		Listbox must add from [v1] (                      ) [v2].
    		"(movenext)" COM method to call with parameters .
    		[x]. = [x] + (1).
    	EndWhile
    
    	:Note: " Close Recordset"
    	"(CLOSE)" COM method to call with parameters .
    
    	:Note: " Close Connection"
    	[MYCON]. COM Object to use and "(CLOSE)" COM method to call with parameters.
    
    endprocedure

关注点

  1. 用于编写简单 Microsoft Windows 应用程序的简单编程语言
  2. 一种接近我们人类语言的编程语言
  3. 支持多语言源代码,包括英语和阿拉伯语作为起点
  4. 不区分大小写/空格/制表符/行

历史

我是超新星的创建者(为Microsoft-Windows设计的简单脚本语言),我对使用人工智能技术实现编译器感兴趣,超新星是我在这个主题上的研究成果,我于2010.03.19将其作为免费软件发布,以便来自不同国家的儿童可以将其作为学习编程的简单起点。

玩得开心!

© . All rights reserved.