Sacred

From Esolang
Jump to navigation Jump to search

Sacred is a joke esoteric language created by User:Conor O'Brien that is primarily a Brainf*** derivative, but adds extra commands. It is entirely comprise of three characters (not commands):

( ) <space>

It was made in response to this question on CodeGolf SE.

Syntax

Sacred can run in two modes: the first mode has first characters ())(, and signals that the program should be read as a Brainf***-esque program; the second mode has first characters ()(), and signals that each set of parenthesis is a ternary byte that should be interpreted to an ASCII charater. Then, the programming language name becomes "Sacred <language name>". All non-space-and-parenthesis characters are treated as comments.

Mode 1: Brainf***

In this mode, each command is delineated by spaces. It is similar to Brainf*** in that it has a theoretically infinite strip; there are, however, no restrictions on the maximum and minimum values that a byte can be. The following commands are listed:

Command Description
() Increments the current byte.
)( Decrements the current byte.
(( Go left in the data strip.
)) Go right in the data strip.
( Jump past the matching ) if the byte is zero.
) Jump back to the matching ( if the byte is non-zero.
((( Outputs the current byte as an ASCII character.
))) Takes a single-character input as an ASCII character.
((() Takes a numeric input.
())) Outputs the byte as a number.
((())) Converts the data strip into characters and evaluates them as if they were code.
((()())) Converts the data strip into characters and evaluates them as if they were code. Places this command at the end of the program to evaluate again the strip ad infinitum.

Mode 2: Sacred <language>

In this mode (also called "Sacred M2"), each character is interpreted as a five-length, zero-padded, base 3 numeral. Each numeral is converted to an ASCII value. However, instead of using the digits 0, 1, and 2, Sacred M2 uses the characters <space>, (, and ) as those digits respectively.

Examples

Mode 1: Hello World

"Hello, World!" program.

())( () () () () () () () () ( )) () () () () ( )) () () )) () () () )) () () () )) () (( (( (( (( )( ) )) () )) () )) )( )) )) () ( (( ) (( )( ) )) )) ((( )) )( )( )( ((( () () () () () () () ((( ((( () () () ((( )) )) ((( (( )( ((( (( ((( () () () ((( )( )( )( )( )( )( ((( )( )( )( )( )( )( )( )( ((( )) )) () ((( )) () () (((

Mode 2: Sacred Python

"Hello, World!" program.

(( (((( ) ( )) ((  )(( )) (((( ( )( ))  ( ) )((   ((   (( (  (()) ( ()(  ) (( ( (( ) ((   ( ) ( ( )  ( )( ((()

Mode 2: Sacred JavaScript

Parenthesis to Footnotes program.

( )( (((  ((  )( )  (( ))( )) (( ( ((  ) ( ()( ) (( ) )(( ((( ()((( ) ( ) )((  ) (((((( )( (())((  ) ) )( ()(( ((()((()   ( (  (  ( )) ((  )( ) (( ) )((((  ( () ) )( ( ()(( )( () ((( )(( ) )( ()((( ) ( )  ( )() (((( () ) (((( () ) ((() ) ()  ( (  (  ( )) ( )(  ((((( )) ((  )( ) (( ) )((((  ) )  ()(  ((() ( ()(( ) ( ) )(( ))(((  (( ) ((  ) ( ()(( )( ) ()  ( (  (  ( ()( ) )( ()(  ) ()  ( (  (  ( )( (( ( (( )  ((((( ))  ) )(( )) ((  )( ) (( ) )((((  ) ()( ))  ) ) (( )( () (((   ( ) )((  )( )(((( ))( )() ) ()( ))  (()( (()( ((()((()   ( (  (    (  ( )) ( )(  (((((( )(( ( (( )) ( ((  ) )( ) )( ( )( ((() ( )( ((() ( ()( ()( ()   ) )( ()(( ) ()  ( (  (    (  ( )) ( )(  (((((( )(( ( (( )) ( ((  ) )( ) )( ( )( (((( ( )( ((() ( ()( ()( (()( ) )( ()(( ) ()  ( (  (    (  ( )) ( )(  (((( ( ) ( ()( ((() ( ()( ())(( ) ( ) )( ()(( ))) ) ()  ( (  (  ((())  ( (  (  ((( ( ) )((( )( () ((( )(((   ( )) ( )  ( ) ) ((((( )) ((  )( ) (( ) )((((  (())( ))  (()( ()(( ((()  ( (  (  ( )(  ) )(((( ( () ((( ) ( ) )(( ((((   ( ()(( )  ( ) ) (((( () )( ((( ((((((()( ((() ((   () )( )(( (()) ( )( ( )( ((() ) ()  ( (  (  (( ) ( ) )(( ))(((  (( ) ((  ) ( ()( ) (( ) )(( ((( ()((( ) ( ) )((  ) (((((( )( () ((( ) ( ) )(( ((((   ( ()(( )  ( ) ) ((((((( ( (()) ( )( ) ) (( )((((  ( ()) ) )) ( )( (()(((  ) (()( ( )( ) )  () )(( )((((  ( ()) ) )) ( )( ((() (()( ( )(  ( (  ( ( ) ) (( )((((  ( ()) ) )) ( )( (()(((  ) (()( ( )( ( () ( )( (()(( )(  (()( ( )( ) )  () )(( )((((  ( ()) ) )) ( )( (())((  ) (()( ()(( ((() ) ()  ( (((())

Readable version.

( )( (((  ((  )( )  (( ))( )) (( ( ((  ) ( ()( ) (( ) )(( ((( ()((( ) 
( ) )((  ) (((((( )( (())((  ) ) )( ()(( ((()((()   ( (  (  ( )) ((  )
( ) (( ) )((((  ( () ) )( ( ()(( )( () ((( )(( ) )( ()((( ) ( )  ( )()
 (((( () ) (((( () ) ((() ) ()  ( (  (  ( )) ( )(  ((((( )) ((  )( ) (
( ) )((((  ) )  ()(  ((() ( ()(( ) ( ) )(( ))(((  (( ) ((  ) ( ()(( )(
 ) ()  ( (  (  ( ()( ) )( ()(  ) ()  ( (  (  ( )( (( ( (( )  ((((( )) 
 ) )(( )) ((  )( ) (( ) )((((  ) ()( ))  ) ) (( )( () (((   ( ) )((  )
( )(((( ))( )() ) ()( ))  (()( (()( ((()((()   ( (  (    (  ( )) ( )( 
 (((((( )(( ( (( )) ( ((  ) )( ) )( ( )( ((() ( )( ((() ( ()( ()( ()  
 ) )( ()(( ) ()  ( (  (    (  ( )) ( )(  (((((( )(( ( (( )) ( ((  ) )(
 ) )( ( )( (((( ( )( ((() ( ()( ()( (()( ) )( ()(( ) ()  ( (  (    (  
( )) ( )(  (((( ( ) ( ()( ((() ( ()( ())(( ) ( ) )( ()(( ))) ) ()  ( (
  (  ((())  ( (  (  ((( ( ) )((( )( () ((( )(((   ( )) ( )  ( ) ) ((((
( )) ((  )( ) (( ) )((((  (())( ))  (()( ()(( ((()  ( (  (  ( )(  ) )(
((( ( () ((( ) ( ) )(( ((((   ( ()(( )  ( ) ) (((( () )( ((( ((((((()(
 ((() ((   () )( )(( (()) ( )( ( )( ((() ) ()  ( (  (  (( ) ( ) )(( ))
(((  (( ) ((  ) ( ()( ) (( ) )(( ((( ()((( ) ( ) )((  ) (((((( )( () (
(( ) ( ) )(( ((((   ( ()(( )  ( ) ) ((((((( ( (()) ( )( ) ) (( )((((  
( ()) ) )) ( )( (()(((  ) (()( ( )( ) )  () )(( )((((  ( ()) ) )) ( )(
 ((() (()( ( )(  ( (  ( ( ) ) (( )((((  ( ()) ) )) ( )( (()(((  ) (()(
 ( )( ( () ( )( (()(( )(  (()( ( )( ) )  () )(( )((((  ( ()) ) )) ( )(
 (())((  ) (()( ()(( ((() ) ()  ( (((())

Interpreter

Mode 1

A Sacred interpreter in C++ was published by User:DanielJohnBenton in 2017. The repository includes an HTML/JavaScript conversion utility to convert between Sacred and Brainfuck to the extent that this is possible.

Mode 2

The following JavaScript function convert can be used to compile to Sacred M2, and devert to compile from Sacred M2:

function pad(e){return e.length>5?(e+".").slice(-6,-1):5==e.length?e:pad(" "+e)}function convert(e){return e.split("").map(function(e){return pad(e.charCodeAt().toString(3).replace(/0/g," ").replace(/1/g,"(").replace(/2/g,")"))}).join("")}function devert(e){e=e.match(/.{1,5}/g);for(var r=0;r<e.length;r++)e[r]=String.fromCharCode(parseInt(e[r].replace(/ /g,"0").replace(/\(/g,"1").replace(/\)/g,"2"),3));return e.join("")}