Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Lexing escaped interpolated regions #67

Open
KrosFire opened this issue Nov 11, 2024 · 0 comments
Open

[BUG] Lexing escaped interpolated regions #67

KrosFire opened this issue Nov 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@KrosFire
Copy link
Member

Example:
A text like this:

"\"\\{should not be interpolated // should not be a comment}\""

With a set of rules like this:

let symbols = vec!['/', '"', '{', '}'];
let regions = reg![reg!(string as "String" => {
    begin: "\"",
    end: "\"",
    tokenize: true
} => [
    reg!(str_interp as "string interpolation" => {
        begin: "{",
        end: "}",
        tokenize: true,
        allow_left_open: true
    } ref global)
]),
reg!(comment as "Comment" => {
    begin: "//",
    end: "\n",
    allow_left_open: true
})];
let compounds = vec![('/', '/')];

is lexed to:

[("\"", 1, 1), ("\\", 1, 2), ("{", 1, 3), ("should", 1, 4), ("not", 1, 11), ("be", 1, 15), ("interpolated", 1, 18), ("// should not be a comment\\}\"", 1, 31)]

When I inspected the region stack, theres is a bug that pushes string interpolation region and then a comment region, that creates a untokenized string

@KrosFire KrosFire added the bug Something isn't working label Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant