extern FILE *yyin;
extern char *yytext;
-int compile_image(FILE *fp)
+int compile_image()
{
- while(!feof(fp)) {
+ while(!feof(yyin)) {
struct Object* ast = create_list_object(); // clone_object(list_object);
struct Object* scope = create_list_object(); //clone_object(list_object);
#include <stdio.h>
-int compile_image(FILE *fp);
+int compile_image();
void execute(struct Object *ast);
struct Object* execute_branch(struct Object *ast, struct Object *scope);
#include "object.h"
#include "interp.h"
+#include "error.h"
-int main() {
+extern FILE *yyin;
+
+int main(int argc, char **argv) {
+
+ yyin = stdin;
+ if(argc == 2) {
+ yyin = fopen(argv[1], "r");
+ if (yyin == NULL) {
+ fail("unable to open file : %s", argv[1]);
+ }
+ }
init_object_system();
puts("this is mojo.");
- compile_image(stdin);
+ compile_image();
return 0;
}
-%{
- /* Everything is supposed to be under control */
-%}
-z := truc
-s := 3
-Lexer yylex;
+2 + 2 ;
+2 + 2 ;