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

Error while parsing exponent #1

Open
FunnySaltyFish opened this issue Dec 12, 2023 · 0 comments
Open

Error while parsing exponent #1

FunnySaltyFish opened this issue Dec 12, 2023 · 0 comments

Comments

@FunnySaltyFish
Copy link

Currently, the library seems cannot parse exponent numbers correctly, like 1e5, 1.2e-4, 0.8e+5.
and, you might need to consider situations when the exponent num is incomplete, for example, for 1.2e5, when the exponent 5 is missing, there will be only 1.2e.

Test code(tokenize.test.ts):

describe('tokenizer extreme cases', () => {
  // 1e3
  it('incomplete expontional num', () => {
    expect(tokenize('1e3')).toEqual([
      {
        type: TokenType.Number,
        value: 1e3,
      },
    ]);
  });
});

Error:


      119 |         }
      120 |         default: {
    > 121 |           throw new SyntaxError(
          |                 ^
      122 |             `Unexpected character: "${char}" ` + `at position: ${context.index}`
      123 |           );
      124 |         }

      at Object.tokenize (src/tokenizer/tokenize.ts:121:17)

Relative code: function parseExponent(context: ParseContext).

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