↧
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 ArticleAnswer 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 ArticleAnswer 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 ArticleTokenize 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