????

From Esolang
Jump to navigation Jump to search

"????" is a language that only operates in "if" statements. It is made to intentionally do nothing except the "????" print statement that prints "?" (what the esolang is named after). "?" initiates an if statement, and then "??" on the next line for true, or "???" for false. If false, the program halts. There is also the "????" statement from before, that goes on the third line.

Any text beside "?" is ignored, so you can make comments without signifying them.

Example program:

? init if
?? true
???? output
? init if
??? false
???? output (doesn't trigger)

IMPLEMENTATION:

# ???? interpreter
from rich import print
from sys import exit
from re import sub

ifstage = 0

# replace question/main.question with the file name #
with open("question/main.question") as file:
    lines = file.readlines()

for line in lines:
    line = line.strip()
    line = sub(r"[^?]", "", line)

    if line == "?":
        if ifstage != 1:
            ifstage = 1
        else:
            exit()
    
    elif line == "??":
        if ifstage == 1:
            ifstage = 2
        else:
            exit()
    
    elif line == "???":
        exit()

    elif line == "????":
        if ifstage == 2:
            print("?")
            ifstage = 0
        else:
            exit()