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

Optional first element (PL/SQL DECLARE) #381

Open
KDASthenerd opened this issue Feb 27, 2025 · 0 comments
Open

Optional first element (PL/SQL DECLARE) #381

KDASthenerd opened this issue Feb 27, 2025 · 0 comments

Comments

@KDASthenerd
Copy link

When working with PL/SQL, There is a BEGIN - END block, and it can have an EXCEPTION section in the middle (optional). So far, this is possible with \<begin\>:\<exception\>:\<end\>.

The problem arises when I try to implement the DECLARE section (declaration section for a begin-end block). It's optional, so the complete scenario goes like "[DECLARE] - BEGIN - [EXCEPTION] - END".

I imagine it would look like this: \<declare\>:\<begin\>:^\s*\<exception\>:\<end\> (^\s* to avoid matching the declaration of an exception).

This works perfectly for the complete scenario, but as soon as the cursor leaves declare, it is ignored (% cycles through begin, exception and end only).

I've tried both settings at once, one before the other, and the other way around, but none worked for me.

I'd like to know if there's a way to set up an optional first element for matching (as of current version), or if it's possible to implement it somehow.

I saw a similar issue regarding an optional last element, and I understand that there are possible limitations for this.

Here's how I've tried

Scenario 1: begin before declare

\<begin\>:^\s*\<exception\>:\<end\>,
\<declare\>:\<begin\>:^\s*\<exception\>:\<end\>,

Cursor at DECLARE, all matches are highlighted
Image

Type % to go to next match. DECLARE is no longer highlighted, and % no longer cycles through it.
Image

Scenario 2: declare before begin

\<declare\>:\<begin\>:^\s*\<exception\>:\<end\>,
\<begin\>:^\s*\<exception\>:\<end\>,

The complete text works fine
Image

With the DECLARE section commented/omited, the match no longer works
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant