#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=totiny.ico #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include #include #include #include const $g__symbol_eof = 0 ; (eof) const $g__symbol_error = 1 ; (error) const $g__symbol_whitespace = 2 ; whitespace const $g__symbol_eq = 3 ; ;=; const $g__symbol_id = 4 ; id const $g__symbol_msg = 5 ; msg const $g__symbol_thing = 6 ; thing const $g__symbol_program = 7 ; const $g__symbol_stms = 8 ; const $g__rule_program = 0 ; ::= const $g__rule_program2 = 1 ; ::= const $g__rule_stms_id_eq_thing = 2 ; ::= id ;=; thing const $g__rule_stms_msg_id = 3 ; ::= msg id const $g__gpmsgaccept = 3 const $g__gpmsgcommentblockread = 9 const $g__gpmsgcommenterror = 7 const $g__gpmsgcommentlineread = 10 const $g__gpmsginternalerror = 8 const $g__gpmsglexicalerror = 5 const $g__gpmsgnotloadederror = 4 const $g__gpmsgreduction = 2 const $g__gpmsgsyntaxerror = 6 const $g__gpmsgtokenread = 1 Global $sdir = @ScriptDir & "\" Global $oparser = ObjCreate("goldparserengine.goldparser") with $oparser .loadcompiledgrammar($sdir & "TOTINY.cgt") .trimreductions = true ;please read about this feature before enabling EndWith Global $ovar = ObjCreate("scripting.dictionary") $ovar.CompareMode = 1 Global $hForm = GUICreate("TOTINY INTERPRETER!", 221, 171, -1, -1) Global $idEdit = GUICtrlCreateEdit("", 10, 10, 131, 151, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL)) GUICtrlSetData(-1, StringFormat("version = 1\r\nmsg version")) GUICtrlSetFont(-1, 10, 800, 0, "consolas") GUICtrlSetColor(-1, 0x00FF00) GUICtrlSetBkColor(-1, 0x464646) GUICtrlSetCursor (-1, 5) Global $idrun = GUICtrlCreateButton("RUN", 150, 10, 61, 31) Global $idclose = GUICtrlCreateButton("CLOSE", 150, 130, 61, 31) Global $idclean = GUICtrlCreateButton("CLEAN", 150, 50, 61, 31) GUISetState(@SW_SHOW) global $stest While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE,$idclose Exit Case $idrun $stest = GUICtrlRead($idEdit) If Not $stest = '' Then parser_run($stest) Case $idclean GUICtrlSetData($idEdit,'') EndSwitch WEnd Func parser_run($sinput) Local $bdone = false Local $iresponse $oparser.OpenTextString($sinput) Do $iresponse = $oparser.parse() Switch $iresponse Case $g__gpmsglexicalerror, $g__gpmsgsyntaxerror MsgBox(16,'error',"token error") $bdone = True Case $g__gpmsginternalerror, $g__gpmsgnotloadederror MsgBox(16,'error',"can't load") $bdone = True Case $g__gpmsgaccept $bdone = True case $g__gpmsgreduction with $oparser.currentreduction Switch .parentrule.tableindex Case $g__rule_stms_id_eq_thing Local $sname = .tokens(0).data Local $svalue = .tokens(2).data $ovar.add($sname, $svalue) Case $g__rule_stms_msg_id Local $smsg = .tokens(1).data msgbox(0,'totiny',$ovar($smsg)) EndSwitch EndWith EndSwitch Until $bdone EndFunc