in reply to S-expressions with Marpa::R2: Grammar for Numbers

I can't test it but I would start with:

atom ::= string | number | symbol number ::= SIGN? DIGITS action => Sexp::Tiny::Actions::do_join SIGN ~ "+" | "-" DIGITS ~ [0-9] # Exclude the new starting characters for numbers from the "symbol" ch +aracter class SYMCHAR ~ [^()\s"0-9+-]

Replies are listed 'Best First'.
Re^2: S-expressions with Marpa::R2: Grammar for Numbers
by choroba (Cardinal) on Dec 22, 2025 at 22:25 UTC
    Or, if you want to support the exponential notation, too:
    number ~ sign_maybe digit_many e | sign_maybe digit_any '.' digit_many e_maybe | sign_maybe digit_many e_maybe | sign_maybe non_zero digit_any empty ~ sign_maybe ~ [+-] | empty digit ~ [0-9] non_zero ~ [1-9] digit_any ~ digit* digit_many ~ digit+ e ~ [Ee] sign_maybe digit_many e_maybe ~ e | empty

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]