Skip to content

How to reconcile overlapping tokens. #439

Closed

Description

@TheGrandmother

I have have a stupid and naive question.
it is very likely the case that I have misunderstood something.

I am building a VDM to Go transpiler and VDM uses a lot of keywords and especially keyword operators (and even a bunch of multi word operators).
I would find it preferable to be able to have the lexer generate different tokens for these keywords instead of having to enumerating them in the grammar or lexing them as arbitrary identifiers and resolving them later.

What is the recommended way, when using participle, to-handle the issue of overlapping tokens.
Given that there is no option to configure the lexer for longest match, no look-ahead (there seems to be in the grammar definition but not for the lexer) or as no non capturing groups are not working,
how do I resolve overlapping tokens?

orlando or oregon and trinidad_and_tobago or floor(x)

What is the recommended to make statements like that lex as something akin to : Ident Op Ident Op Ident Op Ident Lp Ident Rp

This issue seems to have been touched upon in some other issues but I have not seen a coherent solution.
#276 #107 #259 #210

As I said, I may very well be misguided in this question, I am not super well educated and do not have much understanding into compilers.
But I feel that it may still be valid to raise this question since other people may also be confused by this.
A note about it in the readme may be helpful.

Activity

  1. Repository owner locked and limited conversation to collaborators on May 31, 2025
  2. converted this issue into a discussion #440 on May 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions