parent
77399daf66
commit
2d649a149b
|
@ -12,7 +12,18 @@
|
|||
#include "SenchaObject.h"
|
||||
#include "../Visitor.h"
|
||||
|
||||
class ASTNode : public Visitable{
|
||||
|
||||
/**
|
||||
* ASTNode is an ancestor of all former ASTNodes.
|
||||
* It implements Visitable, which is an abstraction of something, which
|
||||
* can be visited, by visitor.
|
||||
* It is very important in our tree relation and creating tree crawlers,
|
||||
* such as ASTInspector, which is very helpful for debugging.
|
||||
* ASTNode stores its children in vector of pointers to other ASTNodes,
|
||||
* It allows us to use features of polymorphism.
|
||||
*/
|
||||
class ASTNode : public Visitable
|
||||
{
|
||||
public:
|
||||
ASTNode();
|
||||
std::vector<ASTNode *> children;
|
||||
|
|
|
@ -10,7 +10,16 @@
|
|||
#include <string>
|
||||
#include "ASTExpression.h"
|
||||
#include "../Context.h"
|
||||
|
||||
/**
|
||||
* Assignment is an abstraction of assignment.
|
||||
* It is different from i.e BasicExpression so that it change value of the lvalue
|
||||
* and has to forward this change to whole system. Assignment does it thanks to its
|
||||
* fellowship with right context
|
||||
* if expression is assigned not to variable, it doesn't update value of variable of course
|
||||
* it just gives value of rvalue...
|
||||
* mmm... maybe it'd be better to return InvalidExpression with appropriate error message such
|
||||
* as: "Invalid assignment, values cannot be assigned to constant values"
|
||||
*/
|
||||
class Assignment : public ASTExpression {
|
||||
public:
|
||||
Context * context;
|
||||
|
|
|
@ -12,6 +12,10 @@
|
|||
#include "ASTStatement.h"
|
||||
#include "../Visitor.h"
|
||||
|
||||
/**
|
||||
* BasicStatement is just one simple statement which is actually some expression and (;) or not
|
||||
* or block of statements like { stat1; stat2; stat3; } of any type
|
||||
*/
|
||||
class BasicStatement : public ASTStatement {
|
||||
public:
|
||||
BasicStatement();
|
||||
|
|
|
@ -13,7 +13,11 @@
|
|||
#include "ConstantExpression.h"
|
||||
#include "../Context.h"
|
||||
|
||||
|
||||
/**
|
||||
* DeclarationStatement is abstraction of declaration/definition
|
||||
* You can declare new variables and functions. And they will be added to
|
||||
* your world aka context. And you could use them later.
|
||||
*/
|
||||
class DeclarationStatement: public ASTStatement {
|
||||
public:
|
||||
std::string name;
|
||||
|
|
|
@ -11,6 +11,13 @@
|
|||
#include "ASTStatement.h"
|
||||
#include "ASTExpression.h"
|
||||
|
||||
/**
|
||||
* This is a regular if then_block else else_block
|
||||
* New IfNode is build like that:
|
||||
* First you add condition, then then-block which is called body
|
||||
* and if it is needed, it's possible to add else-block too.
|
||||
* It has to be done in right order.
|
||||
*/
|
||||
class IfNode : public ASTStatement
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -11,6 +11,11 @@
|
|||
#include "ASTExpression.h"
|
||||
#include <iostream>
|
||||
|
||||
/**
|
||||
* IncorrectExpression is created when something semantically wrong happens
|
||||
* in our SenchaCode, it conveys message of what happened and should be
|
||||
* helpful for programmer.
|
||||
*/
|
||||
class IncorrectExpression: public ASTExpression {
|
||||
public:
|
||||
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
#include "ASTStatement.h"
|
||||
#include "../Context.h"
|
||||
|
||||
/**
|
||||
* PostfixExpression is in current implementation an abstraction
|
||||
* of function call
|
||||
*/
|
||||
class PostfixExpression : public ASTExpression {
|
||||
public:
|
||||
std::string name;
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
#include "ASTNode.h"
|
||||
#include "ASTStatement.h"
|
||||
|
||||
/**
|
||||
* ProgramNode is always first node. It stores all statements.
|
||||
*/
|
||||
class ProgramNode : public ASTNode {
|
||||
public:
|
||||
ProgramNode();
|
||||
|
|
|
@ -10,6 +10,12 @@
|
|||
|
||||
#include "ASTStatement.h"
|
||||
|
||||
/**
|
||||
* Repeat statement if very useful, when you need to do something n-times
|
||||
* you just repeat(n) {block_of_code}
|
||||
* It stores how many times it should be executed
|
||||
* and what should be executed, that is body.
|
||||
*/
|
||||
class RepeatStatement: public ASTStatement {
|
||||
public:
|
||||
RepeatStatement();
|
||||
|
|
|
@ -12,6 +12,10 @@
|
|||
#include "../Context.h"
|
||||
#include "ASTExpression.h"
|
||||
|
||||
/**
|
||||
* VariableExpression is actually a wrapper around name and appropriate context
|
||||
* variable can evaluate itself in right time. It's an abstraction of variable.
|
||||
*/
|
||||
class VariableExpression: public ASTExpression {
|
||||
public:
|
||||
VariableExpression();
|
||||
|
|
|
@ -10,6 +10,11 @@
|
|||
|
||||
#include "ASTStatement.h"
|
||||
#include "ASTExpression.h"
|
||||
|
||||
/**
|
||||
* WhileNode is a while construct. It evaluates condition and executes
|
||||
* body if it's true, when condition turn into false, WhileNode breaks loop.
|
||||
*/
|
||||
class WhileNode: public ASTStatement {
|
||||
public:
|
||||
WhileNode();
|
||||
|
|
Loading…
Reference in New Issue