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


atom ::= string
       | number
       | symbol

number_chars ::= SIGN? DIGITS action => Sexp::Tiny::Actions::do_join
SIGN           ~ "+" | "-"
DIGITS         ~ [0-9]

# Exclude the new starting characters for numbers from the "symbol" character class
SYMCHAR ~ [^()\s"0-9+-]

Replies

  • 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]