123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- use strict;
- use warnings;
- require "structure.pl";
- require "game_data.pl";
- # default data
- my $file_structure = "game_structure";
- # compilation data
- my @src_files = ();
- my $target;
- # argument loop
- while (my $arg = shift) {
- # new structure
- if ($arg eq "-s") {
- $file_structure = shift;
- }
- # open game data and check their structure
- elsif ($arg eq "-c") {
- # file to check
- my $file = shift;
- # structure to check against
- my $structure = game_structure_open($file_structure);
- if (!$structure) {
- printf("error reading structure: $file_structure\n");
- exit 0;
- }
-
- # get game data from file
- my $game_data = read_file($file);
- if (!$game_data) {
- printf("error reading game data: $file\n");
- exit 0;
- }
- # check data
- if (check_data($game_data, $structure)) {
- printf("file '$file' is structured based on $file_structure\n");
- }
- else {
- printf("file '$file' is NOT structure based on $file_structure\n");
- }
- } # -c : check data against structure
- elsif ($arg eq "-t") {
- $target = shift;
- }
- else {
- push @src_files, $arg;
- }
- } # argument loop
- if ($target eq "python") {
- if (@src_files <= 0) {
- printf("no source files given\n");
- exit 0;
- }
- # currently it only parses the first of the source files only
- my $game_data = read_file($src_files[0]);
- if (!$game_data) {
- printf("compilation error: $src_files[0]\n");
- exit 0;
- }
- # compile to python
- require("compile_to_python.pl");
- compile_to_python($game_data);
- }
|