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): \'`
;or#." part of requirement. \$\endgroup\$/;+#/→/.*?#/and the code blocks.length-1→s.count(?;). BTW, your math is also wrong, as%has higher priority than-, so should be(s.length-1)%127. And in.gsub's code block you can access the captured groups with$&,1ドル, ... so the|s|code block parameter usually is not feasible. And the string interpolation stringifies:{"$><<#{$&.count(?;)%127}.chr;"}. Try it online! \$\endgroup\$gsubmodifies$_directly, which means that you don't need to re-assign it. HOWEVER, you have issues if you have comment characters after your last#... see here \$\endgroup\$