Replies: 1 comment 1 reply
-
Hey @dhowe, Trying to directly answer your question: You can manipulate your On a more general note, I have a feeling like you're trying to accomplish too much using just a lexer. Your lexer should be as atomic as possible. You should treat |
Beta Was this translation helpful? Give feedback.
-
I have a language in which spaces are allowed, as well as '<' and '>', but I want the lexer to treat the regex '<\d+>' as a single token. Is there any way to make the lexer recognize the (shorter) WEIGHT token below?
const WEIGHT = createToken({ name: "WEIGHT", pattern: /\s*<\d+>\s*/ });
const TEXT = createToken({ name: "TEXT", pattern: /[\w\d\s<>]+/ });
Examples (-> expected)
Code test:
Output:
Beta Was this translation helpful? Give feedback.
All reactions