Looking for some example files (custom numeric constants / types)

I’ve been playing around with parsing numeric literals and I have some code that I want to test out. I was hoping folks here would have some Ada source files in their repos that use a lot of numeric literals (real and integer, based and non based) either for constants or as part as making some custom numeric types.

If anyone has any good files to look at for potential parsing data, I would appreciate it. Just toss up a link to the file. The only requirement on them is that they were valid Ada files and that they stick to ASCII character subset (for now). Any compiler is fine and any language version is fine, I’m not compiling them (but assuming they correctly compile in their build environment).

I am making my own test cases, but want to hammer my code with as many test cases as I can (it’s also good to test with inputs that I didn’t create to avoid testing bias). I found that parsing numeric literals was more intricate than I had realized based on what the RM allows, so I am looking to hammer out my edge cases.

I’ll be on vacation for the next two weeks or so, so anything after today I’ll try out when I get back.

Thanks in advance!

Here’s a few from the ada cash library:

And from NaCI:

1 Like

@AJ-Ianozi Thank you so much!

Yay all of those passed except for the money one, but that is because while I have an interface for non ASCII characters, I have only implemented up to ASCII. I updated my original post to reflect that.

Have you looked at ACATS?

The package specification of my SHA library should work:
http://verisimilitudes.net/2023-11-13

I’m not clear what you mean by this. Most parsing of numeric literals can be done directly through the language features; see, for example, my response to this question about parsing hex images.

For something more complex, you can look at the parsing in function Value for PragmARC.Unbounded_Numbers.Integers, which accepts bases in 2 … 36.

I have not. I’ll take a look! Thanks!

Thanks! i’ll take a look!

I’m more looking for input data to scan through. I guess I should have said lexing. I’m aware of existing methods though. I could have used the Value attribute directly, but it defeats the purpose of learning things and exploring, plus there are downsides to using those predefined solutions.

I just wanted to say thanks to everyone who suggested ideas. I took some time running through a lot of the suggested example files. Found some logic errors in my code and fixed them. There’s probably still some errors (most likely numeric literals, character literals, attributes, and qualified expressions), but I’ll take small chips away at this as I have time so I can learn more.

If anyone is interested, the lexer I was making is linked below. It’s just for fun, nothing serious. I won’t be making a full fledged compiler, though in the future I may start playing with other compiler related topics. This is mostly for fun / exploration. It is ASCII only for now (maybe some Latin_1) but in the future I’ll toy with making it work with Wide_Wide_String types so I can open it up to larger character sets.