Skip to content

VB parser updates: no sentinel strings, better directives, better attributes#603

Merged
maciejpirog merged 4 commits intomainfrom
mpir/vb-parser-updates
Mar 5, 2026
Merged

VB parser updates: no sentinel strings, better directives, better attributes#603
maciejpirog merged 4 commits intomainfrom
mpir/vb-parser-updates

Conversation

@maciejpirog
Copy link
Contributor

@maciejpirog maciejpirog commented Mar 3, 2026

No sentinel strings

Before, we used sentinel strings like <PUNCTUATION> to match a particular kind of token. We now simply compare the token kind constructors via separate functions that consume particular kinds of tokens.

Preprocessing directives

Before: We kept only the "then" branch of #If ... #Else ... #End If. The new approach is slightly more clever

First, we make preprocessor directives ghost tokens, so in general they are ignored unless explicitly asked for. They are ignored en masse, which means all the code between #Else or #ElseIf and #End If is ignored, and so the original semantics still applies, unless the directive is explicitly asked for in a parsing rule.

The directive is asked for (as one of the possible alternatives) when:

  • a statement is expected, in which case we keep all the statements in all the branches (as we do in C)
  • a definition is expected, in which case we keep all the definitions.

For example, we keep all the code in the following cases

Class C

#If Debug
  Sub F
    doSth()
    log()
  End Sub
#Else
  Sub F
    doSth()
  End Sub
#End If

End Class

and

Sub Foo
  #If Debug
    log_a_lot()
  #Else
    log_just_a_bit()
  #End If
End Sub

If the directive is more complicated, e.g.,

Sub Foo
  x = _
  #If Debug
    random()
  #Else
    3
  #End If
End Sub

we fall back to the old semantics and keep only the "then" branch.

Attributes

There are two kinds of attributes: global and local, the latter are attached to a particular definition. We can distinguish between them syntactically: the former have an Assembly: or Module: prefix

@maciejpirog maciejpirog changed the title VB parser updates: no sentinel strings and better handling of directives VB parser updates: no sentinel strings, better directives, better attributes Mar 4, 2026
@maciejpirog maciejpirog force-pushed the mpir/vb-parser-updates branch from e72406e to dc76450 Compare March 5, 2026 12:42
Copy link
Collaborator

@dimitris-m dimitris-m left a comment

Choose a reason for hiding this comment

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

lgtm

@maciejpirog maciejpirog merged commit c8b0929 into main Mar 5, 2026
6 checks passed
@maciejpirog maciejpirog deleted the mpir/vb-parser-updates branch March 5, 2026 13:00
@maciejpirog maciejpirog mentioned this pull request Mar 5, 2026
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Mar 6, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [opengrep/opengrep](https://github.com/opengrep/opengrep) | patch | `v1.16.2` → `v1.16.3` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>opengrep/opengrep (opengrep/opengrep)</summary>

### [`v1.16.3`](https://github.com/opengrep/opengrep/releases/tag/v1.16.3): Opengrep 1.16.3

[Compare Source](opengrep/opengrep@v1.16.2...v1.16.3)

#### Improvements

- Elixir: Parse short function form (`def f(), do: ...`) by [@&#8203;maciejpirog](https://github.com/maciejpirog) in [#&#8203;605](opengrep/opengrep#605)
- VB parser updates: no sentinel strings, better handling of compiler directives and attributes by [@&#8203;maciejpirog](https://github.com/maciejpirog) in [#&#8203;603](opengrep/opengrep#603)
- Allow `--semgrepignore-filename` to be an absolute path by [@&#8203;dimitris-m](https://github.com/dimitris-m) in [#&#8203;608](opengrep/opengrep#608)

**Full Changelog**: <opengrep/opengrep@v1.16.2...v1.16.3>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My41NS4zIiwidXBkYXRlZEluVmVyIjoiNDMuNTUuMyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6OnBhdGNoIl19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants