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

Negative integers are not parsed #103

Closed
LeoniePhiline opened this issue Feb 18, 2023 · 2 comments
Closed

Negative integers are not parsed #103

LeoniePhiline opened this issue Feb 18, 2023 · 2 comments

Comments

@LeoniePhiline
Copy link
Contributor

LeoniePhiline commented Feb 18, 2023

Issue is _number being used as choice in literal, but also as part of _decimal_number.

    literal: $ => prec(2,
      choice(
        $._number,
        $._decimal_number,
        $._literal_string,
        $.keyword_true,
        $.keyword_false,
        $.keyword_null,
      ),
    ),
    _double_quote_string: _ => seq('"', /[^"]*/, '"'),
    _literal_string: $ => choice(
      seq("'", /[^']*/, "'"),
      $._double_quote_string,
    ),
    _number: _ => /\d+/,
    _decimal_number: $ => choice(
        seq(optional("-"), ".", $._number),
        seq(optional("-"), $._number, ".", $._number),
        seq(optional("-"), $._number, "."),
    ),

Therefore, \d+ is correct, and a new anonymous option _integral_number must be added, using seq(optional("-"), $._number).

@LeoniePhiline
Copy link
Contributor Author

Fixed by 756ffc2 as part of #102.

@DerekStride
Copy link
Owner

Closed in #102

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

2 participants