stardot / beebasm

A portable 6502 assembler with BBC Micro style syntax
http://www.retrosoftware.co.uk/wiki/index.php/BeebAsm
GNU General Public License v3.0
83 stars 26 forks source link

Underscores in numeric literals. Fixes #36, #48. #73

Closed mungre closed 1 year ago

mungre commented 1 year ago

36 is a reminder that the syntax for numeric literals accepted by beebasm depended on the C++ standard library of the compiler used to build it. This pr parses parses all numeric types so that the supported syntax is explicit and platform-independent. It also allows underscores to be used as digit separators in all numeric types, e.g. &1_0000 or 0.000_000_1.

Sorry for the late submission, but #36 has always niggled.

ZornsLemma commented 1 year ago

FWIW I've had a quick look over this and it seems reasonable. My comments in the other thread that I didn't think #36 was a blocker were based on not having a fix; I think it's good if we can fix this, as it's been an ongoing source of occasional problems. The fact we have a test suite now makes me pretty happy this isn't going to break stuff, and I imagine a 1.10 release candidate announced on stardot will also get a fair amount of additional testing too.

ZornsLemma commented 1 year ago

It would be good to document the new underscore feature and the more reliable parsing in the README, of course.

mungre commented 1 year ago

Cheers. Yes, I wouldn't have been confident doing this without the tests. I've updated the README and also changed the parsing of exponents for consistency with BBC BASIC. Previously, the 2 in 2EOR3 was parsed as an unfinished exponent 2E giving an error but now it's just a 2. The parser won't commit to an exponent unless there's a sign or digit.

chriskillpack commented 1 year ago

Thanks for fixing the bug and making the underscore Improvement. LGTM.

mungre commented 1 year ago

Cheers, I've merged both of my PRs now.