Skip to content
New issue

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

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

Already on GitHub? # to your account

Count \r and \t as whitespaces #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Borderliner
Copy link

Otherwise produces Error tokens:

→ let x = 10
Root@0..12
  VariableDef@0..10
    LetKw@0..3 "let"
    Whitespace@3..4 " "
    Ident@4..5 "x"
    Whitespace@5..6 " "
    Equals@6..7 "="
    Whitespace@7..8 " "
    Literal@8..10
      Number@8..10 "10"
  Error@10..12
    Error@10..11 "\r"
    Whitespace@11..12 "\n"
error at 10..11: expected ‘+’, ‘-’, ‘*’, ‘/’, ‘let’, number, identifier, ‘-’ or ‘(’, but found an unrecognized token
[crates\eldiro\src\main.rs:27] root.stmts().filter_map(|stmt|
            if let ast::Stmt::VariableDef(var_def) = stmt {
                    Some(var_def.value())
                } else { None }).collect::<Vec<_>>() = [
    Some(
        Literal(
            Literal(
                Literal@8..10
                  Number@8..10 "10"
                ,
            ),
        ),
    ),
]
[crates\eldiro\src\main.rs:36] hir::lower(root) = (
    Database {
        exprs: Arena {
            len: 0,
            data: [],
        },
    },
    [
        VariableDef {
            name: "x",
            value: Literal {
                n: Some(
                    10,
                ),
            },
        },
    ],
)

This fixes the error and counts \t and \r as whitespaces:
Whitespace@10..12 "\r\n"

Otherwise produces Error tokens:
```
→ let x = 10
Root@0..12
  VariableDef@0..10
    LetKw@0..3 "let"
    Whitespace@3..4 " "
    Ident@4..5 "x"
    Whitespace@5..6 " "
    Equals@6..7 "="
    Whitespace@7..8 " "
    Literal@8..10
      Number@8..10 "10"
  Error@10..12
    Error@10..11 "\r"
    Whitespace@11..12 "\n"
error at 10..11: expected ‘+’, ‘-’, ‘*’, ‘/’, ‘let’, number, identifier, ‘-’ or ‘(’, but found an unrecognized token
[crates\eldiro\src\main.rs:27] root.stmts().filter_map(|stmt|
            if let ast::Stmt::VariableDef(var_def) = stmt {
                    Some(var_def.value())
                } else { None }).collect::<Vec<_>>() = [
    Some(
        Literal(
            Literal(
                Literal@8..10
                  Number@8..10 "10"
                ,
            ),
        ),
    ),
]
[crates\eldiro\src\main.rs:36] hir::lower(root) = (
    Database {
        exprs: Arena {
            len: 0,
            data: [],
        },
    },
    [
        VariableDef {
            name: "x",
            value: Literal {
                n: Some(
                    10,
                ),
            },
        },
    ],
)
```
This fixes the error and counts \t and \r as whitespaces:
`Whitespace@10..12 "\r\n"`
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant