Skip to content
Discussion options

You must be logged in to vote

I am turning my comment into an answer because it is actually the solution to the original problem.

Langium configures lookahead based on local alternatives only, not global ones. For this particular case, it is possible to apply lookahead manually at the tokenization phase using regex lookahead (i.e. (?=...)). All mentions of the token at which lookahead failed need to be turned into terminals and put into the appropriate order.

grammar HelloWorld

terminal ASSIGNMENT_STAR: /\*(?=\s*=)/;
terminal STAR: '*';

entry Model:
    variable=ID ':' Unit ASSIGNMENT_STAR '=';

Unit:
    Multiplicative;

Multiplicative infers Unit:
    Atom ({infer Binary.left=current} operator=(STAR | '/') right=A…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@drhagen
Comment options

@msujew
Comment options

@drhagen
Comment options

@drhagen
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by drhagen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants