Segmentation Fault

From Esolang
Jump to navigation Jump to search

Segmentation Fault is a programming language made by User:Not_Applicable. It has only one valid program:

Segmentation fault

And that prints "Hello, World!". Any other program throws a syntax error:

Syntax eror

and it immediately destroys both the interpreter and the file containing the program.

Sample programs

Hello, World!

Segmentation fault

Quine

Syntax eror

Interpreter

There is an interpreter written in bash:

if [ $# = "1" ]
then
read Program < "$1"
if [ "$Program" = "Segmentation fault" ]
then
echo "Hello, World!"
exit
fi
fi
echo "Syntax eror"
rm "$0"
rm "$1"

Another interpreter in Python:

import sys,os
program=sys.argv[1]
with open(program,'r') as f:
    code=f.read()
if code=='Segmentation fault':
    print("Hello World!")
else:
    print("Syntax eror")
    os.remove(sys.argv[0])
    os.remove(program)