Skip to content
Discussion options

You must be logged in to vote

never mind, I figured it out. I didn't know it was possible to add Cardinalities to a single parse rule.

Anyway for anyone who might ask for it here is the code (because I'll delete the repo):

Langium grammer:

grammar Example

entry Example:
    name=NAME*;

// placeholder terminal rule
terminal NAME: /name/;

Override TokenBuilder:

import {
  CustomPatternMatcherFunc,
  CustomPatternMatcherReturn,
  TokenType,
} from "chevrotain";
import { DefaultTokenBuilder } from "langium";
import { TerminalRule } from "langium/lib/grammar/generated/ast";

const nameRegex = /(?:^|[\t ]+)name[\t ]*:[\t ]*([^\n]+)?/;
const matchName: CustomPatternMatcherFunc = (text: string) => {
  let result: CustomPat…

Replies: 1 comment 4 replies

Comment options

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

@msujew
Comment options

@Yokozuna59
Comment options

@Yokozuna59
Comment options

Answer selected by Yokozuna59
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