binodu

From Esolang
Jump to navigation Jump to search

binodu is an esoteric programming language created by asiekierka in August 2011. It operates on the concept of very simple nodes, which can do simple logic operations or trigger different nodes.

Syntax

List of commands

<...> denotes required elements. [...] denotes optional elements.

[Automatic] [Output] Node a
   Default <True|False>
   Compare [Store] <And|Or>
       [Not] b
   Action <False|True>
       Fire b
       Store c

Explanation

  • Node a: Defines a node named "a". Can be Automatic (runs at every tick, where a new tick is made after all Automatic nodes have finished) and/or Output (its state is output after every tick, in format "a: True". Can also be OutputOnChange, which means the state is only printed out when it changes).
  • Compare [Store] And/Or: Nodes for which values to check. Can be And (all have to result in true) or Or (any can result in true). [Store] means that by default, the result of the compare is stored. The default result is True. The defualt Compare is And.
  • [Not] b: Check if node b is true (or false with Not)
  • Action <False|True>: Defines a list of actions to perform when the result of Compare is true (or false). If not specified, this Action will run always. Multiple Actions can be defined.
  • Fire b: Make Node b execute synchronously (Node a's execution pauses until Node b is fully finished).
  • Store c: Store the value of node c as your own. (The default value is false).
  • Default [True|False]: Defines the default value. Only read during interpreter initialization, otherwise ignored.

NOTE: Multiple pairs of compares/actions are allowed in one node. You can also nest those pairs inside of Actions.

Different commands

  • Copy [Previous] d: Copy the value of node d as your own.
  • Output [b]: Outputs the current state of itself (or a different node) to stdio (when 8 bits are output, it prints an ASCII character).
  • Stop: Stop the node from automatically executing. (If the node is fired off again, automatic execution is restored.)

Special nodes

WARNING: Nodes marked with [o] do not have to be implemented by an interpreter for it to support binodu.

  • True, False: Self-explanatory.
  • [o] InputA-Z,0-9,...: Is true if the key A, B, etc... is pressed.

Examples

Hello, World!

This Hello, World! is considerably optimized, however, it could probably be optimized further

 Automatic Node Hey
	Compare
	Action
		Output False
		Output True
		Fire TwoFalse
		Output True
		Output False
		Fire TwoFalse
		Fire Six
		Output False
		Output True
		Output False
		Output True
		Fire L
		Fire L
		Fire Six
		Fire TwoTrue
		Fire TwoTrue
		Fire Two
		Fire TwoTrue
		Fire TwoFalse
		Fire Two
		Fire TwoFalse
		Fire TwoFalse
 		Fire Seven
 		Fire Seven
 		Fire Six
 		Fire TwoTrue
		Fire TwoTrue
		Fire Seven
		Fire Two
		Fire L
		Fire Six
		Output False
		Output True
		Fire TwoFalse
		Fire Two
		Fire TwoFalse
		Output False
		Output True
		Stop
Node Six
	Compare
	Action
		Output False
		Fire TwoTrue
		Output False
Node L
	Compare
	Action
		Fire Six
		Fire TwoTrue
		Fire TwoFalse
Node Two
	Compare
	Action
		Fire TwoFalse
		Output True
		Output False
Node Seven
	Compare
	Action
		Output False
		Output True
		Fire TwoTrue
Node TwoTrue
	Compare
	Action
		Output True
		Output True
Node TwoFalse
	Compare
	Action
		Output False
		Output False

XOR Gate

Press A to toggle input 1, Z to toggle input 2. X to perform a XOR operation.

Automatic OutputOnChange Node ToggleA
    Compare
        InputA
    Action True
        Compare
            ToggleA
        Action True
            Store False
        Action False
            Store True
Automatic OutputOnChange Node ToggleZ
    Compare
        InputZ
    Action True
        Compare
            ToggleZ
        Action True
            Store False
        Action False
            Store True
Automatic OutputOnChange Node XOR1
    Compare
        InputX
    Action True
        Store False
        Compare And
            ToggleA
            ToggleZ
        Action False
            Compare And
                Not ToggleA
                Not ToggleZ
            Action False
                Store True

4-bit Linear Feedback Shift Register

Triggered with pressing L.

# This is an LFSR.
# Try to figure out how it works.
Node LFSRxor
    Compare
    Action
        Store False
        Compare And
            LFSRbit1
            LFSRbit2
        Action False
            Compare And
                Not LFSRbit1
                Not LFSRbit2
            Action False
                Store True
Automatic Node LFSRbit1
    Compare
        InputL
    Action True
        Fire LFSRxor
        Store LFSRbit2
        Fire LFSRbit2
        Output
        Output LFSRbit2
        Output LFSRbit3
        Output LFSRbit4
Node LFSRbit2
    Compare
    Action
        Store LFSRbit3
        Fire LFSRbit3
Node LFSRbit3
    Default True
    Compare
    Action
        Store LFSRbit4
        Fire LFSRbit4
Node LFSRbit4
    Compare
    Action
        Store LFSRxor

99 bottles of beer

Node CaSetDef
 Compare
 Action
  Store True
  Fire Ca2
  Fire Ca3
  Store False
Node Ca1
 Default True
 Compare
  Ca1
 Action True
  Store False
 Action False
  Store True
  Fire CaSetDef
Node Ca2
 Compare
  CaSetDef
 Action True
  Store False
 Action False
  Compare
   Ca2
  Action True
   Store False
  Action False
   Store True
   Fire Ca1
Node Ca3
 Compare
  CaSetDef
 Action True
  Store False
 Action False
  Compare
   Ca3
  Action True
   Store False
  Action False
   Store True
   Fire Ca2
Node Ca4
 Default True
 Compare
  Ca4
 Action True
  Store False
 Action False
  Store True
  Fire Ca3
Node CbSetDef
 Compare
 Action
  Store True
  Fire Cb2
  Fire Cb3
  Store False
Node Cb1
 Default True
 Compare
  Cb1
 Action True
  Store False
 Action False
  Store True
  Fire CbSetDef
  Fire Ca4
Node Cb2
 Compare
  CbSetDef
 Action True
  Store False
 Action False
  Compare
   Cb2
  Action True
   Store False
  Action False
   Store True
   Fire Cb1
Node Cb3
 Compare
  CbSetDef
 Action True
  Store False
 Action False
  Compare
   Cb3
  Action True
   Store False
  Action False
   Store True
   Fire Cb2
Node Cb4
 Default True
 Compare
  Cb4
 Action True
  Store False
 Action False
  Store True
  Fire Cb3
Node PrepDigit
 Compare
 Action
  Fire TwoFalse
  Fire TwoTrue
Node OutputDigitA
 Compare
 Action
  Fire PrepDigit
  Output Ca1
  Output Ca2
  Output Ca3
  Output Ca4
Node OutputDigitB
 Compare
 Action
  Fire PrepDigit
  Output Cb1
  Output Cb2
  Output Cb3
  Output Cb4
Node Newline
 Compare
 Action
  Fire TwoFalse
  Fire Two
  Fire TrueFalse
Node OutputDigits
 Compare Or
  Ca1
  Ca2
  Ca3
  Ca4
 Action True
  Fire OutputDigitA
 Action
  Fire OutputDigitB
Node KeepOnRunning
 Default True
 Compare Or
  Ca1
  Ca2
  Ca3
  Ca4
  Cb1
  Cb2
  Cb3
  Cb4
 Action False
  Store False
Node TrueFalse
 Compare
 Action
  Output True
  Output False
Node TwoFalse
 Compare
 Action
  Output False
  Output False
Node TwoTrue
 Compare
 Action
  Output True
  Output True
Node Two
 Compare
 Action
  Fire TwoFalse
  Fire TrueFalse
Node space
 Compare
 Action
  Fire Two
  Fire TwoFalse
  Fire TwoFalse
Node lowerB
 Compare
 Action
  Output False
  Fire TwoTrue
  Output False
  Fire Two
Node lowerO
 Compare
 Action
  Output False
  Fire TwoTrue
  Output False
  Fire TwoTrue
  Fire TwoTrue
Node upperT
 Compare
 Action
  Output False
  Fire TrueFalse
  Fire TrueFalse
  Output True
  Fire TwoFalse
Node lowerT
 Compare
 Action
  Output False
  Fire TwoTrue
  Fire TrueFalse
  Output True
  Fire TwoFalse
Node lowerL
 Compare
 Action
  Output False
  Fire TwoTrue
  Output False
  Fire TwoTrue
  Fire TwoFalse
Node lowerE
 Compare
 Action
  Output False
  Fire TwoTrue
  Fire Two
  Output True
Node lowerS
 Compare
 Action
  Output False
  Fire TwoTrue
  Output True
  Fire TwoFalse
  Fire TwoTrue
Node lower,
 Compare
 Action
  Fire Two
  Fire TwoTrue
  Fire TwoFalse
Node lower.
 Compare
 Action
  Fire Two
  Fire TwoTrue
  Fire TrueFalse
Node lowerF
 Compare
 Action
  Output False
  Fire TwoTrue
  Fire TwoFalse
  Fire TwoTrue
  Output False
Node lowerR
 Compare
 Action
  Output False
  Fire TwoTrue
  Output True 
  Fire Two
Node lowerP
 Compare
 Action
  Output False
  Fire TwoTrue
  Output True 
  Fire TwoFalse
  Fire TwoFalse
Node lowerN
 Compare
 Action
  Output False
  Fire TwoTrue
  Output False
  Fire TwoTrue
  Fire TrueFalse
Node lowerH
 Compare
 Action
  Output False
  Fire TwoTrue
  Output False
  Output True
  Fire TwoFalse
  Output False
Node lowerI
 Compare
 Action
  Output False
  Fire TwoTrue
  Output False
  Output True
  Fire TwoFalse
  Output True
Node lowerK
 Compare
 Action
  Output False
  Fire TwoTrue
  Output False
  Fire TrueFalse
  Fire TwoTrue
Node lowerA
 Compare
 Action
  Output False
  Fire TwoTrue
  Fire TwoFalse
  Fire TwoFalse
  Output True
Node lowerU
 Compare
 Action
  Output False
  Fire TwoTrue
  Fire TrueFalse
  Fire TrueFalse
  Output True
Node lowerW
 Compare
 Action
  Output False
  Fire TwoTrue
  Fire TrueFalse
  Fire TwoTrue
  Output True
Node lowerD
 Compare
 Action
  Output False
  Fire TwoTrue
  Fire TwoFalse
  Output True
  Fire TwoFalse
Node BottlesOfBeer
 Compare
 Action
  Fire lowerB
  Fire lowerO
  Fire lowerT
  Fire lowerT
  Fire lowerL
  Fire lowerE
  Fire lowerS
  Fire space
  Fire lowerO
  Fire lowerF
  Fire space
  Fire lowerB
  Fire lowerE
  Fire lowerE
  Fire lowerR
Node OnTheWall
 Compare
 Action
  Fire lowerO
  Fire lowerN
  Fire space
  Fire lowerT
  Fire lowerH
  Fire lowerE
  Fire space
  Fire lowerW
  Fire lowerA
  Fire lowerL
  Fire lowerL
Node TakeOneDown
 Compare
 Action
  Fire upperT
  Fire lowerA
  Fire lowerK
  Fire lowerE
  Fire space
  Fire lowerO
  Fire lowerN
  Fire lowerE
  Fire space
  Fire lowerD
  Fire lowerO
  Fire lowerW
  Fire lowerN
  Fire space
  Fire lowerA
  Fire lowerN
  Fire lowerD
  Fire space
  Fire lowerP
  Fire lowerA
  Fire lowerS
  Fire lowerS
  Fire space
  Fire lowerI
  Fire lowerT
  Fire space
  Fire lowerA
  Fire lowerR
  Fire lowerO
  Fire lowerU
  Fire lowerN
  Fire lowerD
  Fire lower,  
Automatic Node Bottles
 Compare
  KeepOnRunning
 Action True
  Fire OutputDigits
  Fire space
  Fire BottlesOfBeer
  Fire space
  Fire OnTheWall
  Fire lower,
  Fire space
  Fire OutputDigits
  Fire space
  Fire BottlesOfBeer
  Fire lower.
  Fire Newline
  Fire TakeOneDown
  Fire space
  Fire Cb4
  Fire KeepOnRunning
  Fire OutputDigits
  Fire space
  Fire BottlesOfBeer
  Fire space
  Fire OnTheWall
  Fire lower.
  Fire Newline
 Action False
  Stop

Implementations

asiekierka's Java implementation (v3)