25
2
Related to: Make a ;# interpreter and Generate ;# code
;#
- A Whirlwind Guide
This is a simple language with two commands. Its only data structure is an accumulator, which is initialized to 0.
;
Increment the accumulator#
Calculate the value of the accumulator modulo 127, and print the corresponding ASCII character. Then, reset the accumulator to 0.
The source code may contain additional characters (printable ASCII + whitespace), but these are treated as comments and have no effect on program execution.
Challenge
Since most computers do not come with ;#
preinstalled, it would be very useful to have a tool that can convert ;#
code into a different language. In this challenge, you shall write a program to accomplish this.
Input
Some ;#
source code, taken via argument or STDIN. This source code may contain (comment) characters other than ;
or #
.
Output
Code, in the same language as your submission, which, when executed, prints/returns the same string as the original ;#
code. This resultant code may output a trailing newline after the target string, if that is more convenient for your language.
Notes
One thing to look out for is escape sequences, such as code that prints backslashes or prints quote marks. Also look out for ;#
code that could contain things that look like keywords or commands in your language.
Additional restrictions
All programs must terminate (I normally consider this a default, but someone asked about it so I'm stating it here).
Examples
input: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#
output (python): print(";#")
input: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#
output (element): \'`
34My computer came with
;#
preinstalled... – programmer5000 – 2017-05-24T20:56:21.7871Another one? Why? – caird coinheringaahing – 2017-05-24T22:37:20.833
Does the program have to stop execution? Also, can it print no-ops infinitely after the actual code? – totallyhuman – 2017-05-24T23:50:41.597
Will the program always have at least one
#
character in it? – FryAmTheEggman – 2017-05-25T00:54:26.1832@totallyhuman I'm gonna say that all programs must eventually halt. – PhiNotPi – 2017-05-25T03:33:00.413
1Please could we get a test case where the input contains a character (or characters) that aren't
;
or#
? – streetster – 2017-08-10T20:55:58.523@streetster Just spam random characters in the already-existing testcases as comments – MilkyWay90 – 2019-06-14T17:08:01.270