Skip to content

TODO "Figure out how to do verbatim sequences in ANTLR" is impossible to implement with ANTLR #39

@ST92

Description

@ST92

I spent last few days digging around why would such an innocently looking feature be left as a TODO. I was looking for something to put my hands into, and it looked promising enough.

Turns out ANTLR doesn't support back-references or forward-references at all. There is no good way to do it using only it.

A known workaround is to embed actions that verify whether the two tokens match (analogous to how XML opening-closing tag pair match tagname), but those actions involve putting a piece of code inside the grammar lexer definition in a programming language that matches the language of the generated lexer.

That would mean putting Java code in concise-encoding grammar definitions, and thus tying it tightly to Java.

I want to write a Rust 100% implementation. AFAIK at this moment I need to write a custom lexer and parser to make verbatim escape sequences work.

TLDR; ANTLR is insufficient, because VES grammar is context-sensitive

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions