Sign in to follow this  
Followers 0
twitchyliquid64

Experimental (Academic) AutoIT Script Interpreter [C++]

23 posts in this topic

The point is not to not use stacks.

Also, inb4 pratt parser.

It does use a THE stack, as it relies heavily on recursion :) I did write a non recursive version using a stack for assembly as well. I guess what you mean to say is that it is better to not maintain a stack explicitly.

However, since all AutoIt statements have signal tokens (e.g. there is some unique token at the start of every statement: switch, select, while, for, do, func...), A predictive parser is probably the right way to go. Pratt's is more suited to maths expressions, its main strength being resolving ambiguity easily, allowing it to be easily extended.

Reading through my textbook now, most of the algorithms are stack and table driven (or recursive descent). I definitely think you could do better than having two separate parsers though. That does not make much sense.

Share this post


Link to post
Share on other sites



It does use a THE stack, as it relies heavily on recursion :) I did write a non recursive version using a stack for assembly as well. I guess what you mean to say is that it is better to not maintain a stack explicitly.

I didn't mean to say better or worse, really. My "The point is not to not use stacks" was aimed at the fact that because of the usage of recursion to drive the algorithm you are using a stack anyway. You can't really do without a stack (or table as you said).

I agree with the rest of your post. Didn't read his code so wouldn't know about two parsers, but I can see the merit in two parsing strategies. If you use a method where you parse BNF and produce a parser that way, you are using two parsers. But again I say, I didn't read his code.

Share this post


Link to post
Share on other sites

I didn't mean to say better or worse, really. My "The point is not to not use stacks" was aimed at the fact that because of the usage of recursion to drive the algorithm you are using a stack anyway. You can't really do without a stack (or table as you said).

Ah right, I misread your post. I guess when you are talking about C++, the standard does not define HOW the function call stack should be implement it... It could be a singly linked list quite easily (linked backwards though) so then it wouldn't be a stack at all, so I guess when you are writing in a language that deals with a standard rather than a platform it is not quite right to say recursion uses a stack. Then again, I have never read the standard, I am guessing that they standardise behaviour not implementation.

I agree with the rest of your post. Didn't read his code so wouldn't know about two parsers, but I can see the merit in two parsing strategies. If you use a method where you parse BNF and produce a parser that way, you are using two parsers. But again I say, I didn't read his code.

I didn't either, but he said he was using:

-Stateful Recursive Decent Parser

