%{ // // Orbital // // Copyright: (c) 2009-2012 Cédric Lecacheur // (c) 2009-2012 Benjamin Huet // (c) 2012 Sam Hocevar // #if defined HAVE_CONFIG_H # include "config.h" #endif #include "core.h" #include "loldebug.h" using namespace lol; #include "../gun.h" #include %} %require "2.3" %debug %defines %skeleton "lalr1.cc" %name-prefix="orbital" %define parser_class_name "GunParser" %locations %parse-param { class GunCompiler& gc } %error-verbose %union { float fval; struct { float f0, f1, f2, f3, f4, f5, f6, f7; } args; } %start gun_description %token T_AI %token T_PAI %token T_CA %token T_SA %token T_TIM %token T_SO %token T_RD %token T_SPD %token T_MODA %token T_MODB %token T_FFB %token T_FFP %token T_FB %token T_FP %token T_SK %token T_LOOP %token T_END 0 %token NUMBER %type number %type args1 args2 args3 %{ #include "../gun-compiler.h" #undef yylex #define yylex gc.m_lexer->lex %} %% gun_description: gun_command_list T_END ; gun_command_list: gun_command | gun_command_list ',' gun_command ; gun_command: T_AI { gc.m_gun.m_angle = gc.m_gun.AimActor(); } | T_PAI args1 { gc.m_gun.PreAimActor($2.f0); } | T_CA args1 { gc.m_gun.m_pre_aim = $2.f0; } | T_SA args1 { gc.m_gun.m_angle = $2.f0; } | T_TIM args1 { gc.m_gun.m_round_duration = $2.f0; } | T_SO args1 { gc.m_gun.m_angle_offset = $2.f0; } | T_RD args1 { gc.m_gun.m_radius = $2.f0; } | T_SPD args1 { gc.m_gun.m_shoot_speed = $2.f0; } | T_MODA args3 { /* FIXME: 1st modifier */ } | T_MODB args3 { /* FIXME: 2nd modifier */ } | T_FFB args1 { for (int i = 0; i < (int)$2.f0; i++) gc.m_gun.Shoot(1); gc.m_gun.m_shoot_type = 1; gc.m_gun.m_round_timer = gc.m_gun.m_round_duration; } | T_FFP args1 { for (int i = 0; i < (int)$2.f0; i++) gc.m_gun.Shoot(0); gc.m_gun.m_shoot_type = 0; gc.m_gun.m_round_timer = gc.m_gun.m_round_duration; } | T_FB args1 { gc.m_gun.Shoot(1); gc.m_gun.m_nbshoots = (int)$2.f0 - 1; gc.m_gun.m_shoot_type = 1; gc.m_gun.m_round_timer = gc.m_gun.m_round_duration; } | T_FP args1 { gc.m_gun.Shoot(0); gc.m_gun.m_nbshoots = (int)$2.f0 - 1; gc.m_gun.m_shoot_type = 0; gc.m_gun.m_round_timer = gc.m_gun.m_round_duration; } | T_SK args1 { gc.m_gun.m_round_timer = gc.m_gun.m_round_duration * $2.f0; /* FIXME: modifiers */ } | T_LOOP { /* FIXME: loops */ } ; args1: number { $$.f0 = $1; } ; args2: args1 ',' number { $$ = $1; $$.f1 = $3; } ; args3: args2 ',' number { $$ = $1; $$.f2 = $3; } ; number: NUMBER { $$ = $1; } | '-' number { $$ = -$2; } ; %% void orbital::GunParser::error(const GunParser::location_type& l, const std::string& m) { gc.Error(l, m); }