summaryrefslogtreecommitdiffstats
path: root/Sencha-lang
diff options
context:
space:
mode:
authorJustyna Ilczuk <justyna.ilczuk@gmail.com>2012-12-28 11:41:43 +0100
committerJustyna Ilczuk <justyna.ilczuk@gmail.com>2012-12-28 11:41:43 +0100
commit2d649a149bad632e224d48e2020e0ab6c2d5fb1f (patch)
tree77900ea2010ba35bd047d70ff4309bdb408e36ca /Sencha-lang
parent77399daf66a8768258de9b38f945804691bc9a40 (diff)
downloadsencha-lang-2d649a149bad632e224d48e2020e0ab6c2d5fb1f.tar.gz
sencha-lang-2d649a149bad632e224d48e2020e0ab6c2d5fb1f.tar.bz2
sencha-lang-2d649a149bad632e224d48e2020e0ab6c2d5fb1f.zip
Documentation... some useful comments, which are descriptions of
AST nodes.
Diffstat (limited to 'Sencha-lang')
-rw-r--r--Sencha-lang/AST/ASTNode.h13
-rw-r--r--Sencha-lang/AST/Assignment.h11
-rw-r--r--Sencha-lang/AST/BasicStatement.h4
-rw-r--r--Sencha-lang/AST/DeclarationStatement.h6
-rw-r--r--Sencha-lang/AST/IfNode.h7
-rw-r--r--Sencha-lang/AST/IncorrectExpression.h5
-rw-r--r--Sencha-lang/AST/PostfixExpression.h4
-rw-r--r--Sencha-lang/AST/ProgramNode.h3
-rw-r--r--Sencha-lang/AST/RepeatStatement.h6
-rw-r--r--Sencha-lang/AST/VariableExpression.h4
-rw-r--r--Sencha-lang/AST/WhileNode.h5
11 files changed, 65 insertions, 3 deletions
diff --git a/Sencha-lang/AST/ASTNode.h b/Sencha-lang/AST/ASTNode.h
index c5f3019..7c27b26 100644
--- a/Sencha-lang/AST/ASTNode.h
+++ b/Sencha-lang/AST/ASTNode.h
@@ -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;
diff --git a/Sencha-lang/AST/Assignment.h b/Sencha-lang/AST/Assignment.h
index 4bb9a1a..a646af4 100644
--- a/Sencha-lang/AST/Assignment.h
+++ b/Sencha-lang/AST/Assignment.h
@@ -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;
diff --git a/Sencha-lang/AST/BasicStatement.h b/Sencha-lang/AST/BasicStatement.h
index 4d29a16..7d76fd5 100644
--- a/Sencha-lang/AST/BasicStatement.h
+++ b/Sencha-lang/AST/BasicStatement.h
@@ -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();
diff --git a/Sencha-lang/AST/DeclarationStatement.h b/Sencha-lang/AST/DeclarationStatement.h
index 50cbfb4..0fdb51b 100644
--- a/Sencha-lang/AST/DeclarationStatement.h
+++ b/Sencha-lang/AST/DeclarationStatement.h
@@ -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;
diff --git a/Sencha-lang/AST/IfNode.h b/Sencha-lang/AST/IfNode.h
index e035240..6accc7d 100644
--- a/Sencha-lang/AST/IfNode.h
+++ b/Sencha-lang/AST/IfNode.h
@@ -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:
diff --git a/Sencha-lang/AST/IncorrectExpression.h b/Sencha-lang/AST/IncorrectExpression.h
index eecf0bb..22542c4 100644
--- a/Sencha-lang/AST/IncorrectExpression.h
+++ b/Sencha-lang/AST/IncorrectExpression.h
@@ -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:
diff --git a/Sencha-lang/AST/PostfixExpression.h b/Sencha-lang/AST/PostfixExpression.h
index 35bb00a..b6e4db1 100644
--- a/Sencha-lang/AST/PostfixExpression.h
+++ b/Sencha-lang/AST/PostfixExpression.h
@@ -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;
diff --git a/Sencha-lang/AST/ProgramNode.h b/Sencha-lang/AST/ProgramNode.h
index 1c8fc42..a39e46a 100644
--- a/Sencha-lang/AST/ProgramNode.h
+++ b/Sencha-lang/AST/ProgramNode.h
@@ -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();
diff --git a/Sencha-lang/AST/RepeatStatement.h b/Sencha-lang/AST/RepeatStatement.h
index a42b194..1d65121 100644
--- a/Sencha-lang/AST/RepeatStatement.h
+++ b/Sencha-lang/AST/RepeatStatement.h
@@ -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();
diff --git a/Sencha-lang/AST/VariableExpression.h b/Sencha-lang/AST/VariableExpression.h
index f89260c..f07ba7a 100644
--- a/Sencha-lang/AST/VariableExpression.h
+++ b/Sencha-lang/AST/VariableExpression.h
@@ -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();
diff --git a/Sencha-lang/AST/WhileNode.h b/Sencha-lang/AST/WhileNode.h
index 131f152..bc41139 100644
--- a/Sencha-lang/AST/WhileNode.h
+++ b/Sencha-lang/AST/WhileNode.h
@@ -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();