Flex/Bison based compiler and interpreter written in C++ (using Boost)
File detail
Source code
/*
* Copyright (C) 2008 Kamil Dudka <xdudka00@stud.fit.vutbr.cz>
*
* This file is part of vyp08 (compiler and interpreter of VYP08 language).
*
* vyp08 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* vyp08 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with vyp08. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CMD_H
#define CMD_H
#include "config.h"
#include "vm.h"
/**
* Factory for virtual machine related commands.
* @note design pattern factory
*/
class CmdFactory {
public:
typedef Value::VType VType; ///< using Value::VType for type specification
/// @param vm Initialized virtual machine object to create commands for.
CmdFactory(Vm *vm);
~CmdFactory();
PCmd createAssign(Token, FncDefinition *, VType &dstType); ///< assignment
PCmd createIf(Token, PCmd ifCmd, PCmd elseCmd); ///< if statement
PCmd createWhile(Token, PCmd whileExpr, PCmd whileStat); ///< while statement
PCmd createPush(Token, FncDefinition *, VType &dstType); ///< read value (and push to stack)
PCmd createUnary(Token); ///< unary operator
PCmd createBinary(Token, VType t1, VType t2, VType &dstType); ///< binary operator
PCmd createCall(Token, unsigned nArgs, bool pushResult); ///< function call
PCmd createPrint(Token, EToken valType, VType &srcType); ///< print() function
PCmd createInput(Token, Value::VType type, bool pushResult); ///< intput{int|double|string}() function
private:
struct Private;
Private *d;
};
#endif /* CMD_H */