Something went wrong. Try again.
AppleScript grammar for tree-sitter
applescript tree-sitter-grammar tree-sitter
Something went wrong. Try again.
1.9 kB · 113 lines
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114-- Sample AppleScript file-- Demonstrates various language features
(* Block comment Multiple lines*)
-- Propertiesproperty appName : "My Application"property version : 1.0
-- Simple handleron greet(userName) set greeting to "Hello, " & userName & "!" return greetingend greet
-- Handler with labeled parametersto calculateArea given width:w, height:h set area to w * h return areaend calculateArea
-- Variable assignmentsset x to 10set y to 20set message to "AppleScript"
-- Listsset myList to {1, 2, 3, 4, 5}set colors to {"red", "green", "blue"}
-- Recordsset person to {name:"John", age:30, city:"New York"}
-- Conditionalsif x > 5 then set result to "x is greater than 5"else if x = 5 then set result to "x equals 5"else set result to "x is less than 5"end if
-- Repeat loopsrepeat 5 times set x to x + 1end repeat
repeat with i from 1 to 10 set x to x + iend repeat
repeat with item in myList -- Process each item set x to x + itemend repeat
repeat while x < 100 set x to x * 2end repeat
-- Tell statementtell application "Finder" activate set windowCount to count of windowsend tell
-- Try-catchtry set result to x / 0on error errMsg number errNum return "Error: " & errMsgend try
-- Boolean operationsset isValid to trueset isEnabled to falseset combined to isValid and not isEnabled
-- Arithmetic operationsset sum to x + yset difference to x - yset product to x * yset quotient to x / yset power to x ^ 2
-- Comparison operationsset isEqual to x = yset isGreater to x > yset isLessOrEqual to x ≤ y
-- String operationsset fullName to "John" & " " & "Doe"
-- Containment checksif "app" is in message then return trueend if
-- Script objectscript MyScript property counter : 0
on increment() set counter to counter + 1 end increment
on getCounter() return counter end getCounterend script