Whitespace part - kenrube/Esopoly GitHub Wiki

Whitespace is a semi-joking programming language, the source code on which you can embed in any other: using only space, tab and line feed characters, it hides in sight :) You can get acquainted with the syntax of the language on the official page.

The algorithm for outputting the phrase Whitespace program is simple: push all the characters, from the end, to the stack, then extract them one by one (pop) and print. For the sake of convenience, let's designate a space character as -, a tab character as >, and a newline character as v.

  1. We call -- that will allow us to push the next number (bit representation of the symbol) to the top of the stack. - in the number means 0, > - 1. The number ends with the new line character v.
  2. After all the numbers are on the stack, we call >v-- to output each of them. According to the specification, this sequence of instructions extracts and prints the character from the top of the stack.
  3. After displaying all the characters, we call vvv, which means the end of the program. Let's write the source code in the pseudocode:
-- ->>->>->v       push 'm'(01101101) to stack
-- ->>---->v       push 'a'(01100001)
-- ->>>-->-v       push 'r'(01110010)
-- ->>-->>>v       push 'g'(01100111)
-- ->>->>>>v       push 'o'(01101111)
-- ->>>-->-v       push 'r'(01110010)
-- ->>>----v       push 'p'(01110000)
-- -->-----v       push ' '(00100000)
-- ->>-->->v       push 'e'(01100101)
-- ->>--->>v       push 'c'(01100011)
-- ->>---->v       push 'a'(01100001)
-- ->>>----v       push 'p'(01110000)
-- ->>>-->>v       push 's'(01110011)
-- ->>-->->v       push 'e'(01100101)
-- ->>>->--v       push 't'(01110100)
-- ->>->-->v       push 'i'(01101001)
-- ->>->---v       push 'h'(01101000)
-- ->->->>>v       push 'W'(01010111)
>v--               pop & print 'W'
>v--               pop & print 'h'
>v--               pop & print 'i'
>v--               pop & print 't'
>v--               pop & print 'e'
>v--               pop & print 's'
>v--               pop & print 'p'
>v--               pop & print 'a'
>v--               pop & print 'c'
>v--               pop & print 'e'
>v--               pop & print ' '
>v--               pop & print 'p'
>v--               pop & print 'r'
>v--               pop & print 'o'
>v--               pop & print 'g'
>v--               pop & print 'r'
>v--               pop & print 'a'
>v--               pop & print 'm'
vvv                finish

Or the same in the true Whitespace (view after embedding in the common source, drop head and tail if you want to see only the analog of the pseudocode):

head    
head    
   		 		 	
   		    	
   			  	 
   		  			
   		 				
   			  	 
   			    
    	     
   		  	 	
   		   		
   		    	
   			    
   			  		
   		  	 	
   			 	  
   		 	  	
   		 	   
   	 	 			
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  


tail
--//--                                                   
--//--                                                   
--//--  		  
--//--  		  
--//--  		  
--//--  		  
--//--  		  
--//--  		  
--//--  		  
--//--  		  
--//--  		  
--//--   		   
--//--   		   
--//--   		   
--//--       
--//--
--//--
--//--
--//--
--//--
--//--
--//--                                            
--//--                        
--//--                    
--//--                                
--//--                    
--//--                    
--//--                        
--//--                                    
--//--
--//--
--//--
--//--                                  
--//--                          
--//--                        
--//--                          
--//--                          
--//--                      
--//--                      
--//--                              
--//--
--//--
--//--
--//--

You can try it in the online interpreter.

Why did the source become so large after the embedding? I went through a lot of options to make the common source code look as much as possible aesthetically pleasing (assuming, of course, the size of tab character = 1), and eventually came to the fact that it looks good in the general outline of the X-P smiley, recreated from the source code in Whitespace. X is formed from the code for pushing characters to the stack, - - from the extraction and output code. P was added for the company and, although it also consists of a mixture of spaces and tabs, does not actually perform any actions in the context of Whitespace - our program has already completed its execution after 3 consecutive line breaks. Similarly, later, the inscription ESOTERIC POLYGLOT was added - too much space left without graffiti :)

Let's not embed it to the common source yet, we will do it at the last stage.