mattdiesel / ault Goto Github PK
View Code? Open in Web Editor NEWAutoIt Language Tools
AutoIt Language Tools
There is a problem with parsing & deparsing enumerations, example from the help file:
#include <MsgBoxConstants.au3>
Example()
Func Example()
; These variables will enumerate from 0 to 2.
Local Enum $eVar1, $eVar2, $eVar3
MsgBox($MB_SYSTEMMODAL, "", "$eVar1 is equal to (0): " & $eVar1 & @CRLF & _
"$eVar2 is equal to (1): " & $eVar2 & @CRLF & _
"$eVar3 is equal to (2): " & $eVar3 & @CRLF)
; These variables will enumerate from 1 to 2 and then $eVariant3 is set to 5 which will continue to
; increment by 1.
Local Enum $eVariant1 = 1, $eVariant2, $eVariant3 = 5, $eVariant4
MsgBox($MB_SYSTEMMODAL, "", "$eVariant1 is equal to (1): " & $eVariant1 & @CRLF & _
"$eVariant2 is equal to (2): " & $eVariant2 & @CRLF & _
"$eVariant3 is equal to (5): " & $eVariant3 & @CRLF & _
"$eVariant3 is equal to (6): " & $eVariant4 & @CRLF)
; Multiply each enumeration by 2.
Local Enum Step *2 $eFoo1, $eFoo2, $eFoo3, $eFoo4
MsgBox($MB_SYSTEMMODAL, "", "$eFoo1 is equal to (1): " & $eFoo1 & @CRLF & _
"$eFoo2 is equal to (2): " & $eFoo2 & @CRLF & _
"$eFoo3 is equal to (4): " & $eFoo3 & @CRLF & _
"$eFoo3 is equal to (8): " & $eFoo4 & @CRLF)
EndFunc ;==>Example
I took the first enumeration and tried to parse it:
Local Enum $eVar1, $eVar2, $eVar3
it parsed fine, but to single declarations and so it was deparsed back to:
$eFoo1
$eFoo2
$eFoo3
$eFoo4
This is clearly wrong, because it's not valid syntax and throws expected error "Expected function call or assignment".
Example:
$objWMIService.SubclassesOf()
There's a bug when parsing nested object properties
$objClassDictionary.Add($objClass.Path_.Class)
Hi Matt
Local $oShellWindows = $oShell.windows
throws an error "Invalid character '.'"
Enumeration parsing is still broken despite your patches. I've add comment to your commit about this.
Hello,
Small example;
Dim $Variable[] = [StringToBinary("123"), StringToBinary("123")]
I will add a pull request when I am done fully understanding your code and try to fix the issues
There's a bug in Static variables declaration, they are deparsed back to Const values
Source script:
#include <Timers.au3>
$hWnd = GUICreate("random GUI")
GUISetState()
_Timer_SetTimer($hWnd, 300, "_MyTimerCallback")
Do
Until GUIGetMsg() = -3
Func _MyTimerCallback($hWnd, $Msg, $iIDTimer, $dwTime)
Static $i = 1
$i += 1
If $i > 5 Then _Timer_KillTimer($hWnd, $iIDTimer)
MsgBox(0, "Hey", "It worked.")
EndFunc
Deparsed script:
#include <Timers.au3>
$hWnd = GUICreate("random GUI")
GUISetState()
_Timer_SetTimer($hWnd, 300, "_MyTimerCallback")
Do
Until GUIGetMsg() = -3
Func _MyTimerCallback($hWnd, $Msg, $iIDTimer, $dwTime)
Const $i = 1
$i += 1
If $i > 5 Then
_Timer_KillTimer($hWnd, $iIDTimer)
EndIf
MsgBox(0, "Hey", "It worked.")
EndFunc
Property settings
Func Speak($Text, $Rate, $Vol)
$voice.Rate = $Rate
$voice.Volume = $Vol
$voice.Speak ($Text)
EndFunc ;==>Speak
Error:
"e-properties.au3" (2:11) : ==> Expected function call or assignment.:
$voice.Rate = $Rate
$voice^ ERROR
All in the title, it just fails, everywhere
Another code example form AutoIt help file that breaks the parser
#include <MsgBoxConstants.au3>
Example()
Func Example()
; Using an Array
Local $aArray[4]
$aArray[0] = "a"
$aArray[1] = 0
$aArray[2] = 1.3434
$aArray[3] = "test"
Local $sString = ""
For $vElement In $aArray
$sString = $sString & $vElement & @CRLF
Next
EndFunc ;==>Example
Deparser generates:
#include <MsgBoxConstants.au3>
Example()
Func Example()
Local $aArray[4]
???
???
???
???
Local $sString = ""
???
EndFunc
Example:
#cs
#cs
#ce
bug ;this is parsed, but it's between the inner #cs block
#ce
$a = 1
Don't be angry Matt, it's from official language specification:
#include <MsgBoxConstants.au3>
Local $sMsg = ""
Switch @HOUR
Case 6 To 11
$sMsg = "Good Morning"
Case 12 To 17
$sMsg = "Good Afternoon"
Case 18 To 21
$sMsg = "Good Evening"
Case Else
$sMsg = "What are you still doing up?"
EndSwitch
MsgBox($MB_SYSTEMMODAL, "", $sMsg)
And another:
#include <MsgBoxConstants.au3>
Example()
Func Example()
Local $sName = InputBox("", "Please enter a word.", "", " M", Default, Default, Default, Default, 10)
Local $sMsg = ""
Switch @error
Case 2
$sMsg = "Timeout "
ContinueCase
Case 1 ; Continuing previous case
$sMsg &= "Cancellation"
Case 0
Switch $sName
Case "a", "e", "i", "o", "u"
$sMsg = "Vowel"
Case "QP"
$sMsg = "Mathematics"
Case "Q" To "QZ"
$sMsg = "Science"
Case Else
$sMsg = "Others"
EndSwitch
Case Else
$sMsg = "Something went horribly wrong."
EndSwitch
MsgBox($MB_SYSTEMMODAL, "", $sMsg)
EndFunc ;==>Example
Both throws an unknown error
I'm testing right now everything I can find (from the official help file)
Local $oExcel = ObjCreate("Excel.Application")
$oExcel.visible = 1
$oExcel.workbooks.add
With $oExcel.activesheet
.cells(2, 2).value = 1
.range("A1:B2").clear
EndWith
$oExcel.quit
It throws error:
"e8.au3" (2:8) : ==> Expected function call or assignment.:
$oExcel.visible = 1
$oExcel^ ERROR
And another associated bug, I've commented out the assignments:
Local $oExcel = ObjCreate("Excel.Application")
;$oExcel.visible = 1
;$oExcel.workbooks.add
With $oExcel.activesheet
.cells(2, 2).value = 1
.range("A1:B2").clear
EndWith
$oExcel.quit
And now it throws:
"e8.au3" (5:1) : ==> Keyword 'With' not valid at the start of a line.:
With $oExcel.activesheet
^ ERROR
Another bug from some examples
Local $aArray_1[1] = ["Data_0"], $iBegin
It's parsed back to
Local $aArray_1[1] = ["Data_0"]
Local $iBegin
AutoIt is full of surprises (wish it wouldn't) ;)
Hi Matt, I've found another small bug, ternary operator is not supported, sample scripts:
$a = 1
$b = 2
$c = $a > 1 ? $a : $b
ConsoleWrite($c)
#include <MsgBoxConstants.au3>
Example()
Func Example()
; Assign a Local variable an array containing the numbers.
Local $aNumber[8] = [4.8, 4.5, 4.3, 4, -4.8, -4.5, -4.3, -4]
; Assign a Local variable a string which will contain the results.
Local $sResults = ""
; Loop through the array: calculate the ceiling and format the result.
For $i = 0 To 7
$sResults &= "Ceiling(" & $aNumber[$i] & ") = " & Ceiling($aNumber[$i]) & @CRLF & ($i = 3 ? @CRLF : "")
Next
; Display the results.
MsgBox($MB_SYSTEMMODAL, "", $sResults)
EndFunc ;==>Example
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.