meillo@59: .TH baum 1 "2008-06-24" "baum 0.5" meillo@18: .SH NAME meillo@18: baum \- an esoteric programming language meillo@18: meillo@18: meillo@18: meillo@18: .SH SYNOPSIS meillo@18: .B baum meillo@31: [\-v]\ meillo@18: meillo@18: meillo@18: meillo@18: .SH DESCRIPTION meillo@18: .B baum meillo@18: is an interpreter for the baum programming language which is an experiment to create an esoteric programming language. meillo@18: meillo@18: Source code is a representation of a tree in which every node is a command or data. meillo@18: meillo@18: baum is only an experiment and the functionality is (currently) very restricted. meillo@18: meillo@18: meillo@18: meillo@18: meillo@18: .SH OPTIONS meillo@18: meillo@18: .TP meillo@18: .BI \-v meillo@42: Verbose output (All verbose output goes to stderr) meillo@18: meillo@18: .TP meillo@18: .BI \-\-help meillo@18: Print usage information meillo@18: meillo@18: .TP meillo@18: .BI \-\-version meillo@18: Print version information meillo@18: meillo@18: meillo@18: meillo@18: meillo@18: meillo@18: meillo@48: .SH CONCEPT meillo@48: meillo@48: baum programs are represented as nodes in a tree structure. Nodes are of specific kind and contain a value. meillo@48: meillo@48: The tree is processed recursive starting at the root node. Every node controls it's sons and should only know them; while most nodes only use their leftmost son. meillo@48: meillo@48: Each node returns a value to it's parent. (The root node returns an exit code to the shell.) The internal value of the node could be used in any useful way, but only inside the node. meillo@48: meillo@48: All values in the language (return values, expected return values and in-node values) should be of the same type, so that every combination of nodes is possible. meillo@48: meillo@48: Nodes can modify the tree, but should do this only on it's brothers or better only through it's rightmost brother. meillo@48: meillo@48: meillo@48: meillo@18: .SH SOURCE CODE meillo@18: meillo@18: Source code are plain text files with one node per line representing the tree. The indention controls in which level in the tree the node is. Indention can be made with SPACE or with TAB characters. Every character means one level. meillo@18: meillo@18: Empty lines and everything vom the hash symbol (`#') to the end of the line is ignored. meillo@18: meillo@37: .B An example that echoes (and returns) `42': meillo@18: meillo@18: .nf meillo@18: # comment meillo@18: print(0) meillo@18: sum(0) #comment meillo@18: number(40) meillo@18: number(2) meillo@18: .fi meillo@18: meillo@18: meillo@48: .SH NODES meillo@18: meillo@48: .TP meillo@51: .B create meillo@51: Creates a new number node as last brother. The value of the new node is ether read from standard input (if the node has no son), or the return value of the first son. Returns 0 always. meillo@18: meillo@48: .TP meillo@52: .B if meillo@52: Compares return value of first son and second son. The internal value defines how the comparation is done. 33 (`!') means not equal; 60 (`<') less than; 62 (`>') greater than; and everything else stands for equal. Requires two sons. Returns 1 for true and 0 for false. meillo@52: meillo@52: .TP meillo@48: .B number meillo@48: Executes it's leftmost son. Returns the internal value. meillo@18: meillo@48: .TP meillo@48: .B print meillo@48: Prints the return value of it's leftmost son. Ether as char (if the internal value is 99), or as number otherwise. Returns the return value of the leftmost son (passes through). meillo@18: meillo@48: .TP meillo@48: .B sum meillo@48: Executes all of it's sons. Returns the sum of their return values. meillo@18: meillo@48: .TP meillo@48: .B times meillo@48: Copies everything below the node and pastes it as last brother(s). Returns 0 always. meillo@18: meillo@52: .TP meillo@52: .B while meillo@52: Executes it's second son as long the first son returns a logical true (not `0'). Requires two sons. Returns 0 always; meillo@52: meillo@52: meillo@48: meillo@48: meillo@48: meillo@18: meillo@18: meillo@18: .SH ERRORS meillo@18: meillo@43: You have to keep in mind, that valid programs that run successful can return exit codes different from zero too! Each program returns the return value of the root node to the shell. If you don't want your program doing this, just set a `number(0)' node as root, and put everything else below. meillo@43: meillo@18: .TP meillo@18: .BI 1 meillo@18: common error meillo@18: meillo@18: .TP meillo@18: .BI 3 meillo@18: no or more than one source file given meillo@18: meillo@18: .TP meillo@18: .BI 4 meillo@18: invalid node meillo@18: meillo@18: .TP meillo@31: .BI 5 meillo@31: indention over more than one level meillo@31: meillo@31: .TP meillo@33: .BI 6 meillo@33: node name too long, or no value given meillo@33: meillo@33: .TP meillo@52: .BI 7 meillo@52: a node has not the required amount of sons meillo@52: meillo@52: .TP meillo@55: .BI 10 meillo@55: unable to open input file, unable to allocate memory, or something similar meillo@55: meillo@55: .TP meillo@42: .BI 126 meillo@18: invalid command line options meillo@18: meillo@18: meillo@18: meillo@18: .SH BUGS meillo@18: Please report if you find some. meillo@18: meillo@18: meillo@18: .SH CREDITS meillo@18: Ju developed the idea of meillo@18: .B baum meillo@18: with me in a conversation. Actually it was his idea to use the tree as basic structure. meillo@18: meillo@18: meillo@18: meillo@18: .SH AUTHOR meillo@18: markus schnalke and julian forster