@@ -7,7 +7,7 @@ end preOpenStack
77
88on mouseUp
99 if the short name of the target is "Generate Snippets" then
10-
10+
1111 # functions
1212 set the folder to specialFolderPath ("home" ) & "/livecode/docs/dictionary/function"
1313 put quote & ".source.livecodescript" & quote & ":" & cr into theSnippets
@@ -18,21 +18,21 @@ on mouseUp
1818 delete word 1 of theSyntax
1919 replace "[" with empty in theSyntax
2020 replace "]" with empty in theSyntax
21-
21+
2222 -- parameters
2323 put empty into theFunctionName
2424 put empty into theParameters
2525 if theSyntax contains "(" then
2626 get MatchText (theSyntax ,"(?i)^(.*)\((.*)\)" ,theFunctionName ,theParameters )
27-
27+
2828 if theParameters is empty then
2929 next repeat
3030 end if
31-
31+
3232 put theFunctionName into thePrefix
33-
33+
3434 put theFunctionName & "(" into theBody
35-
35+
3636 if theParameters is not empty then
3737 replace "<" with "" in theParameters
3838 replace ">" with "" in theParameters
@@ -46,11 +46,11 @@ on mouseUp
4646 else
4747 put ")" after theBody
4848 end if
49-
49+
5050 AddSnippet theSnippets , theFunctionName , theFunctionName , theBody
51-
51+
5252 else
53-
53+
5454 if theSyntax contains "of" then
5555 put word 2 to - 4 of theSyntax into theOptions
5656 put word - 3 of theSyntax into theFunctionName
@@ -63,7 +63,7 @@ on mouseUp
6363 put word 2 to - 2 of theSyntax into theOptions
6464 put word - 1 of theSyntax into theFunctionName
6565 end if
66-
66+
6767 if theOptions contains "|" then
6868 split theOptions with "|"
6969 repeat with theIndex = 1 to the number of elements of theOptions
@@ -83,7 +83,7 @@ on mouseUp
8383 end repeat
8484 end repeat
8585 put theSnippets into url ("binfile:" & specialFolderPath ("home" )& "/atom-language-livecode/snippets/functions.cson" )
86-
86+
8787 # messages
8888 set the folder to specialFolderPath ("home" ) & "/livecode/docs/dictionary/message"
8989 put quote & ".source.livecodescript" & quote & ":" & cr into theSnippets
@@ -100,7 +100,7 @@ on mouseUp
100100 split theParameters by comma
101101 repeat with theIndex = 1 to the number of elements of theParameters
102102 if theParameters [theIndex ] contains "|" then
103- -- unfortunately some of the syntax definitions describe a set of possible values
103+ -- unfortunately some of the syntax definitions describe a set of possible values
104104 -- or parameter types and this simplifies things considerably...
105105 put "Value" into theParameter
106106 else
@@ -112,13 +112,13 @@ on mouseUp
112112 if the last char of theSyntax is comma then
113113 delete the last char of theSyntax
114114 end if
115-
115+
116116 put theSyntax & cr & tab & "${1:/* code */ }" & cr & "end" && theMessageName into theBody
117117 AddSnippet theSnippets , theMessageName & " ... end " & theMessageName , theMessageName , theBody
118118 end repeat
119119 end repeat
120120 put theSnippets into url ("binfile:" & specialFolderPath ("home" )& "/atom-language-livecode/snippets/messages.cson" )
121-
121+
122122 # commands
123123 set the folder to specialFolderPath ("home" ) & "/livecode/docs/dictionary/command"
124124 put quote & ".source.livecodescript" & quote & ":" & cr into theSnippets
@@ -137,7 +137,7 @@ on mouseUp
137137 replace ">" with "" in theSyntax
138138 put word 1 to 3 of theSyntax into thePrefix
139139 replace space with empty in thePrefix
140-
140+
141141 split theParameters with "<"
142142 repeat with theIndex = 1 to the number of elements of theParameters
143143 if theIndex is 1 then
@@ -152,8 +152,8 @@ on mouseUp
152152 end repeat
153153 end repeat
154154 put theSnippets into url ("binfile:" & specialFolderPath ("home" )& "/atom-language-livecode/snippets/commands.cson" )
155-
156-
155+
156+
157157 end if
158158end mouseUp
159159
@@ -194,7 +194,7 @@ function ParseOptionalSyntax pSyntaxDefinition
194194 end if
195195 end if
196196 end repeat
197-
197+
198198 if foundEndChar <> 0 then
199199 -- we found some optional syntax so we need to split the syntax defintion into two
200200 put pSyntaxDefinition into theOption1
@@ -207,22 +207,22 @@ function ParseOptionalSyntax pSyntaxDefinition
207207 return theOption1 & cr & theOption2
208208 end if
209209 end if
210-
210+
211211 return pSyntaxDefinition
212212end ParseOptionalSyntax
213213
214214function ParseVariationSyntax pSyntaxDefinition
215215 put 0 into foundStartChar
216216 put 0 into foundEndChar
217-
217+
218218 put offset ("{" ,pSyntaxDefinition ,foundStartChar) into foundStartChar
219219 if foundStartChar <> 0 then
220220 put offset ("}" ,pSyntaxDefinition ,foundEndChar) into foundEndChar
221221 if foundEndChar = 0 then
222222 exit repeat
223223 end if
224224 put char foundStartChar+ 1 to foundEndChar- 1 of pSyntaxDefinition into theVariations
225-
225+
226226 if foundEndChar <> 0 then
227227 -- we found an array of variable syntax
228228 set the itemDelimiter to "|"
@@ -240,7 +240,7 @@ end ParseVariationSyntax
240240function ParseCommandSyntaxDefinition pSyntaxDefinition
241241 local theSyntaxes
242242 replace "..." with "" in pSyntaxDefinition
243-
243+
244244 put ParseOptionalSyntax(pSyntaxDefinition ) into theSyntaxes
245245 repeat for each line theSyntax in theSyntaxes
246246 put ParseVariationSyntax(theSyntax ) & cr after theParsedSyntaxes
@@ -249,37 +249,19 @@ function ParseCommandSyntaxDefinition pSyntaxDefinition
249249end ParseCommandSyntaxDefinition
250250
251251command AddSnippet @pSnippets, pName, pPrefix, pBody
252- replace quote with "\" & quote in pBody
253-
252+ replace quote with "\" & quote in pBody
253+
254254 if the number of lines of pBody > 1 then
255255 put "'''" & cr before pBody
256256 put cr & "'''" after pBody
257-
257+
258258 repeat with theIndex = 2 to the number of lines of pBody
259259 put tab & tab before line theIndex of pBody
260260 end repeat
261261 else
262262 put "'" & pBody & "'" into pBody
263263 end if
264-
264+
265265 put tab & "'" & pName & "'" & ":" & cr & tab & tab & "prefix: " & "'" & pPrefix & \
266266 "'" & cr & tab & tab & "body: " & pBody & cr after pSnippets
267267end AddSnippet
268-
269- function RecurseSyntax pArray
270- if pArray is not an array then
271- return pArray
272- else
273- p
274- put RecurseSyntax(pArray [1 ]) into theParentSyntaxes
275- repeat with X = 2 to the number of elements of pArray
276- put RecurseSyntax(pArray [X]) into theChildSyntaxes
277- repeat for each line theParentSyntax in theParentSyntaxes
278- repeat for each line theChildSyntax in theChildSyntaxes
279- put theParentSyntax & theChildSyntax & cr after theSyntaxes
280- end repeat
281- end repeat
282- end repeat
283- end if
284- return theSyntaxes
285- end RecurseSyntax
0 commit comments