Quantcast
Channel: Tokenize a Stack-Based language - Code Golf Stack Exchange
Viewing all articles
Browse latest Browse all 4

Answer by Martin Ender for Tokenize a Stack-Based language

$
0
0

Retina, 6864 63 bytes

M!s`"(\\.|[^"])*"?|'.|\d+|\Sms`^'(.)|^"(([^\\"]|\\.)*$)"$1$2"

or

s`\s*((")(\\.|[^"])*(?<-2>")?|'.|\d+|.)\s*$1$2¶\ms`^'(.)"$1"

I think this covers all the funky edge cases, even those not covered by the test cases in the challenge.

Try it online!


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>