예제 #1
0
파일: lispy.c 프로젝트: nvdnkpr/mpc
int main(int argc, char **argv) {
  
  mpc_parser_t* Number  = mpc_new("number");
  mpc_parser_t* Symbol  = mpc_new("symbol");
  mpc_parser_t* String  = mpc_new("string");
  mpc_parser_t* Comment = mpc_new("comment");
  mpc_parser_t* Sexpr   = mpc_new("sexpr");
  mpc_parser_t* Qexpr   = mpc_new("qexpr");
  mpc_parser_t* Expr    = mpc_new("expr");
  mpc_parser_t* Lispy   = mpc_new("lispy");

  mpca_lang(MPCA_LANG_PREDICTIVE,
    " number  \"number\"  : /[0-9]+/ ;                         "
    " symbol  \"symbol\"  : /[a-zA-Z0-9_+\\-*\\/\\\\=<>!&]+/ ; "
    " string  \"string\"  : /\"(\\\\.|[^\"])*\"/ ;             "
    " comment             : /;[^\\r\\n]*/ ;                    "
    " sexpr               : '(' <expr>* ')' ;                  "
    " qexpr               : '{' <expr>* '}' ;                  "
    " expr                : <number>  | <symbol> | <string>    "
    "                     | <comment> | <sexpr>  | <qexpr> ;   "
    " lispy               : /^/ <expr>* /$/ ;                  ",
    Number, Symbol, String, Comment, Sexpr, Qexpr, Expr, Lispy);

  if (argc > 1) {
    
    mpc_result_t r;
    if (mpc_parse_contents(argv[1], Lispy, &r)) {
      mpc_ast_print(r.output);
      mpc_ast_delete(r.output);
    } else {
      mpc_err_print(r.error);
      mpc_err_delete(r.error);
    }
    
  } else {
    
    mpc_result_t r;
    if (mpc_parse_pipe("<stdin>", stdin, Lispy, &r)) {
      mpc_ast_print(r.output);
      mpc_ast_delete(r.output);
    } else {
      mpc_err_print(r.error);
      mpc_err_delete(r.error);
    }
  
  }

  mpc_cleanup(8, Number, Symbol, String, Comment, Sexpr, Qexpr, Expr, Lispy);
  
  return 0;
  
}
예제 #2
0
파일: maths.c 프로젝트: 01000001/mpc
int main(int argc, char **argv) {
  
  mpc_parser_t *Expr  = mpc_new("expression");
  mpc_parser_t *Prod  = mpc_new("product");
  mpc_parser_t *Value = mpc_new("value");
  mpc_parser_t *Maths = mpc_new("maths");
  
  mpca_lang(MPCA_LANG_PREDICTIVE,
    " expression : <product> (('+' | '-') <product>)*; "
    " product : <value>   (('*' | '/')   <value>)*;    "
    " value : /[0-9]+/ | '(' <expression> ')';         "
    " maths : /^/ <expression> /$/;                    ",
    Expr, Prod, Value, Maths, NULL);
  
  mpc_print(Expr);
  mpc_print(Prod);
  mpc_print(Value);
  mpc_print(Maths);
  
  if (argc > 1) {
    
    mpc_result_t r;
    if (mpc_parse_contents(argv[1], Maths, &r)) {
      mpc_ast_print(r.output);
      mpc_ast_delete(r.output);
    } else {
      mpc_err_print(r.error);
      mpc_err_delete(r.error);
    }
    
  } else {

    mpc_result_t r;
    if (mpc_parse_pipe("<stdin>", stdin, Maths, &r)) {
      mpc_ast_print(r.output);
      mpc_ast_delete(r.output);
    } else {
      mpc_err_print(r.error);
      mpc_err_delete(r.error);
    }
  
  }

  mpc_cleanup(4, Expr, Prod, Value, Maths);
  
  return 0;
  
}
예제 #3
0
파일: repl.c 프로젝트: ikbenlike/Xenon
int repl(){
    char *a = calloc(1, 1000 * sizeof(char));
    xenon_stack_vector stack;
    stack.size = 1000;
    while(1){
        stack.vector = calloc(1, 1000 * sizeof(xenon_stack_item));
        printf("Xenon> ");
        input(a, 1000);
        if(strcmp(a, ".exit") == 0){
            return 0;
        }
        char *b = preprocessor(a);
        mpc_ast_t *ast = parse("stdin", b);
        free(b);
        if(ast != NULL){
            stack.cursor = 0;
            mpc_ast_print(ast);
            //vm_add_opcode_to_stack(&stack, HALT);
            tree_walker(ast, stack);
            vm_add_opcode_to_stack(&stack, CONST);
            vm_add_int_to_stack(&stack, 10);
            printf("%i\n", stack.cursor);
            VM *vm = vm_create(stack, 0);
            mpc_ast_delete(ast);
            vm_exec(vm, 0, false);
            vm_free(vm);
        }
        if(stack.vector != NULL){
            free(stack.vector);
        }
    }
    free(a);
    return 0;
}
예제 #4
0
int main(int argc, char** argv) {
  char* input;
  lispy_parser* parser = create_lispy_parser();
  mpc_result_t parser_result;

  puts("Lispy version 0");
  puts("Exit with ^C, ^D or \\q");

  while(1) {
    if (input != NULL) {
      free(input);
    }
    input = readline("lispy> ");
    add_history(input);

    if (input == NULL || strcmp(input, "\\q") == 0) {
      printf("\nBye!\n");
      break;
    } else {
      // TODO: Hide all of this parser stuff behind a facade
      if (mpc_parse("<stdin>", input, parser->Lispy, &parser_result)) {
        mpc_ast_print(parser_result.output);
        mpc_ast_delete(parser_result.output);
      } else {
        mpc_err_print(parser_result.error);
        mpc_err_delete(parser_result.error);
      }
    }
  }
}
예제 #5
0
파일: doge.c 프로젝트: 01000001/mpc
int main(int argc, char **argv) {
  
  mpc_parser_t* Adjective = mpc_new("adjective");
  mpc_parser_t* Noun      = mpc_new("noun");
  mpc_parser_t* Phrase    = mpc_new("phrase");
  mpc_parser_t* Doge      = mpc_new("doge");

  mpca_lang(MPCA_LANG_DEFAULT,
    " adjective : \"wow\" | \"many\" | \"so\" | \"such\";                 "
    " noun      : \"lisp\" | \"language\" | \"c\" | \"book\" | \"build\"; "
    " phrase    : <adjective> <noun>;                                     "
    " doge      : /^/ <phrase>* /$/;                                      ",
    Adjective, Noun, Phrase, Doge, NULL);

  if (argc > 1) {
    
    mpc_result_t r;
    if (mpc_parse_contents(argv[1], Doge, &r)) {
      mpc_ast_print(r.output);
      mpc_ast_delete(r.output);
    } else {
      mpc_err_print(r.error);
      mpc_err_delete(r.error);
    }
    
  } else {

    mpc_result_t r;
    if (mpc_parse_pipe("<stdin>", stdin, Doge, &r)) {
      mpc_ast_print(r.output);
      mpc_ast_delete(r.output);
    } else {
      mpc_err_print(r.error);
      mpc_err_delete(r.error);
    }
  
  }

  mpc_cleanup(4, Adjective, Noun, Phrase, Doge);
  
  return 0;
  
}
예제 #6
0
파일: prompt.c 프로젝트: leechannl/learning
int main(int argc, char** argv)
{
    /* Create some parsers */
    mpc_parser_t* Number = mpc_new("number");
    mpc_parser_t* Operator = mpc_new("operator");
    mpc_parser_t* Expr = mpc_new("expr");
    mpc_parser_t* Lispy = mpc_new("lispy");

    /* Define them with the following Language */
    mpca_lang(MPCA_LANG_DEFAULT,
            " \
                number: /-?[0-9]+/; \
                operator: '+' | '-' | '*' | '/'; \
                expr: <number> | '(' <operator> <expr>+ ')'; \
                lispy: /^/ <operator> <expr>+ /$/; \
            ",
            Number, Operator, Expr, Lispy);

    /* Print version and exit information */
    puts("Lispy Version 0.0.2");
    puts("Press Ctrl+c to Exit\n");

    /* In a never ending loop */
    while (1) {
        /* Output our prompt */
        char* input = readline("lispy> ");

        /* Add input to history */
        add_history(input);

        /* Attempt to parse the user input */
        mpc_result_t r;
        if (mpc_parse("<stdin>", input, Lispy, &r)) {
            /* On success print and delete the AST */
            mpc_ast_print(r.output);

            /* Eval */
            lval result = eval(r.output);
            lval_println(result);
            mpc_ast_delete(r.output);
        } else {
            /* Otherwise print and delete the Error */
            mpc_err_print(r.error);
            mpc_err_delete(r.error);
        }

        /* Free retrieved input */
        free(input);
    }

    /* Undefine and delete our parsers */
    mpc_cleanup(4, Number, Operator, Expr, Lispy);

    return 0;
}
예제 #7
0
int main(int argc, char *argv[])
{
    /* Create types */
    mpc_parser_t *Number = mpc_new("number");
    mpc_parser_t *Bool = mpc_new("bool");
    mpc_parser_t *Symbol = mpc_new("symbol");
    mpc_parser_t *Sexp = mpc_new("sexp");
    mpc_parser_t *Qexp = mpc_new("qexp");
    mpc_parser_t *Expr = mpc_new("expr");
    mpc_parser_t *Smallisp = mpc_new("Smallisp");
    
    /* Definintions */
    mpca_lang(MPC_LANG_DEFAULT,
	      "number   : /-?[0-9]+/ ;					"
	      "bool	: \"true\" | \"false\"  ;			"
	      "symbol   : /[a-zA-Z0-9_+\\-*\\/=<>!&]+/;		"
	      "sexp     : '(' <expr>* ')';				"
	      "qexp	: '{' <expr>* '}';				"
	      "expr     : <number> | <bool> | <char> | <symbol> | <sexp> | <qexp>;	"
	      "Smallisp : /^/ <sexp>* /$/ ;				",
	      Number, Bool, Symbol, Sexp, Qexp, Expr, Smallisp, NULL);

    puts("Lispy version 0.0.0.7\n");
    puts("Press Ctrl-C to exit\n");

    lenv *env = lenv_new();
    lenv_add_builtins(env);
    while(1) {
	char *input = readline("slisp> ");

	add_history(input);
	
	mpc_result_t r;
	if (mpc_parse("<stdin>", input, Smallisp, &r)) {
	    /* On success print AST */
	    lval *result = lval_eval(env, lval_read(r.output));
	    
	    lval_println(result);
	    lval_del(result);
	    mpc_ast_print(r.output);
	    mpc_ast_delete(r.output);
	} else {
	    /* Print error */
	    mpc_err_print(r.error);
	    mpc_err_print(r.error);
	}

	free(input);
    }
    lenv_del(env);
	
    mpc_cleanup(7, Number, Bool, Symbol, Sexp, Qexp, Expr, Smallisp);
    return 0;
}
예제 #8
0
int main(int argc, char **argv) {

  char *input;
  int exit;
  mpc_result_t ast;

  // Print version and exit information
  puts("Lispy version 0.0.0.0.1");
  puts("Press ctrl-c to exit\n");

  mpc_parser_t *Number = mpc_new("number");
  mpc_parser_t *Operator = mpc_new("operator");
  mpc_parser_t *Expr = mpc_new("expr");
  mpc_parser_t *Lispy = mpc_new("lispy");

  mpca_lang(MPCA_LANG_DEFAULT,
    "number : /-?[0-9]+/ ; \
     operator : '+' | '-' | '*' | '/' ; \
     expr : <number> | '(' <operator> <expr>+ ')' ; \
     lispy : /^/ <operator> <expr>+ /$/ ; \
    ", Number, Operator, Expr, Lispy);

  // In a never ending loop
  while(1) {
    // output our prompt
    input = readline("lispy> ");

    exit = strcmp(input, "exit");

    if (exit == 0) {
      puts("Bye!");
      break;
    }

    add_history(input);

    if (mpc_parse("<stdin>", input, Lispy, &ast)) {
      // On success, print the AST
      mpc_ast_print(ast.output);
      mpc_ast_delete(ast.output);
    } else {
      // Otherwise, print the error
      mpc_err_print(ast.error);
      mpc_err_delete(ast.error);
    }

    free(input);

  }

  mpc_cleanup(4, Number, Operator, Expr, Lispy);
  return 0;
}
예제 #9
0
파일: parsing.c 프로젝트: j4nu5/byol
int main() {
    /* Parsers */
    mpc_parser_t* Number        = mpc_new("number");
    mpc_parser_t* Operator      = mpc_new("operator");
    mpc_parser_t* Expression    = mpc_new("expression");
    mpc_parser_t* KLisp         = mpc_new("klisp");

    /* Language Definition */
    mpca_lang(MPCA_LANG_DEFAULT,
    "                                                               \
        number      : /-?[0-9]+(\\.[0-9]+)?/;                       \
        operator    : '+' | '-' | '*' | '/';                        \
        expression  : <number> | '(' <operator> <expression>+ ')';  \
        klisp       : /^/ <operator> <expression>+ /$/;             \
    ",
    Number, Operator, Expression, KLisp);

    printf("Welcome to KLisp v0.0.1\n");
    printf("To exit press Ctrl+c\n");

    while (1) {
        char *input = readline("klisp> ");

        if (!input) {
            printf("\n");
            break;
        }

        if (!strlen(input))
            continue;

        add_history(input);

        /* Process the input */
        mpc_result_t r;
        if (mpc_parse("<stdin>", input, KLisp, &r)) {
            mpc_ast_print(r.output);
            mpc_ast_delete(r.output);
        }
        else {
            mpc_err_print(r.error);
            mpc_err_delete(r.error);
        }

        free(input);
    }

    /* Cleanup */
    mpc_cleanup(4, Number, Operator, Expression, KLisp);
    return 0;
}
예제 #10
0
int main(int argc, char** argv) {
  
  /* Create Some Parsers*/
  
  mpc_parser_t* Number = mpc_new("number"); 
  mpc_parser_t* Operator = mpc_new("operator");
  mpc_parser_t* Expr = mpc_new("expr");
  mpc_parser_t* Lispy = mpc_new("lispy");
  
  /* Define them with the following Language */
  mpca_lang(MPCA_LANG_DEFAULT,
  "                                                     \
    number   : /-?[0-9]+/ ;                             \
    operator : '+' | '-' | '*' | '/' ;                  \
    expr     : <number> | '(' <operator> <expr>+ ')' ;  \
    lispy    : /^/ <operator> <expr>+ /$/ ;             \
  ",
  Number, Operator, Expr, Lispy);
   
  puts("Lispy Version 0.0.0.0.1");
  puts("Press Ctrl+c to Exit\n");
   
  while (1) {
    
    /* Now in either case readline will be correctly defined */
    char* input = readline("lispy> ");
    add_history(input);

    /* Attempt to Parse the user Input */
    mpc_result_t r;
    if (mpc_parse("<stdin>", input, Lispy, &r)) {
    		/* On Success Print the AST */
    		mpc_ast_print(r.output);
    		mpc_ast_delete(r.output);
    } else {
    		/* Otherwise Print the Error */
    		mpc_err_print(r.error);
    		mpc_err_delete(r.error);
    }
    
    free(input);
    
  }
  
  /* Undefine and Delete our Parsers */
	mpc_cleanup(4, Number, Operator, Expr, Lispy);
  
  return 0;
}
예제 #11
0
int main(int argc, char** argv) {

  /* Create Some Parsers */
  mpc_parser_t* Number   = mpc_new("number");
  mpc_parser_t* Operator = mpc_new("operator");
  mpc_parser_t* Expr     = mpc_new("expr");
  mpc_parser_t* Nilisp   = mpc_new("nilisp");

  /* Define them with the following Language */
  mpca_lang(MPCA_LANG_DEFAULT,
    "                                                    \
      number   : /-?[0-9]+(\\.[0-9]+)?/;                 \
      operator : '+' | '-' | '*' | '/' | '%' |           \
                \"add\" | \"sub\" | \"mul\" | \"div\";   \
      expr     : <number> | '(' <operator> <expr>+ ')' ; \
      nilisp   : /^/ <operator> <expr>+ /$/ ;            \
    ",
    Number, Operator, Expr, Nilisp);

  /* Print Version and Exit Information */
  puts("Nihilisp Version 0.0.0.0.1");
  puts("Created by @youfoundron");
  puts("Press Ctrl+c to Exit\n");

  while (1) {                           /* In a never ending loop */
    char* input = readline("nilisp> "); /* Output our prompt and get input */
    add_history(input);                 /* Add input to history */

    /* Atempt to Parse the user Input */
    mpc_result_t r;
    if (mpc_parse("<stdin>", input, Nilisp, &r)) {
      /* On Success Print the AST */
      mpc_ast_print(r.output);
      mpc_ast_delete(r.output);
    } else {
      /* Otherwise Print the Error */
      mpc_err_print(r.error);
      mpc_err_delete(r.error);
    }

    free(input);                        /* Free retrieved input */
  }

  /* Undefine and Delete our Parsers */
  mpc_cleanup(4, Number, Operator, Expr, Nilisp);
  return 0;
}
예제 #12
0
int main(int argc, char** argv) {

  /* Create some parsers */
  mpc_parser_t* Number = mpc_new("number");
  mpc_parser_t* Operator = mpc_new("operator");
  mpc_parser_t* Expr = mpc_new("expr");
  mpc_parser_t* Lithp = mpc_new("lithp");

  /* Define them with the following language */
  mpca_lang(MPCA_LANG_DEFAULT, 
    "\
    number : /-?[0-9]+/ ; \
    operator : '+' | '-' | '*' | '/' | '%' ; \
    expr : <number> | '(' <operator> <expr>+ ')' ; \
    lithp : /^/ <operator> <expr>+ /$/ ; \
    ",
  Number, Operator, Expr, Lithp);

  /* Print version and exit */
  puts("Lithp Version 0.0.0.0.1");
  puts("Suitable for absolutely nothing!");
  puts("Press Ctrl-C to exit\n");

  /* never ending storrr-y! */
  while(1) {
      /* output our prompt and get input */ 
      char* input = readline("lithp> ");
      /* add to our history */
      add_history(input);
      /* Attempt to parse the user input */
      mpc_result_t r;
      if (mpc_parse("<stdin>", input, Lithp, &r)) {
        /* On success, print the AST */
        mpc_ast_print(r.output);
        mpc_ast_delete(r.output);
      } else {
        /* Otherwise, print the error */
        mpc_err_print(r.error);
        mpc_err_delete(r.error);
      }
      /* free the malocs! */
      free(input);
  }
  /* Undefine and Delete our Parsers.  Or else... */
  mpc_cleanup(4, Number, Operator, Expr, Lithp);
  return 0;
}
예제 #13
0
int main(int argc, char** argv){
	/* Create some parsers */ 
	mpc_parser_t* Number 	= mpc_new("number");
	mpc_parser_t* Operator 	= mpc_new("operator");
	mpc_parser_t* Expr 		= mpc_new("expr");
	mpc_parser_t* Lispy 	= mpc_new("lispy");

	/* Define them with the following Language */
	mpca_lang(MPCA_LANG_DEFAULT,
		"														\
		number 		: /-?[0-9]+/;								\
		operator 	: '+' | '-' | '*' | '/';					\
		expr 		: <number> | '(' <operator> <expr>+ ')' ;	\
		lispy 		: /^/ <operator> <expr>+ /$/				\
		",
		Number, Operator, Expr, Lispy);

	/* Print Version and Exit information */
	puts("Lispy Version 0.0.0.0.1");
	puts("Press Ctrl-c to Exit\n");

	/* loop forever */
	while(1){		
		
		/* Output prompt and get input*/
		char* input = readline("lispy> ");

		/*Add input to history */
		add_history(input);

		/* Atempt to Parse user input */
		mpc_result_t r;
		if( mpc_parse("<stdin", input, Lispy, &r)){
			/* on sucess print the AST */
			mpc_ast_print(r.output);
			mpc_ast_delete(r.output);			
		}
		else {
			mpc_err_print(r.error);
			mpc_err_delete(r.error);
		}

		/* Free retrieved input */
		free(input);
	}
	return 0;
}
예제 #14
0
파일: parsing.c 프로젝트: atherlangga/lispc
int main(int argc, char** argv) {

    /* Create parsers */
    mpc_parser_t* Number    = mpc_new("number");
    mpc_parser_t* Operator  = mpc_new("operator");
    mpc_parser_t* Expr      = mpc_new("expr");
    mpc_parser_t* Lispc     = mpc_new("lispc");

    /* Define the language */
    mpca_lang(MPC_LANG_DEFAULT,
            "                                                       \
             number     : /-?[0-9]+/  ;                             \
             operator   : '+' | '-' | '*' | '/'  ;                  \
             expr       : <number> | '(' <operator> <expr>+ ')'  ;  \
             lispc      : /^/ <operator> <expr>+ /$/  ;             \
            ",
            Number, Operator, Expr, Lispc);

    puts("Silang version 0.0.1");
    puts("Press Ctrl+C to exit\n");

    /* Do the main loop for REPL */
    while (1) {
        char* input = readline("lispc > ");
        add_history(input);

        /* Process the input */
        mpc_result_t result;
        if (mpc_parse("<stdin>", input, Lispc, &result)) {
            mpc_ast_print(result.output);
            mpc_ast_delete(result.output);
        }
        else {
            mpc_err_print(result.error);
            mpc_err_delete(result.error);
        }

        free(input);
    }

    /* Clean up the parsers */
    mpc_cleanup(4, Number, Operator, Expr, Lispy);

    return 0;
}
예제 #15
0
int main(int argc, char** argv) {
    mpc_parser_t* Number    = mpc_new("number");
    mpc_parser_t* Operator  = mpc_new("operator");
    mpc_parser_t* Expr      = mpc_new("expr");
    mpc_parser_t* Lispy     = mpc_new("lispy");

    mpca_lang(MPCA_LANG_DEFAULT,
        " \
            number      : /-?[0-9]+/ ;                              \
            operator    : '+' | '-' | '*' | '/' ;                   \
            expr        : <number> | '(' <operator> <expr>+ ')' ;   \
            lispy       : /^/ <operator> <expr>+ /$/ ;              \
        ",
        Number, Operator, Expr, Lispy);

    puts("Slight-Lisp Version 0.0.1");
    puts("Press Ctrl+c to Exit\n");

    while(1) {

        char* input = readline("slight> ");
        if (input && input[0] != '\0') {
            add_history(input);
        }
        
        mpc_result_t r;
        if (mpc_parse("<stdin>", input, Lispy, &r)) {
            /* On success print the AST */
            mpc_ast_print(r.output);
            mpc_ast_delete(r.output);
        } else {
            /* Otherwise print error */
            mpc_err_print(r.error);
            mpc_err_delete(r.error);
        }

        free(input);
    }


    mpc_cleanup(4, Number, Operator, Expr, Lispy);
    return 0;
}
예제 #16
0
int main(int argc, char ** argv) {

    mpc_parser_t* Number = mpc_new("number");
    mpc_parser_t* Operator = mpc_new("operator");
    mpc_parser_t* Expression = mpc_new("expression");
    mpc_parser_t* Lispy = mpc_new("lispy");

    mpca_lang(MPCA_LANG_DEFAULT,
              "                                                         \
            number    : /-?[0-9]+/;                                   \
            operator  : '+' | '-' | '*' | '/';                        \
            expression: <number> | '(' <operator> <expression>+ ')';  \
            lispy     : /^/ <operator> <expression>+ /$/;             \
            ",
              Number, Operator, Expression, Lispy);

    puts("Lispy Version 0.0.0.0.1");
    puts("Press Ctrl+c to Exit\n");

    while(1) {
        char * input = readline("lispy> ");
        add_history(input);

        mpc_result_t result;
        if(mpc_parse("<stdin>", input, Lispy, &result)) {
            mpc_ast_print(result.output);
            mpc_ast_delete(result.output);
        } else {
            mpc_err_print(result.error);
            mpc_err_delete(result.error);
        }

        free(input);
    }

    mpc_cleanup(4, Number, Operator, Expression, Lispy);
}
예제 #17
0
파일: polish.c 프로젝트: hckrtst/cs-refresh
int main(int argc, char** argv) {
    /* Create parsers */
    mpc_parser_t* Number = mpc_new("number");
    mpc_parser_t* Operator = mpc_new("operator");
    mpc_parser_t* Expression = mpc_new("expression");
    mpc_parser_t* Lispy = mpc_new("lispy");
    
    linenoiseClearScreen();

    /* Define them with the language as follows */
    mpca_lang(MPCA_LANG_DEFAULT, 
            " number      : /-?[0-9]+/ ; "
             " operator    : '+' | '/' | '*' | '-' ; "
             " expression  : <number> | '(' <operator> <expression>+ ')' ; "
             " lispy        : /^/ <operator>* <expression> /$/ ; ", Number, Operator, Expression, Lispy);
    char *line = NULL;

    while((line = linenoise("Lispy> ")) != NULL ) {
        mpc_result_t result;

        if (mpc_parse("<stdin>" , line, Lispy, &result)) {
           mpc_ast_print(result.output);
           mpc_ast_delete(result.output);
        } else {
            mpc_err_print(result.output);
            mpc_err_delete(result.output);

        }

        free(line);
    }

    mpc_cleanup(4, Number, Operator, Expression, Lispy);

    return 0;
   
}