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

Invalid output from token #399

Open
axelkar opened this issue Jun 28, 2024 · 1 comment
Open

Invalid output from token #399

axelkar opened this issue Jun 28, 2024 · 1 comment

Comments

@axelkar
Copy link

axelkar commented Jun 28, 2024

May be related to #181 ?

#[derive(Logos, Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[logos(skip "[ \t\r\n]+")]
pub enum TokenKind2 {
    #[regex(r"/dts-v1")]
    DtsV1,

    // Removing this makes the slash match be `/d` instead of `/dt`
    #[regex(r"/dfoo")]
    Dfoo,

    #[regex(r"/[a-z-]+/")]
    UnknownDirective,

    /// A lex error!!
    Unrecognized,

    #[regex(r#"[a-z-]+"#)]
    Ident,

    #[token("/")]
    Slash,
}

With input /dts-v (plus newline) produces the following output:

Slash "/d" 0..2
Ident "ts-v" 2..6

Should be

Slash "/" 0..1
Ident "dts-v" 1..6

With /dts- or /dts-vv it just errors?

@axelkar
Copy link
Author

axelkar commented Jun 28, 2024

Here's the graph:

{
    1: ::<skip> (<skip>),
    2: {
        [09-0A] ⇒ 2,
        [0D] ⇒ 2,
          ⇒ 2,
        _ ⇒ 1,
    },
    4: ::DtsV1,
    6: ::Dfoo,
    8: ::UnknownDirective,
    9: / ⇒ 8,
    10: {
        - ⇒ 10,
        [a-z] ⇒ 10,
        _ ⇒ 9,
    },
    13: ::Ident,
    14: {
        - ⇒ 14,
        [a-z] ⇒ 14,
        _ ⇒ 13,
    },
    16: ::Slash,
    26: {
        - ⇒ 10,
        / ⇒ 8,
        [a-e] ⇒ 10,
        f ⇒ 27,
        [g-s] ⇒ 10,
        t ⇒ 30,
        [u-z] ⇒ 10,
    },
    27: [
        oo ⇒ 28,
        _ ⇒ 10*,
    ],
    28: {
        - ⇒ 10,
        / ⇒ 8,
        [a-z] ⇒ 10,
        _ ⇒ 6,
    },
    30: [
        s-v ⇒ 32,
        _ ⇒ 10*,
    ],
    32: {
        - ⇒ 10,
        / ⇒ 8,
        1 ⇒ 4,
        [a-z] ⇒ 10,
    },
    33: {
        - ⇒ 10,
        [a-c] ⇒ 10,
        d ⇒ 26,
        [e-z] ⇒ 10,
        _ ⇒ 16,
    },
    34: {
        [09-0A] ⇒ 2,
        [0D] ⇒ 2,
          ⇒ 2,
        - ⇒ 14,
        / ⇒ 33,
        [a-z] ⇒ 14,
    },
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant