Wolfgang

From Esolang
Jump to navigation Jump to search

Wolfgang[1] is a programming language made by User:Myname, based on Wikipedia:Petri nets.

Code

The source code basically consists of a list of arcs. During runtime, arcs will be evaluated in the same order as they appear in the source code. If a Transition cannot be active, other Places with Arcs to it will not be evaluated.

The following are valid arcs:

  • -> Pid or -x-> Pid: Add Tokens to Place 'id'
  • Pa -> Tb or Pa -x-> Tb or Pa -° Tb: Make the Place 'a' an input place of the Transition 'b'
  • Tb -> Pa or Tb -x-> Pa: Make the Place 'a' an output place of the Transition 'b'

-x-> moves x Tokens from/to the corresponding Places iff the Transition is active. -> is identical to -1-> and -° is an inhibitor arc.

Special Places

  • 'OUT' is treated as a special Place which just outputs the char to a corresponding ascii code.
  • 'IN' is treated as a special Place which holds the ascii code of a char from user input.

Examples

A simple truth-machine:

Pinit -° Tstart                                                                        
PIN -49-> Tstart
Tstart -> Pdata
Tstart -> Pinit
Pdata -> Ttrue
Pdata -° Tfalse
Pblock -° Tfalse
Tfalse -48-> POUT
Tfalse -> Pblock
Ttrue -49-> POUT
Ttrue -32-> POUT
Ttrue -> Pdata

A larger example that substracts one number from another using step-wise decrement and prints it, as long as the result is between 1 and 9:

-9-> Pregister                                                                         
-3-> Pdec
Pdec -> Tdecnz
Pregister -> Tdecnz
Tdecnz -> Ptrash
Pdec -> Tdecz
Pregister -° Tdecz
Tdecz -> Ptrash
Pinc -° Tprint
Pdec -° Tprint
Tprint -> Pprint
Pregister -9-> Tp9
Pprint -> Tp9
Pregister -8-> Tp8
Pprint -> Tp8
Pregister -7-> Tp7
Pprint -> Tp7
Pregister -6-> Tp6
Pprint -> Tp6
Pregister -5-> Tp5
Pprint -> Tp5
Pregister -4-> Tp4
Pprint -> Tp4
Pregister -3-> Tp3
Pprint -> Tp3
Pregister -2-> Tp2
Pprint -> Tp2
Pregister -> Tp1
Pprint -> Tp1
Tp9 -57-> POUT
Tp8 -56-> POUT
Tp7 -55-> POUT
Tp6 -54-> POUT                                                                         
Tp5 -53-> POUT
Tp4 -52-> POUT
Tp3 -51-> POUT
Tp2 -50-> POUT
Tp1 -49-> POUT

Since building a finite-state automaton with Wolfgang should be trivial, it should be turing complete with this, because you obviously can do branch if zero with an inhibitor arc and simulate a Minsky machine with two registers.

External resources