All pastes #839314 Raw Edit

k4st

public c v1 · immutable
#839314 ·published 2007-12-30 23:36 UTC
rendered paste body
#include <stdlib.h>#include <stdio.h>#include <string.h>#include "interpreter.h"/********************************** * Blah **********************************/void printStream(char *stream) {	int i, j;		/* Print out the stream with leading line numbers */	for(i = 1, j = 0; ; i++, j++) {		printf("\n%2d) ", i);		while(1) {						if(stream[j] == '\n' || stream[j] == '\0')				break;						printf("%c", stream[j]);						j++;		}				/* end of stream */		if(stream[j] == '\0') {			printf("\n\n");			break;		}	}}int main() {	SwParseTree *tree, *node;	unsigned int num_idents_guess = 0;			//char stream[] = "[1 to 10]()\nadder(x) => \\(y)=>x+y\nidentifier(arg1, arg2, ...) => do:\n\tz={a:'10',b:'20',c:'30'}\n\ty=[1,2,\"3\"]\n\twhile:\n\t\treturn()\n\t;\n;a = -b\ntest = 1+2+3+!x[1:5]\nmoo => 1*(7/8)\n";	char stream[] = "add2(x)=>x+2\nx=add2(2)";		printStream(stream);		/* Evaluate the tree, we start at BOF node */	tree = parse_stream(stream);		/* Push the global scope on to the stack */	SwScope_Push();	/*	toStringParseTree(car(tree), -1);	printf("\n\n");		toStringParseTree(cdr(tree), -1);	printf("\n\n");		exit(EXIT_SUCCESS);*/		//tree = cdr(tree);	//node = tree;	while((node = car(tree)) != NULL) {				SwStmt_Unpack(node);			//toStringParseTree(node, -1);		//printf("\n\n");				tree = cdr(tree);	}		/* Pop the global scope */	SwScope_Pop();		/* Free the parse tree */	free_parse_tree();		return 1;}