Let’s say I have a very simple language that can handle only line comments that start with a double-slash and paths that are delimited with a single slash. For example:
// this is a comment
this/is/a/path
The grammar I’ve written for this is:
@top {
Path*
}
Path { (identifier "/")* identifier }
@tokens {
whitespace { std.whitespace+ }
LineComment { "//" ![\n]* }
identifier { (std.asciiLetter | std.digit)+ }
}
@skip { whitespace | LineComment }
lezer-generator gives me the following error
Overlapping tokens “/” and LineComment used in same context (example: “/” vs “//”)
My intuition tells me that I need to use the ambiguity marker so that the parser splits when it reaches a slash, and will test the next character to determine which path to take, but I’m having trouble figuring out exactly how to do that. Any help would be greatly appreciated!