Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catch exception capture #21

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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? }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did I use simple correctly here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if that solves the parsing conflict it's probably fine.

IIRC !simple is used to ensure return a, b is parsed (return (tuple a b)) and not (tuple (return a) b).

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
Loading