# HG changeset patch # User meillo@marmaro.de # Date 1204471038 -3600 # Node ID 7d7abe88e71bcd34d8b3efac709c5ede4e12c96c # Parent 0870e261bf2889f2cdc681d69193adf33da5cc34 "input" node is now "create" node and can handle more than user input now diff -r 0870e261bf28 -r 7d7abe88e71b actions.c --- a/actions.c Sun Mar 02 15:54:35 2008 +0100 +++ b/actions.c Sun Mar 02 16:17:18 2008 +0100 @@ -6,7 +6,7 @@ unsigned char action_print(struct Node* node); unsigned char action_sum(struct Node* node); unsigned char action_number(struct Node* node); -unsigned char action_input(struct Node* node); +unsigned char action_create(struct Node* node); unsigned char action_times(struct Node* node); unsigned char action_if(struct Node* node); unsigned char action_while(struct Node* node); @@ -30,8 +30,8 @@ } else if (strcmp(node->name, "number") == 0) { return action_number(node); - } else if (strcmp(node->name, "input") == 0) { - return action_input(node); + } else if (strcmp(node->name, "create") == 0) { + return action_create(node); } else if (strcmp(node->name, "times") == 0) { return action_times(node); @@ -81,11 +81,19 @@ } -unsigned char action_input(struct Node* node) { +unsigned char action_create(struct Node* node) { int input; - printf("input: "); - scanf("%d", &input); - input = input % 256; + + if (node->down == NULL) { + /* user input */ + printf("input: "); + scanf("%d", &input); + input = input % 256; + } else { + /* return value */ + input = action(node->down); + } + insertLast(node, newNode("number", (char) input)); return 0; } diff -r 0870e261bf28 -r 7d7abe88e71b baum.1 --- a/baum.1 Sun Mar 02 15:54:35 2008 +0100 +++ b/baum.1 Sun Mar 02 16:17:18 2008 +0100 @@ -1,4 +1,4 @@ -.TH baum 1 "2008-03-01" "baum 0.3" +.TH baum 1 "2008-03-01" "baum 0.4" .SH NAME baum \- an esoteric programming language @@ -74,8 +74,8 @@ .SH NODES .TP -.B input -Reads a number from standard input which is treated as ASCII value. It inserts a number node with this value as last brother. Returns 0 always. +.B create +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. .TP .B number