Skip to content

Commit 500bb47

Browse files
authored
catch exception capture (#21)
1 parent f1e105e commit 500bb47

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

src/julia.grammar

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ simple-statement {
111111

112112
Condition { expr _t? }
113113
ElseIfClause { kw<'elseif'> Condition block? }
114-
CatchClause { kw<'catch'> block? } // TODO: ExceptionCapture
114+
CatchClause { kw<'catch'> ExceptionCapture { !simple Identifier }? block? }
115115
ElseClause { kw<'else'> block? }
116116
FinallyClause{ kw<'finally'> block? }
117117

test/statements.txt

+57-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ if true 1 else 0 end
219219

220220
if a
221221
b()
222-
elseif c
222+
elseif c
223223
d()
224224
d()
225225
else
@@ -280,6 +280,16 @@ finally
280280
close(resource)
281281
end
282282

283+
try
284+
catch e
285+
e
286+
end
287+
288+
try catch e e end
289+
try catch e end
290+
try catch end
291+
try finally end
292+
283293
==>
284294
Program(
285295
TryStatement(
@@ -300,6 +310,52 @@ Program(
300310
)
301311
end
302312
)
313+
TryStatement(
314+
try
315+
CatchClause(
316+
catch
317+
ExceptionCapture(Identifier)
318+
Identifier
319+
)
320+
end
321+
)
322+
323+
TryStatement(
324+
try
325+
CatchClause(
326+
catch
327+
ExceptionCapture(Identifier)
328+
Identifier
329+
)
330+
end
331+
)
332+
333+
TryStatement(
334+
try
335+
CatchClause(
336+
catch
337+
ExceptionCapture(Identifier)
338+
)
339+
end
340+
)
341+
342+
TryStatement(
343+
try
344+
CatchClause(
345+
catch
346+
)
347+
end
348+
)
349+
350+
TryStatement(
351+
try
352+
FinallyClause(
353+
finally
354+
)
355+
end
356+
)
357+
358+
303359
)
304360

305361

0 commit comments

Comments
 (0)