1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-17 00:07:41 +02:00

Entities redesign and a few ERM features

* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
This commit is contained in:
AlexVinS
2018-03-17 17:58:30 +03:00
committed by AlexVinS
parent 11bb46780a
commit ecaa9f5d0b
475 changed files with 22491 additions and 7123 deletions

View File

@ -8,7 +8,7 @@
*
*/
#pragma once
#include <boost/spirit/home/support/unused.hpp>
namespace spirit = boost::spirit;
@ -16,14 +16,22 @@ namespace spirit = boost::spirit;
class CERMPreprocessor
{
std::string fname;
std::ifstream file;
std::stringstream sourceStream;
int lineNo;
enum {INVALID, ERM, VERM} version;
void getline(std::string &ret);
public:
CERMPreprocessor(const std::string &Fname);
enum class Version : ui8
{
INVALID,
ERM,
VERM
};
Version version;
CERMPreprocessor(const std::string & source);
std::string retrieveCommandLine();
int getCurLineNo() const
{
@ -34,6 +42,9 @@ public:
//various classes that represent ERM/VERM AST
namespace ERM
{
using ValType = int; //todo: set to int64_t
using IType = int; //todo: set to int32_t
struct TStringConstant
{
std::string str;
@ -105,25 +116,25 @@ namespace ERM
TStringConstant string;
};
struct TVarConcatString
struct TVarConcatString
{
TVarExp var;
TStringConstant string;
};
typedef boost::variant<TVarConcatString, TStringConstant, TCurriedString, TSemiCompare, TMacroDef, TIexp, TVarpExp, boost::spirit::unused_type> TBodyOptionItem;
typedef boost::variant<TVarConcatString, TStringConstant, TCurriedString, TSemiCompare, TMacroDef, TIexp, TVarpExp> TBodyOptionItem;
typedef std::vector<TBodyOptionItem> TNormalBodyOptionList;
struct TNormalBodyOption
{
char optionCode;
TNormalBodyOptionList params;
boost::optional<TNormalBodyOptionList> params;
};
typedef boost::variant<TVRLogic, TVRArithmetic, TNormalBodyOption> TBodyOption;
typedef boost::variant<TIexp, TArithmeticOp > TIdentifierInternal;
typedef std::vector< TIdentifierInternal > Tidentifier;
// typedef boost::variant<TIexp, TArithmeticOp > TIdentifierInternal;
typedef std::vector< TIexp > Tidentifier;
struct TComparison
{
@ -160,7 +171,7 @@ namespace ERM
struct Ttrigger : TTriggerBase
{
Ttrigger()
Ttrigger()
{
pre = true;
}
@ -209,7 +220,7 @@ namespace ERM
>
Tcmd;
Tcmd cmd;
std::string comment;
//std::string comment;
};
//vector expression
@ -239,6 +250,8 @@ namespace ERM
//script line
typedef boost::variant<TVExp, TERMline> TLine;
template <typename T> class ERM_grammar;
}
struct LineInfo
@ -249,17 +262,16 @@ struct LineInfo
class ERMParser
{
public:
std::shared_ptr<ERM::ERM_grammar<std::string::const_iterator>> ERMgrammar;
ERMParser();
virtual ~ERMParser();
std::vector<LineInfo> parseFile(CERMPreprocessor & preproc);
private:
std::string srcFile;
void repairEncoding(char * str, int len) const; //removes nonstandard ascii characters from string
void repairEncoding(std::string & str) const; //removes nonstandard ascii characters from string
enum ELineType{COMMAND_FULL, COMMENT, UNFINISHED, END_OF};
int countHatsBeforeSemicolon(const std::string & line) const;
ERM::TLine parseLine(const std::string & line, int realLineNo);
public:
ERMParser(std::string file);
std::vector<LineInfo> parseFile();
static ERM::TLine parseLine(const std::string & line);
ERM::TLine parseLine(const std::string & line);
};