Skip to content

Support scientific notation for float literals (1e-12, 2.5e3) #106

@timfennis

Description

@timfennis

Summary

The lexer does not support scientific/exponential notation for float literals. 1e-12 currently causes a parse error.

Example

let eps = 1e-12;   // parse error: Expected ';' but got 'e'
let big = 2.5e3;   // also fails

Motivation

Came up when writing tests for trig functions — a natural epsilon value like 1e-12 had to be written as 0.000000000001, which is error-prone and hard to read.

Expected behavior

Scientific notation should be parsed as float literals:

  • 1e121000000000000.0
  • 1e-120.000000000001
  • 2.5e32500.0
  • 1.5E-60.0000015 (case-insensitive E)

Implementation hint

Update the float literal rule in ndc_lexer to accept an optional exponent part ([eE][+-]?[0-9]+).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions