Astroscript
Jump to navigation
Jump to search
Astroscript is a programming language designed by PSTF and his AI friend(you should know who is he).
Overview
Astroscript is esoteric so you may feel hard to program in it. It is based on Tag system.
Syntax
Because it is based on Tag system, we should define a fixed deletion number V(we assign it with 2), a command set Σ(such as capital alphanums), and a rule table.
Normal format
rules = { your rules } initial_queue = "" input = ""
Execution
When running a program, the system will repeatly do these until the queue length is less than V.
- Check the queue's head(s).
- If s is "!" or "?", do the I/O operations;
- Otherwise do the convert of program.
- I/O operations:
- Question mark:
- First, delete the first v characters in program queue.
- Then, get the symbol x from the input queue(if the input is ended then add an ending mark).
- Next, append x + "I" to the tail of queue. "I" is the internal type symbol.
- Bang mark:
- First, delete the first v characters in program queue.
- Then, output the second character being deleted to the screen.
- Next, append an empty string.
- Question mark:
- Normal operations:
- First, delete the first v characters in program queue.
- Then change the s into the rule of s, then append it to the tail.
Example
Cat program
rules = { 'I': "!x?I", 'A': "?AA" } initial_queue = "?AA" input = "Hello, world!"
Advantages and disadvantages:
Advantages
This esolang is Turing-complete because it is based on Tag system.
The I/O extension is easy to implement.
Challenges
This esolang is hard to debug.
This esolang needs many rules just for an input.
This esolang has a high difficulty to manage the queue length.
Interpreter?
def tag_io_interpreter(initial_queue, rules, input_stream, v=2): queue = list(initial_queue) output = [] input_ptr = 0 while len(queue) >= v: head = queue[0] if head == '?': del queue[:v] if input_ptr < len(input_stream): x = input_stream[input_ptr] input_ptr += 1 else: x = 'EOF' queue.extend([x, 'I']) elif head == '!': if len(queue) >= v: y = queue[1] output.append(y) del queue[:v] else: if head in rules: del queue[:v] queue.append(rules[head]) else: raise Exception(f"No rule for symbol '{head}'") return output