Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Showing
with 954 additions and 250 deletions
#pragma once
#include "../../../Player/Player.h"
class ExpressionInt
{
public:
......@@ -32,6 +35,18 @@ public:
int evaluate() override;
};
// Expression represents an
// index of current player
class ExpressionInt_PlayerIndex : public ExpressionInt
{
private:
PlayersSet* players;
public:
ExpressionInt_PlayerIndex(PlayersSet* players);
int evaluate() override;
};
// Expression represents negation
// of expression
class ExpressionInt_Neg : public ExpressionInt
......
#include "InstructionNextPlayer.h"
//
InstructionNextPlayer::InstructionNextPlayer(PlayersSet* players, std::string type, ExpressionInt* id_expr)
: players(players), player_type(type), player_id(id_expr)
{}
Instruction* InstructionNextPlayer::Run()
{
players->setNextPlayer(player_type, player_id->evaluate());
return next;
}
//*/
\ No newline at end of file
#pragma once
#include "../../Player/Player.h"
#include "Instruction.h"
#include "Expression/ExpressionInt.h"
//
class InstructionNextPlayer : public Instruction
{
private:
PlayersSet* players;
std::string player_type;
ExpressionInt* player_id;
public:
InstructionNextPlayer(PlayersSet* players, std::string type, ExpressionInt* id_expr);
Instruction* Run() override;
};
//*/
......@@ -5,6 +5,7 @@
#include "Instruction/InstructionAssign.h"
#include "Instruction/InstructionReturn.h"
#include "Instruction/InstructionConditionalJump.h"
#include "Instruction/InstructionNextPlayer.h"
#include "../DataSet/DataSet.h"
class InstructionBlock
......@@ -13,9 +14,6 @@ private:
Instruction* entry_point;
//void* return_ptr = NULL;
//VAR_TYPE return_type;
Variable* return_value;
public:
......
#include "IPlayer.h"
std::string IPlayer::makeMove(DataSet* state_data, std::unordered_map<std::string, DataSet*> moves_map)
{
return std::string();
}
void IPlayer::Payoff(int payoff)
{}
#pragma once
#include <string>
#include "../DataSet/DataSet.h"
class IPlayer
{
public:
virtual std::string makeMove(DataSet* state_data, std::unordered_map<std::string, DataSet*> moves_map);
virtual void Payoff(int payoff);
};
#include "Player.h"
Player::Player(std::string player_type, int player_id)
: player_type(player_type), player_id(player_id), player(NULL)
{}
int Player::getId()
{
return player_id;
}
std::string Player::getType()
{
return player_type;
}
void Player::setPlayer(IPlayer* player)
{
this->player = player;
}
void Player::setPayoff(int payoff)
{
player->Payoff(payoff);
this->payoff = payoff;
}
std::string Player::makeMove(DataSet* state_data, std::unordered_map<std::string, DataSet*> moves_map)
{
return player->makeMove(state_data, moves_map);
}
void Player::print()
{
std::cout << player_type << " " << player_id << " payoff: " << payoff << '\n';
}
Player* PlayersSet::getPlayer(std::string type, int id)
{
// OPTIMIZATION: add map to avoid linear searching
for (Player* p : players)
if (p->getId() == id && p->getType() == type)
return p;
return NULL;
}
PlayersSet::PlayersSet(std::list<Player*> players)
: players(players), on_move(NULL)
{
if (players.size() == 0)
{
std::cout << "Warning: Players set is empty\n";
return;
}
on_move = players.front();
}
void PlayersSet::setNextPlayer(std::string type, int id)
{
Player* player = getPlayer(type, id);
if (player)
{
on_move = player;
return;
}
std::cout << "Execution Error: Player does not exist: " << type << '[' << id << "]\n";
on_move = NULL;
}
void PlayersSet::setNextPlayer(Player* player)
{
on_move = player;
}
Player* PlayersSet::getCurrentPlayer()
{
return on_move;
}
std::list<Player*> PlayersSet::getPlayersList()
{
return players;
}
void PlayersSet::setPlayer(IPlayer* i_player, std::string player_class, int player_id)
{
Player* player = getPlayer(player_class, player_id);
if (player)
{
player->setPlayer(i_player);
return;
}
std::cout << "Execution Error: Player does not exist: " << player_class << '[' << player_id << "]\n";
on_move = NULL;
}
std::string PlayersSet::makeMove(DataSet* state_data, std::unordered_map<std::string, DataSet*> moves_map)
{
return on_move->makeMove(state_data, moves_map);
}
void PlayersSet::print()
{
on_move->print();
std::cout << '\n';
for (Player* p : players) p->print();
}
#pragma once
#include <iostream>
#include <string>
#include <list>
#include "IPlayer.h"
class Player
{
private:
std::string player_type;
int player_id;
IPlayer* player;
int payoff = 0; // Payoff for game (to refactor)
public:
Player(std::string player_type, int player_id);
int getId();
std::string getType();
void setPlayer(IPlayer* player);
void setPayoff(int payoff);
std::string makeMove(DataSet* state_data, std::unordered_map<std::string, DataSet*> moves_map);
void print();
};
class PlayersSet
{
private:
std::list<Player*> players;
Player* on_move;
Player* getPlayer(std::string type, int id);
public:
PlayersSet(std::list<Player*> players);
void setNextPlayer(std::string type, int id);
void setNextPlayer(Player* player);
Player* getCurrentPlayer();
std::list<Player*> getPlayersList();
void setPlayer(IPlayer* i_player, std::string player_class, int player_id);
std::string makeMove(DataSet* state_data, std::unordered_map<std::string, DataSet*> moves_map);
void print();
};

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29509.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameCompiler", "GameCompiler.vcxproj", "{E6E0A92C-B54B-4635-A994-6165BA1681CD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E6E0A92C-B54B-4635-A994-6165BA1681CD}.Debug|x64.ActiveCfg = Debug|x64
{E6E0A92C-B54B-4635-A994-6165BA1681CD}.Debug|x64.Build.0 = Debug|x64
{E6E0A92C-B54B-4635-A994-6165BA1681CD}.Debug|x86.ActiveCfg = Debug|Win32
{E6E0A92C-B54B-4635-A994-6165BA1681CD}.Debug|x86.Build.0 = Debug|Win32
{E6E0A92C-B54B-4635-A994-6165BA1681CD}.Release|x64.ActiveCfg = Release|x64
{E6E0A92C-B54B-4635-A994-6165BA1681CD}.Release|x64.Build.0 = Release|x64
{E6E0A92C-B54B-4635-A994-6165BA1681CD}.Release|x86.ActiveCfg = Release|Win32
{E6E0A92C-B54B-4635-A994-6165BA1681CD}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1A3BE76F-6278-4508-B1D6-B8B68C1F95DB}
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Game\Compiler.cpp" />
<ClCompile Include="Game\DataSet\DataSet.cpp" />
<ClCompile Include="Game\DataSet\VarType.cpp" />
<ClCompile Include="Game\Game.cpp" />
<ClCompile Include="Game\GameComponents\MainRule.cpp" />
<ClCompile Include="Game\GameComponents\MainRule\EndRule.cpp" />
<ClCompile Include="Game\GameComponents\MainRule\Payoff.cpp" />
<ClCompile Include="Game\GameComponents\Moves.cpp" />
<ClCompile Include="Game\GameComponents\Moves\Move.cpp" />
<ClCompile Include="Game\GameComponents\State.cpp" />
<ClCompile Include="Game\Instructions\InstructionBlock.cpp" />
<ClCompile Include="Game\Instructions\Instruction\Expression\ExpressionBool.cpp" />
<ClCompile Include="Game\Instructions\Instruction\Expression\ExpressionInt.cpp" />
<ClCompile Include="Game\Instructions\Instruction\Instruction.cpp" />
<ClCompile Include="Game\Instructions\Instruction\InstructionAssign.cpp" />
<ClCompile Include="Game\Instructions\Instruction\InstructionConditionalJump.cpp" />
<ClCompile Include="Game\Instructions\Instruction\InstructionNextPlayer.cpp" />
<ClCompile Include="Game\Instructions\Instruction\InstructionReturn.cpp" />
<ClCompile Include="Game\Player\IPlayer.cpp" />
<ClCompile Include="Game\Player\Player.cpp" />
<ClCompile Include="Grammar\Common.cpp" />
<ClCompile Include="Grammar\Lexer.c" />
<ClCompile Include="Grammar\Parser.tab.c" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Game\Compiler.h" />
<ClInclude Include="Game\DataSet\DataSet.h" />
<ClInclude Include="Game\DataSet\VarType.h" />
<ClInclude Include="Game\Game.h" />
<ClInclude Include="Game\GameComponents\MainRule.h" />
<ClInclude Include="Game\GameComponents\MainRule\EndRule.h" />
<ClInclude Include="Game\GameComponents\MainRule\Payoff.h" />
<ClInclude Include="Game\GameComponents\Moves.h" />
<ClInclude Include="Game\GameComponents\Moves\Move.h" />
<ClInclude Include="Game\GameComponents\State.h" />
<ClInclude Include="Game\Instructions\InstructionBlock.h" />
<ClInclude Include="Game\Instructions\Instruction\Expression\ExpressionBool.h" />
<ClInclude Include="Game\Instructions\Instruction\Expression\ExpressionInt.h" />
<ClInclude Include="Game\Instructions\Instruction\Instruction.h" />
<ClInclude Include="Game\Instructions\Instruction\InstructionAssign.h" />
<ClInclude Include="Game\Instructions\Instruction\InstructionConditionalJump.h" />
<ClInclude Include="Game\Instructions\Instruction\InstructionNextPlayer.h" />
<ClInclude Include="Game\Instructions\Instruction\InstructionReturn.h" />
<ClInclude Include="Game\Player\IPlayer.h" />
<ClInclude Include="Game\Player\Player.h" />
<ClInclude Include="Grammar\Common.h" />
<ClInclude Include="Grammar\Parser.tab.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{E6E0A92C-B54B-4635-A994-6165BA1681CD}</ProjectGuid>
<RootNamespace>GameCompiler</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<CustomBuildBeforeTargets>
</CustomBuildBeforeTargets>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<CustomBuildBeforeTargets>
</CustomBuildBeforeTargets>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
</Link>
<CustomBuildStep>
<Command>
</Command>
<Outputs>
</Outputs>
</CustomBuildStep>
<PreBuildEvent>
<Command>
</Command>
<Message>
</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<CustomBuildStep>
<Command>
</Command>
<Outputs>
</Outputs>
</CustomBuildStep>
<PreBuildEvent>
<Command>
</Command>
<Message>
</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Pliki źródłowe">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Pliki nagłówkowe">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Pliki zasobów">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Grammar\Lexer.c">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Grammar\Parser.tab.c">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Grammar\Common.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\DataSet\DataSet.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\Game.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\Compiler.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\DataSet\VarType.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\Instructions\InstructionBlock.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\Instructions\Instruction\Instruction.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\Instructions\Instruction\InstructionAssign.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\Instructions\Instruction\Expression\ExpressionInt.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\Instructions\Instruction\Expression\ExpressionBool.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\Instructions\Instruction\InstructionReturn.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\Instructions\Instruction\InstructionConditionalJump.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\GameComponents\State.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\Player\Player.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\GameComponents\MainRule\EndRule.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\GameComponents\MainRule\Payoff.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\GameComponents\MainRule.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\Instructions\Instruction\InstructionNextPlayer.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\GameComponents\Moves.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\GameComponents\Moves\Move.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
<ClCompile Include="Game\Player\IPlayer.cpp">
<Filter>Pliki źródłowe</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Grammar\Parser.tab.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Grammar\Common.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\DataSet\DataSet.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\Game.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\Compiler.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\DataSet\VarType.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\Instructions\InstructionBlock.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\Instructions\Instruction\Instruction.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\Instructions\Instruction\InstructionAssign.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\Instructions\Instruction\Expression\ExpressionInt.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\Instructions\Instruction\Expression\ExpressionBool.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\Instructions\Instruction\InstructionReturn.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\Instructions\Instruction\InstructionConditionalJump.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\GameComponents\State.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\Player\Player.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\GameComponents\MainRule\EndRule.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\GameComponents\MainRule\Payoff.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\GameComponents\MainRule.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\Instructions\Instruction\InstructionNextPlayer.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\GameComponents\Moves.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\GameComponents\Moves\Move.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
<ClInclude Include="Game\Player\IPlayer.h">
<Filter>Pliki nagłówkowe</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>
\ No newline at end of file
......@@ -40,7 +40,9 @@ const char* getTypeName(Type type)
case return_instr: return "return_instr";
case if_instr: return "if_instr";
case while_instr: return "while_instr";
case next_player_instr: return "next_player_instr";
case expr: return "expr";
case expr_player_index: return "expr_player_index";
case expr_ref: return "expr_ref";
case expr_literal: return "expr_literal";
case expr_add: return "expr_add";
......
......@@ -19,8 +19,8 @@ typedef enum Type
game, main_rule, players, players_list, player, state, moves,
data_set, var_list, var_list_tail, var_declaration, var_type, var_definition,
instruction_block, instruction_list,
instruction, assign_instr, return_instr, if_instr, while_instr,
expr, expr_ref, expr_literal, expr_add, expr_sub, expr_mul, expr_div, expr_mod, expr_neg,
instruction, assign_instr, return_instr, if_instr, while_instr, next_player_instr,
expr, expr_player_index, expr_ref, expr_literal, expr_add, expr_sub, expr_mul, expr_div, expr_mod, expr_neg,
expr_equal, expr_not_equal, expr_less_equal, expr_greater_equal, expr_greater, expr_less, expr_and, expr_or, expr_not,
var_reference, local_scope, state_scope, move_scope,
m_rule_list, m_rule,
......
......@@ -290,7 +290,7 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
#define YY_END_OF_BUFFER 24
static yyconst short int yy_accept[85] =
{ 0,
0, 0, 24, 23, 22, 21, 21, 23, 16, 21,
0, 0, 24, 23, 22, 21, 21, 21, 16, 21,
21, 21, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 23, 11, 14, 16, 12, 10, 13,
20, 20, 8, 20, 20, 20, 20, 20, 20, 20,
......
......@@ -122,7 +122,7 @@ TMP {
}
[\[\]{}<>()+\-*/=!,;%$#\.] {
[\[\]{}<>()+\-*/=!,;%$#&\.] {
yylval.t = SyntaxTree_init(syntax_char, yytext, 0);
return yytext[0];
......
This diff is collapsed.
......@@ -32,7 +32,7 @@ SyntaxTree* root;
PLAYERS_LIST PLAYER
DATA_SET VAR_LIST VAR_DECLARATION VAR_TYPE VAR_DEFINITION
INSTRUCTION_BLOCK INSTRUCTION_LIST
INSTRUCTION ASSIGN_INSTR RETURN_INSTR IF_INSTR WHILE_INSTR EXPR
INSTRUCTION ASSIGN_INSTR RETURN_INSTR IF_INSTR WHILE_INSTR NEXT_PLAYER_INSTR EXPR
VAR_REFERENCE SCOPE
M_RULE_LIST M_RULE
PAYOFF_LIST PAYOFF
......@@ -225,6 +225,12 @@ INSTRUCTION: ASSIGN_INSTR {
st->children[0] = $1;
}
| NEXT_PLAYER_INSTR {
SyntaxTree* st = SyntaxTree_init(instruction, "", 1);
$$ = st;
st->children[0] = $1;
}
ASSIGN_INSTR: VAR_REFERENCE '=' EXPR ';' {
SyntaxTree* st = SyntaxTree_init(assign_instr, "", 2);
......@@ -261,6 +267,13 @@ WHILE_INSTR: KW_WHILE '(' EXPR ')' '{' INSTRUCTION_LIST '}' {
st->children[1] = $6;
}
NEXT_PLAYER_INSTR: '&' '=' IDENTIFIER '[' EXPR ']' ';' {
SyntaxTree* st = SyntaxTree_init(next_player_instr, "", 2);
$$ = st;
st->children[0] = $3;
st->children[1] = $5;
}
EXPR: VAR_REFERENCE {
......@@ -269,6 +282,10 @@ EXPR: VAR_REFERENCE {
st->children[0] = $1;
}
| '&' {
SyntaxTree* st = SyntaxTree_init(expr_player_index, "", 0);
$$ = st;
}
| VAR_DEFINITION{
SyntaxTree* st = SyntaxTree_init(expr_literal, "", 1);
$$ = st;
......@@ -345,7 +362,7 @@ EXPR: VAR_REFERENCE {
st->children[1] = $3;
}
| EXPR OPERATOR_LESS_EQUAL EXPR{
SyntaxTree* st = SyntaxTree_init(expr_greater_equal, "", 2);
SyntaxTree* st = SyntaxTree_init(expr_less_equal, "", 2);
$$ = st;
st->children[0] = $1;
......
File added
File added