Esempio n. 1
0
struct preset *generate_ast(char *preset_code)
{
	struct scanner *s;
	int tok;
	char *identifier;
	void *p;
	struct preset *ast;
	
	s = new_scanner(preset_code);
	ast = NULL;
	p = ParseAlloc(malloc);
	tok = scan(s);
	while(tok != TOK_EOF) {
		identifier = malloc(IDENTIFIER_SIZE);
		get_token(s, identifier, IDENTIFIER_SIZE);
		Parse(p, tok, identifier, &ast);
		if(tok == TOK_ERROR) {
			printf("Scan error\n");
			break;
		}
		tok = scan(s);
	}
	Parse(p, TOK_EOF, NULL, &ast);
	ParseFree(p, free);
	delete_scanner(s);

	if(ast == NULL) {
		printf("Parse error\n");
		return NULL;
	}

	return ast;
}
Esempio n. 2
0
int
main(void) {
    struct Scanner * scanner = new_scanner();
    struct Parser * parser = new_parser();
    parse(parser);
    return 0;
}
Esempio n. 3
0
File: game.c Progetto: phoboz/yz
void init_game(int tile_index)
{
  if ((game_hero = load_actor_XML("aron.stat")) == NULL) {
    fprintf(stderr, "ERROR - Unable to initialize hero.\n");
    exit(1);
  }

  if ((game_player = new_player(128 * 32, 96 * 32, game_hero)) == NULL) {
    fprintf(stderr, "ERROR - Unable to initialize player.\n");
    exit(1);
  }

  if ((game_world = new_world("world.png", tile_index,
                         game_player->x, game_player->y,
                         300, 200,
	                 DEFAULT_CELL_WIDTH, DEFAULT_CELL_HEIGHT)) == NULL) {
    fprintf(stderr, "ERROR - Unable to initialize world\n");
    exit(1);
  }

  if ((game_scanner = new_scanner("marker4x4.png")) == NULL) {
    fprintf(stderr, "ERROR - Unable to initialize scanner\n");
    exit(1);
  }

  if ((game_battle = new_battle(game_world)) == NULL) {
    fprintf(stderr, "ERROR - Unable to initialize battle\n");
    exit(1);
  }

  set_game_state(GAME_STATE_WORLD);

  update_game();
}
Esempio n. 4
0
PUBLIC Stream *
new_stream (char * filename, char * mode) {
    Stream * strm = NEW (Stream);
    StreamPrivate * priv = NEW (StreamPrivate);
    
    priv->s = new_scanner (NULL);
    priv->o = new_out ();
    
    strm->priv = priv;
    strm->Open = StrmOpen;
    strm->Close = StrmClose;
    strm->Write = StrmWrite;
    strm->WriteFmt = StrmWriteFmt;
    strm->WriteBinary = StrmWriteBinary;
    strm->Read = StrmRead;
    strm->ReadBinary = StrmReadBinary;
    strm->ReWind = StrmReWind;
    strm->GetDescriptor = StrmGetDescriptor;
    strm->SetDescriptor = StrmSetDescriptor;

    strm->dtor = StrmDtor;
    if (filename != NULL && mode != NULL) {        
        if ((stream (strm)->Open (filename, mode)) == 0) {
            stream (strm)->dtor ();
            strm = NULL;
        }
    }

    return strm;
}
Esempio n. 5
0
int
main (int argc, char ** argv) {
    int a;
    
    Scanner * in = new_scanner (stdin);
    Out * o = new_out ();
    
    a = scanner (in)->getInt ();law
    
//    printf ("%d", a);  
    out(o)->Stdout ("%d", a);
   
    scanner (in)->dtor ();
    return 0;
}