Skip to content
Discussion options

You must be logged in to vote

You could create a dummy token and then return EOF from the chevrotain import in its stead. You'll need to override the TokenBuilder service for that.

Am I missing something?

Added a dummy terminal rule:

terminal EOF: /\z/;

Override TokenBuilder:

import { TokenType, EOF } from 'chevrotain';
import { DefaultTokenBuilder } from 'langium';
import { TerminalRule } from 'langium/lib/grammar/generated/ast';

class CustomTokenBuilder extends DefaultTokenBuilder {
    override buildTerminalToken(terminal: TerminalRule): TokenType {
        let tokenType = super.buildTerminalToken(terminal);
        if (tokenType.name === 'EOF') {
            tokenType = EOF;
        }
        return tokenType;

Replies: 3 comments 22 replies

Comment options

You must be logged in to vote
8 replies
@msujew
Comment options

@spoenemann
Comment options

@Yokozuna59
Comment options

@Yokozuna59
Comment options

Answer selected by Yokozuna59
@msujew
Comment options

@Yokozuna59
Comment options

@Yokozuna59
Comment options

Comment options

You must be logged in to vote
12 replies
@Yokozuna59
Comment options

@Yokozuna59
Comment options

@msujew
Comment options

@msujew
Comment options

@msujew
Comment options

Comment options

You must be logged in to vote
2 replies
@msujew
Comment options

@msujew
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants