After I implemented labels and macros, I figured that it would be nice if I was able to define them all in one place and then re-use them over and over again. Hence, the concept of imports.
Examples: In file macros.b: # Macro to convert ASCII representation of integer to actual # integer value *OFFSET = 48; @atoi(CHR) = -$OFFSET$CHR; # Macro to convert integer value to ASCII representation of # integer value @itoa(NUM) = +$OFFSET$NUM; In file macro-use.bad: %macros.b # Input a character ?a # Convert to actual integer value &atoi(a) # Store the number 9 in location pointed to by value in # register a >9[a # Convert 9 to ASCII value of the character '9' (57) &itoa([a)
By convention, bAdkOde scripts end with the extension bad, whereas macro-definition files end with the extension b. Also, macro-definition files shouldn't contain any actual code. Any such code is ignored. It's possible to "overload" macros. You can have macros that share the same name, but they must have different numbers of parameters.
Example bAdkOde scripts
Here are a few example scripts:
# prints the first 10 fibonacci numbers
# reverse prints what ever the user enters
# takes whatever the user enters and stores it in memory
# and then prints it out
As you can see, pretty unreadable. I've tried to provide a semblance of readability in some scripts by indenting. But you can pretty much write everything in one line and it'll work.
4 thoughts on “bAdkOde”
Ugh. Macros are the devil incarnate. Nothing makes grep-ing through large amounts of source code more painful than macros. Nice post though. I’m impressed with your use of EBNF and creative ability with new programming languages! This also lead me to look up several other esoteric languages (i.e. Brainfuck).
Oh yeah, a large number of macros can make things really hairy. But I think that’s probably due to macro abuse! I made macros here just because that’s what I was familiar with when I was doing assembly programming. Then again, this isn’t meant to be a language for serious software projects! I’m glad you liked the EBNF and I’m also glad that you found bAdkOde creative. I guess all those theoretical computer-science classes I took at ASU weren’t for nothing! 😉 Haha!
Esoteric programming languages are pretty neat. I think you realize how much you take for granted in high-level languages when you work with some of the more limited ones, like Brainfuck. On the other hand, they really make you think in novel ways and also completely change the way you approach problems. I think it’s a good thing.