Coder Social home page Coder Social logo

ault's People

Contributors

mattdiesel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ault's Issues

Enums parsing & deparsing

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".

Nested properties bug

There's a bug when parsing nested object properties

$objClassDictionary.Add($objClass.Path_.Class)

Parsing error

Hi Matt

Local $oShellWindows = $oShell.windows

throws an error "Invalid character '.'"

Static variables declaration

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

Properties settings

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

Array parsing

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

Case xxx To zzz

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

Object properties assignment bug and WITH bug

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

Array in Array

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) ;)

Ternary operator

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.