-Shunting yard algorithm for expression evaluation

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • ralph_ng
      How to append data (random) in Excel?
      By ralph_ng
      Hi everybody, I'm newbie to learn AutoIt, need some help... The process/ work that I'd like to automate is just for testing purpose for my job.
      Searching high and low, I found no script example for writing any random data into excel file. 
    • Valnurat
      Several small issues
      By Valnurat
      I have put all my small issues into one thread hope that is fine.
      I have GUI with many GUICtrlCreateInput and it's working ok.
       
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=x86\Create Consultant.Exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <AD.au3> #include <Array.au3> Main() Func Main() _AD_Open() If @error Then Exit MsgBox(0x40010, "ERROR", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended) Local $sUsername = InputBox('OPTIONAL', 'Please enter the username.' & @CRLF & @CRLF & 'Exampel: '& @UserName) If @error = 1 Then Exit If $sUsername <> "" Then Local $sFQDN = _AD_SamAccountNameToFQDN($sUsername) if @error = 1 Then MsgBox(64, "Info", "User '" & $sUsername & "' does not exist") Exit EndIf ; MsgBox(64, "Info", "User '" & $sFQDN & @CRLF & _AD_GetObjectAttribute($sFQDN, 'department')) EndIf ; MsgBox(64, "Info", "User '" & $sFQDN & @CRLF & _AD_GetManager($sFQDN, 'department')) local $aObj = _AD_GetObjectsInOU("OU=Users,OU=so,OU=dk,OU=company,DC=AD,DC=company,DC=ORG","(&(objectclass=person)(sAMAccountName=" & $sUsername & "))",2,"department,physicalDeliveryOfficeName,company", "") _ArrayDisplay($aObj) _ArrayDelete($aObj,0) ; Create a GUI with various controls. Local $hGUI = GUICreate("Create Consultant") GUICtrlCreateLabel("First name:", 10, 13) Local $idFirst = GUICtrlCreateInput("", 90, 10, 150, 20) GUICtrlCreateLabel("Shortname:", 245, 13) Local $idShort = GUICtrlCreateInput("", 300, 10, 90, 20) GUICtrlCreateLabel("Last name:", 10, 43) Local $idLast = GUICtrlCreateInput("", 90, 40, 300, 20) GUICtrlCreateLabel("Display name:", 10, 73) Local $idDisplay = GUICtrlCreateInput("", 90, 70, 300, 20) GUICtrlCreateLabel("Description:", 10, 103) Local $idRadio1 = GUICtrlCreateRadio("Consultant", 90, 100) Local $idRadio2 = GUICtrlCreateRadio("Group Account", 190, 100) GUICtrlCreateLabel("Email:", 10, 133) Local $idEmail = GUICtrlCreateInput("", 90, 130, 300, 20) GUICtrlCreateLabel("Department:", 10, 163) If $sUsername <> "" Then Local $idDepart = GUICtrlCreateInput($aObj[0][0], 90, 160, 300, 20) Else Local $idDepart = GUICtrlCreateInput("", 90, 160, 300, 20) EndIf GUICtrlCreateLabel("Office:", 10, 193) If $sUsername <> "" Then Local $idOffice = GUICtrlCreateInput($aObj[0][1], 90, 190, 80, 20) Else Local $idOffice = GUICtrlCreateInput("", 90, 190, 80, 20) EndIf Local $idCheckBox = GUICtrlCreateCheckbox("End date", 330, 190, 80, 20) Local $idDate = GUICtrlCreateDate("", 200, 190, 120, 20) GUICtrlSetState($idDate,$gui_disable) GUICtrlCreateLabel("Manager:", 10, 223) Local $idComboBox = GUICtrlCreateCombo("", 90, 220, 150, 100) GUICtrlCreateLabel("Misal code:", 245, 223) If $sUsername <> "" Then Local $idMisalCode = GUICtrlCreateInput($aObj[0][2], 310, 220, 80, 20) Else Local $idMisalCode = GUICtrlCreateInput("", 310, 220, 80, 20) EndIf GUICtrlCreateLabel("Ticket no.:", 10, 253) Local $idTicketNo = GUICtrlCreateInput("", 90, 250, 150, 20) GUICtrlCreateLabel("Cost no.:", 245, 253) Local $idCostNo = GUICtrlCreateInput("", 290, 250, 100, 20) GUICtrlCreateLabel("Ext. Company:", 10, 283) Local $idExtComp = GUICtrlCreateInput("", 90, 280, 300, 20) GUICtrlCreateGroup("Optional, if no Email", 10, 310, 380, 55) GUICtrlCreateLabel("Ext. Email:", 20, 333) Local $idExtEmail = GUICtrlCreateInput("", 90, 330, 290, 20) local $aObject = _AD_GetObjectsInOU("OU=Users,OU=so,OU=dk,OU=company,DC=AD,DC=company,DC=ORG","(&(objectclass=person)(StaffManager=TRUE))",2,"sAMAccountName,distinguishedName,displayname", "displayname") ; _ArrayDisplay($aObject,"") If IsArray($aObject) Then Local $sFill = "" For $i = 1 To $aObject[0][0] $sFill &= $aObject[$i][2] & "|" Next $sFill = StringTrimRight($sFill,1) ; Add additional items to the combobox. GUICtrlSetData($idComboBox, $sFill, "") EndIf Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idOK MsgBox($MB_SYSTEMMODAL, "", "test") Global $sFirst = GUICtrlRead($idFirst) Global $sShort = GUICtrlRead($idShort) Global $sLast = GUICtrlRead($idLast) Global $sDisp = GUICtrlRead($idDisplay) If GUICtrlRead($idRadio1) = $GUI_CHECKED Then MsgBox($MB_SYSTEMMODAL, "test", "Consultants") EndIf Global $sEmail = GUICtrlRead($idEmail) Global $sDepart = GUICtrlRead($idDepart) Global $sOffice = GUICtrlRead($idOffice) Global $sManager = GUICtrlRead($idComboBox) If $sManager <> "" Then MsgBox($MB_SYSTEMMODAL, "test", $sManager) EndIf Global $sMisalCode = GUICtrlRead($idMisalCode) Global $sTicketNo = GUICtrlRead($idTicketNo) Global $sCostNo = GUICtrlRead($idCostNo) Global $sExtCompe = GUICtrlRead($idExtComp) Global $sExtEmail = GUICtrlRead($idExtEmail) ExitLoop Case $idCheckBox If _IsChecked($idCheckbox) Then GUICtrlSetState($idDate,$gui_enable) Else GUICtrlSetState($idDate,$gui_disable) EndIf EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) ; Create a new user #cs Global $iValue = _AD_CreateUser($sOU, $sShort, "Doe John") If $iValue = 1 Then MsgBox(64, "Active Directory Functions - Example 1", "User '" & $sUser & "' in OU '" & $sOU & "' successfully created") ElseIf @error = 1 Then MsgBox(64, "Active Directory Functions - Example 1", "User '" & $sUser & "' already exists") ElseIf @error = 2 Then MsgBox(64, "Active Directory Functions - Example 1", "OU '" & $sOU & "' does not exist") ElseIf @error = 3 Then MsgBox(64, "Active Directory Functions - Example 1", "Value for CN (e.g. Lastname Firstname) is missing") ElseIf @error = 4 Then MsgBox(64, "Active Directory Functions - Example 1", "Value for $sAD_User is missing") Else MsgBox(64, "Active Directory Functions - Example 1", "Return code '" & @error & "' from Active Directory") #ce EndIf _AD_Close() EndFunc Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked Now I have to read all GUICtrlCreateInput and I want to be sure that all GUICtrlCreateInput is filled. Do I have to this for all of them:
      Global $sManager = GUICtrlRead($idComboBox) If $sManager <> "" Then MsgBox($MB_SYSTEMMODAL, "test", $sManager) Global $bManager = True EndIf Or is there a nice way of controlling that they all are filled out?
      And how can I be in the loop until all fields are filled out?
       
      I also have 2 radiobuttons. 1 with text "Consultants" and 1 with "Group account".
      How do I get the text from the 1 that's active? I tried this and it's working, but is there another way?
      If GUICtrlRead($idRadio1) = $GUI_CHECKED Then MsgBox($MB_SYSTEMMODAL, "test", "Consultants") EndIf  
    • killertone
      ControlSend Messing up the string
      By killertone
      Greetings!
      I have been trying to get send to this textarea on a website a message through ControlSend because _IEFormElementSetValue doesnt work on it, so i get the hwnd of the IE window then do the ControlSend to the window, and the message it sends doesnt type some of the letters.
      The textarea
      <textarea style="overflow:hidden;height:undefinedpx;" class="form-control input-sm" placeholder="Add a comment" rows="1" data-reactid=".0.3.2.1.2.0.$view.8.1.0.0.1"></textarea> How im getting the textarea:
      $comment_area = _IETagNameGetCollection($oIE,"textarea") for $element in $comment_area if $element.placeholder = "Add a comment" Then _IEAction($element,"focus") Sleep(1500) ;_IEFormElementSetValue($element,$comment_list[$random_index]) ;_IEFormSubmit($element) ControlSend($hIE,"","[CLASS:Internet Explorer_Server; INSTANCE:1]",$comment_list[$random_index],1) ;Send("{ENTER}") Sleep(3000) ;Hacer que sea random EndIf Next When i use _IEFormElementSetValue  it changes the text on the box, but it doesn't change the value or something because when i send an Enter key it doesn't submit the message (I Also tried _IEFormSubmit)
      With ControlSend it does send it but corrupted, for example: Message: Pretty nice Result: ety nice
      Also i know the element is the actual one im referring because if i use _IEAction($element,"focus") it focuses the one i want.
      Any help appreciated!
    • khathiatz
      UninstallMe - Automatically destroy script
      By khathiatz
      UninstallMe will automatically destroy script running
      - With example files
      - Automatic, using file BAT and VBS to destroy, no GUI
       
       
      English: https://khathiatz.blogspot.com/2016/08/uninstall-me-en.html
      Tiếng Việt: https://khathiatz.blogspot.com/2016/07/uninstall-me.html
       
    • Valnurat
      How do I add content to a ComboBox from an AD attribute?
      By Valnurat
      Hi.
      Can someone help me with some code to get info from AD and into a ComboBox. I'm using this UDF:
      How do you get AD user object with the StaffManager attributes = True? I think I have to use:
      _AD_GetObjectsInOU($sOU[, $sFilter = "(name=*)"[, $iSearchScope = 2[, $sDataToRetrieve =  "sAMAccountName"[, $sSortBy = "sAMAccountName"[, $bCount = False[, $vReturnNull = True]]]]])
      but I don't know how.