Skip to content

Commit

Permalink
catch exception capture (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp authored Jan 17, 2025
1 parent f1e105e commit 500bb47
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/julia.grammar
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ simple-statement {

Condition { expr _t? }
ElseIfClause { kw<'elseif'> Condition block? }
CatchClause { kw<'catch'> block? } // TODO: ExceptionCapture
CatchClause { kw<'catch'> ExceptionCapture { !simple Identifier }? block? }
ElseClause { kw<'else'> block? }
FinallyClause{ kw<'finally'> block? }

Expand Down
58 changes: 57 additions & 1 deletion test/statements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ if true 1 else 0 end

if a
b()
elseif c
elseif c
d()
d()
else
Expand Down Expand Up @@ -280,6 +280,16 @@ finally
close(resource)
end

try
catch e
e
end

try catch e e end
try catch e end
try catch end
try finally end

==>
Program(
TryStatement(
Expand All @@ -300,6 +310,52 @@ Program(
)
end
)
TryStatement(
try
CatchClause(
catch
ExceptionCapture(Identifier)
Identifier
)
end
)

TryStatement(
try
CatchClause(
catch
ExceptionCapture(Identifier)
Identifier
)
end
)

TryStatement(
try
CatchClause(
catch
ExceptionCapture(Identifier)
)
end
)

TryStatement(
try
CatchClause(
catch
)
end
)

TryStatement(
try
FinallyClause(
finally
)
end
)


)


Expand Down

0 comments on commit 500bb47

Please sign in to comment.