Quantcast
Channel: Tokenize a Stack-Based language - Code Golf Stack Exchange
Browsing latest articles
Browse All 4 View Live

Answer by anon for Tokenize a Stack-Based language

Ruby, 234 bytesputs"[#{$stdin.read.scan(/("(?:(?<!\\)\\"|[^"])+(?:"|$))|'(.)|(\d+)|(.)/).map{|m|(m[0]?(m[0].end_with?('"')?m[0]: m[0]+'"'): m[1]?"\"#{m[1]}\"":...

View Article


Answer by Zach Gates for Tokenize a Stack-Based language

Python 3, 228 bytesimport re;L=listprint(L(map(lambda i:i+'"'if i[0]=='"'and not i[-1]=='"'else i,map(lambda i:'"%s"'%i[1]if i[0]=="'"else i,filter(None,sum([L(i)for i in...

View Article


Answer by Martin Ender for Tokenize a Stack-Based language

Retina, 6864 63 bytesM!s`"(\\.|[^"])*"?|'.|\d+|\Sms`^'(.)|^"(([^\\"]|\\.)*$)"$1$2"ors`\s*((")(\\.|[^"])*(?<-2>")?|'.|\d+|.)\s*$1$2¶\ms`^'(.)"$1"I think this covers all the funky edge cases, even...

View Article

Tokenize a Stack-Based language

I've been working on another stack-based golfing language called Stackgoat. In this challenge you'll be writing a Tokenizer for Stackgoat (or really any general stack-based...

View Article
Browsing latest articles
Browse All 4 View Live


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