Monthly Archives: February 2013

Script

Moved to CMake. Integrated script parsing to main project. Implemented two test script commands. Time to fill the rest.

Full commands list:

Catch, Class, Command, DriveSpeed, Event, Exception, ExFiles, FadeMask, Flags, Font, Image, Inventory, Language, Layer, List, Load, Local, Mouse, Object, Params, Path, Source, SubLocation, Template, Text, Try, Volume, Zone

Theoretically 100% implementation of this list is 100% implementation of the game.
Practically I don’t see any references to Tetris and i18n.
Stay tuned.

Script progress

A little update:

Formal grammar definition for GAG script is 99% finished.

It was found out, that scripts are somewhat dirty, with a lot of commented out code. From what I see, legacy GAG script parser was written by hand (without parser generators and lexical analyzers), and due to this, a lot of script errors were undetected. I implemented a lot of workarounds to support broken constructs, hope that’ll mimic original script parser behaviour, we’ll see.

Here’s flex definitions, if anybody interested. Full Bison and Flex sample is in SVN.

%option noyywrap
%option nounput

%{
#include "gag_script.tab.h"

extern int bison_line_num;
extern void flex_read_callback(char *, int *, int);
#define YY_INPUT(buf, result, max_size) flex_read_callback(buf, &result, max_size)
%}

%%

[ \t\r]                 { ;                               }
\/\*[^ ;\n]*            { ;                               }
\*.*\n                  { ++bison_line_num;               }
\[END\]                 { return FOOTER;                  }
[\[\]=;/\(\)]           { return yytext[0];               }
:+                      { return SEP;                     }
[a-zA-Z0-9_\.\-!#\+]+   { yylval = yytext; return STRING; }
,\ *                    { return COMA;                    }
\n                      { ++bison_line_num;               }
.                       { return UNDEFINED;               }

%%