Importing files
Usage: %[filename];
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:
hello-world.bad
)0)33)100)108)114)111)87)32)111)108)108)101)72(a{!a"a(a}
fibonacci.bad
# prints the first 10 fibonacci numbers )0 )1 >10a >a[a {![a (a (b )b 'b"32 +ab (a )b )a >10a -1[a } "8"10
reverse.bad
# reverse prints what ever the user enters )0 >1a {!a ?a )a -10a } >1a {!a (a "a }
echo.bad
# takes whatever the user enters and stores it in memory # and then prints it out >0b>1a{!a?a>a[b+1b-10a}>0b>1a{!a>[ba"a+1b-10a}
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.
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).
Steve
@Steve O
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.
p2bc6d
jukv39
ciulzw
w1w5ku
jk9opn
e9ltgz
zpls52
e88jk9
dv5mj2
6a0krx
rjc16y