QSet interpreter


QSet is an esoteric programming language from the ABCTF-2016 challenge. The program is a sequence of pairs of symbol lists. The syntax is:

symbol = ALPHA
multiset = symbol / symbol " " multiset
instruction = multiset "|" multiset
program = instruction / instruction "\n" program

The semantic is like:

multiset<symbol> state = input
while True:
  for (L, R) : (multiset<symbol>, multiset<symbol>) in program:
    if R ⊆ S:
      state = state - R + L
  if state is not modified:
multiset<symbol> output = state

Both input and output are finite sequences of positive integers. Symbols i0, i1, i2 and so on are pre-defined with input sequence Symbols o0, o1 and so on are used for output.

About the project itself

Just an interpreter for such an interesting language. Made just for fun. By the way, I’ve solved that CTF challenge by writing a specific optimizing compiler which compiles programs into the QSet code.