Adj
Adj (a is ADd a to b, then Jump to c) aka a=a+b; goto c.
Architecture
The maintenance of data constitutes the bailiwick of a triad of variables, their agnominations restricted to the Latin minuscules a, b, and c, each such meted with a scalar signed integer number of any magnitude as its capacity.
Syntax
A majority of Adj's capabilities derives from a single instruction, their distinguishment's indicium the three operand's concrete values, whence is acquired to a high degree a similitude to a One Instruction Set Computer (OISC).
A divergent aspect from an OISC, however, ensues from the contingency for label definitions, furnishing an avenue for navigations across the program.
The following Extended Backus-Naur Form (EBNF) description shall elucidate the language's conformation:
program := { innerLine } , [ terminalLine ] ;
terminalLine := [ command ] ;
innerLine := [ command ] , newline ;
command := addAndJumpCommand
| addOnlyCommand
| jumpOnlyCommand
| outputAndJumpCommand
| outputOnlyCommand
| inputAndJumpCommand
| inputOnlyCommand
| labelDefinition
;
addAndJumpCommand := ADJ , variable , operand , jumpTarget ;
addOnlyCommand := ADJ , variable , operand , X ;
jumpOnlyCommand := ADJ , X , X , jumpTarget ;
outputAndJumpCommand := ADJ , "0" , operand , jumpTarget ;
outputOnlyCommand := ADJ , "0" , operand , X ;
inputAndJumpCommand := ADJ , "1" , variable , jumpTarget ;
inputOnlyCommand := ADJ , "1" , variable , X ;
labelDefinition := labelName , ":" ;
jumpTarget := labelName | variable | integerLiteral ;
labelName := potentialLabelName - invalidLabelNames ;
potentialLabelName := labelCharacter , { labelCharacter } ;
labelCharacter := character - ( whitespace | ":" ) ;
invalidLabelNames := ADJ | X | variable | integerLiteral ;
ADJ := "ADJ" ;
X := "X" ;
operand := integerLiteral | variable ;
variable := "a" | "b" | "c" ;
integerLiteral := [ "+" | "-" ] , digit , { digit } ;
digit := "0" | "1" | "2" | "3" | "4"
| "5" | "6" | "7" | "8" | "9"
;
whitespace := newline | space ;
newline := "\n" ;
space := " " | "\t" ;
Commands
Adj's instruction set bifurcates into two lineages: imprimis, the ADJ specimen, furnishing the paravaunt warklumes for the accomplishment of tasks. As a parergon, a statement dedicated to the definition of labels partakes of the proffered avails.
The control flow conduction may either transpire through label names or by adminiculum of line numbers, the enumeration commencing with one (1) for the first program row.
| Effect | Pattern | Description |
|---|---|---|
| Add and jump | ADJ a b c
|
Increments the variable a by the value of b and jumps to the label c. a must constitute one of the three admissible variable names. b must resolve to a variable name or a literal integer number. c must either resolve to a label name, a variable identifier, or an integer literal.
|
| Add only | ADJ a b X
|
Increments the variable a by the value of b and advances to the next command. a must constitute one of the three admissible variable names. b must resolve to a variable name or a literal integer number.
|
| Jump only | ADJ X X c
|
Jumps to the line designated by c, without a prevenient addition epiphenomenon. c must either resolve to a label name, a variable identifier, or an integer literal.
|
| Output and jump | ADJ 0 b c
|
Outputs the value stored in the variable b to the standard output and jumps to the label c. b must constitute one of the three admissible variable names. c must either resolve to a label name, a variable identifier, or an integer literal.
|
| Output only | ADJ 0 b X
|
Outputs the value stored in the variable b to the standard output and advances to the next command. b must constitute one of the three admissible variable names.
|
| Input and jump | ADJ 1 b c
|
Queries the standard input for an integer number, stores the same in the variable b, and jumps to the label c. b must constitute one of the three admissible variable names. c must either resolve to a label name, a variable identifier, or an integer literal.
|
| Input only | ADJ 1 b X
|
Queries the standard input for an integer number, stores the same in the variable band advances to the next command. b must constitute one of the three admissible variable names.
|
| Label definition | x:
|
Defines a label for navigational purposes. x must constitute a valid label name, comprehending one or more characters, except for whitespaces and colons (:); further, the thus assembled identifier ought to be differentiated from a decimal integer number in order to obviate confoundments with line numbers in ADJ commands.
|
Examples
Add 1 and 1
ADJ a 1 X ADJ b 1 X ADJ a b X ADJ 0 a X
Add in1 and in2
ADJ 1 a X ADJ 1 b X ADJ a b X ADJ 0 a X
Jump to line
ADJ 1 a X ADJ X X a
Truth-machine
This truth-machine implementation relies on the definition of labels as a polymechany for its navigational purposes:
ADJ 1 a X ADJ b 7 X ADJ b a X ADJ b a X ADJ 0 a X ADJ X X b case_of_zero: ADJ X X 11 case_of_one: ADJ 0 a case_of_one
Interpreter
- Common Lisp implementation of the Adj programming language.