Graphene

Graphene is an esoteric programming language created by Baltdev (talk) in 2024.
The program structure is defined by an arbitrary graph structure.
The language is very difficult to type, and would be much easier to program in with a visual editor. Unfortunately, no such editor exists.
== Layout ==
A program is laid out as a graph with nodes and edges.
At the start of the file, an Exit node must be specified:
 exit a
Each line contains either a node:
 -- node a: Attribute
 node foo: Constant<1>
 node bar: Memory
or an edge:
 -- edge: idx a -> idx b
 edge: 0 foo -> 0 bar
 edge: 1 foo -> 0 baz
Edges connected to the same node must have unique indices.
Comments start at the start of the line with --, and extend to the end of the line.
All edges must only refer to nodes that have already been specified in lines above them.
== Values ==
There are 8 different types of value that can be manipulated by a grapheme program.
All values are immutable.
 Caption text
Type 	Example 	Description
Null 	! 	Unit type. Can only ever have one value. Represents an empty space.
Char 	'a' 	A single Unicode character, stored as 4 bytes.
Int 	123 	A two's complement signed 32-bit integer.
Float	NaN 	A 32-bit IEEE 754 floating point number.
Bool 	true 	A boolean value.
Tuple	(1, 2.0, "3")	A fixed-size collection of heterogenous values.
Type 	Char 	An enumeration over all types in Graphene.
A string is a tuple of characters with special syntactic sugar.
 "Hello" -> ('H', 'e', 'l', 'l', 'o')
== Structure ==
The following attributes of a node can specify its behavior:
 Node behaviors
Attribute 	Inputs	Outputs	Description
Memory 	0 	0 	Holds a value, and passes a clone of that value to all output edges when needed. May be overwritten by passing a value into input edge 0. Starts as Null.
Constant<Value>	 	* 	Passes a constant value to all output edges whenever requested.
Input 	 	0 	When a value is requested, passes a single Char from stdin to output edge 0.
Output 	0 	0 	When a value is passed into input edge 0 of this node, it is passed into output edge 0 unchanged AND output to stdout.
Copy 	0 	* 	Requests a value from input edge 0, and passes it to all output edges.
Mix 	* 	0 	Requests a value from all input edges, and passes the value from the first edge that returns a value (in order), or Null if none do, to output edge 0.
Head 	0 	0 1 	Requests a Tuple from input edge 0, and passes the tuple's trailing values and its head value to output edges 0 and 1 respectively. If the tuple doesn't have enough values, then Null is passed as needed.
Tail 	0 	0 1 	Requests a Tuple from input edge 0, and passes the tuple's leading values and its tail value to output edges 0 and 1 respectively. If the tuple doesn't have enough values, then Null is passed as needed.
Cons 	0 1 	0 	Requests a Tuple and Value from input edges 0 and 1, and returns that tuple with the value prepended to edge 0.
Concat 	0 1 	0 	Requests two Tuples from input edges 0 and 1, and returns a tuple with the two concatenated to edge 0.
Alternate 	0 1 	? 	Requests a boolean value from input edge 0, and if it's true, passes the value in input edge 1 to output edge 0. Otherwise, it's passed to output edge 1.
Sum 	0 1 	0 	Requests two numeric values from input edges 0 and 1, and returns the sum of them to output edge 0.
Difference 	0 1 	0 	Requests two numeric values from input edges 0 and 1, and returns the difference of them to output edge 0.
Product 	0 1 	0 	Requests two numeric values from input edges 0 and 1, and returns the product of them to output edge 0.
Quotient 	0 1 	0 	Requests two numeric values from input edges 0 and 1, and returns the quotient of them to output edge 0.
Negation 	0 	0 	Requests a numeric or boolean value from input edge 0, and returns the negation of it to output edge 0.
Exponent 	0 1 	0 	Requests two numeric values from input edges 0 and 1, and returns input 0 raised to input 1 to output edge 0.
Equal 	0 1 	0 	Requests two values from input edges 0 and 1, and returns a boolean on output edge 0 saying whether they are equal.
Less 	0 1 	0 	Requests two numeric values or Chars from input edges 0 and 1, and returns a boolean on output edge 0 saying whether input 0 is less than input 1.
Greater 	0 1 	0 	Requests two numeric values or Chars from input edges 0 and 1, and returns a boolean on output edge 0 saying whether input 0 is greater than input 1.
Or 	0 1 	0 	Requests two Boolean values from input edges 0 and 1, and returns a boolean on output edge 0 saying if either of them were true. Short-circuts.
And 	0 1 	0 	Requests two Boolean values from input edges 0 and 1, and returns a boolean on output edge 0 saying if both of them were true. Short-circuts.
Or' 	0 1 	0 	Requests two Boolean values from input edges 0 and 1, and returns a boolean on output edge 0 saying if either of them were true. Doesn't short circut.
And' 	0 1 	0 	Requests two Boolean values from input edges 0 and 1, and returns a boolean on output edge 0 saying if both of them were true. Doesn't short circut.
Xor 	0 1 	0 	Requests two Boolean values from input edges 0 and 1, and returns a boolean on output edge 0 saying if one or the other was true, but not both.
Cast 	0 1 	0 1 	Requests any value on edge 0 and a Type on edge 1, and attempts to convert the value to the type. Returns a boolean on edge 1 saying whether conversion was successful, and the value or Null on edge 0. Conversion to Null will always succeed.
Switch 	0 1 	? 	Requests an Integer on edge 0 and any value on edge 1, and returns the value to the edge specified by the integer.
Entry 	-> 	0 	When on the main execution path, outputs on edge 0 a Tuple of Tuples of Chars, being the command line arguments to the program. Otherwise, returns the values passed into Call to the specified output edges.
Exit 	* 	-> 	When on the main execution path, halts the program with an integer requested from input edge 0 as the exit code. Otherwise, returns the values on its input edges to the corresponding output edges on the Call node this was branched from.
Call<Node> 	* 	* 	Requests a value from all input edges, and moves to the corresponding Entry node, outputting values on that node's output edges. If the other node encounters an Exit, returns its values to its corresponding output edges.
Delay 	0 	[0] 	Waits one generation to pass its input on edge 0 to its output on edge 0. This node is the only way to plug a node's output value back into itself.
Category:Unimplemented
Category:2024
Category:Languages