var->dump(fp, indent);
}
fprintf(fp, "%s== Body:%s\n", tabs, m_body == NULL ? " <none>" : "");
- if (m_body != NULL)
- m_body->dump(fp, indent);
+ RplASNode1::dumpStatements(fp, indent, m_body);
}
/**
/**
* @brief Constructor.
*
- * @param itemType the node type, e.g. AST_VAR_DEFINITION
* @param dataType the data type (class)
* @param name the name of the variable
* @param attributes the attributes of the variable
*/
-RplASNamedValue::RplASNamedValue(RplASItemType itemType, RplASClass* dataType,
+RplASNamedValue::RplASNamedValue(RplASClass* dataType,
const QString& name, int attributes) :
- RplASNode1(itemType),
+ RplASNode1(AST_NAMED_VALUE),
m_name(name),
m_attributes(attributes),
m_dataType(dataType)
/** @class RplVarDefinition rplastree.hpp "rplexpr/rplastree.hpp"
*
* @brief Implements variable definition for the Abstract Syntax Tree.
+ *
+ * <code>m_child</code>: next statement</br>
+ * <code>m_child2</code>: named value (name + default value expression)
+ * <code>m_child3</code>: initial value or NULL
*/
/**
* @brief Constructor.
- *
- * @param type the data type
- * @param name the name of the variable
- * @param attributes the attributes of the variable
*/
-RplASVarDefinition::RplASVarDefinition(RplASClass* type, const QString& name,
- int attributes) :
- RplASNamedValue(AST_VAR_DEFINITION, type, name, attributes),
+RplASVarDefinition::RplASVarDefinition() :
+ RplASNode3(AST_VAR_DEFINITION),
RplASStatement()
{
}
void RplASVarDefinition::dump(FILE* fp, int indent)
{
DEFINE_TABS(indent);
- QByteArray name = m_name.toUtf8();
- QByteArray className = m_dataType == NULL ? "?" : m_dataType->name().toUtf8();
+ RplASNamedValue* namedValue = dynamic_cast<RplASNamedValue*>(m_child2);
+ QByteArray name = namedValue->name().toUtf8();
char buffer[256];
- fprintf(fp, "%svarDef %s (%s) id: %d succ: %d attr: 0x%x %s\n",
- tabs, name.constData(), className.constData(),
- m_id, m_successor == NULL ? 0 : m_successor->id(), m_attributes,
+ fprintf(fp, "%svarDef %s id: %d namedValue: %d value: %d succ: %d %s\n",
+ tabs, name.constData(), m_id,
+ m_child2 == NULL ? 0 : m_child2->id(),
+ m_child3 == NULL ? 0 : m_child3->id(),
+ m_child == NULL ? 0 : m_child->id(),
positionStr(buffer, sizeof buffer));
- if (m_child != NULL)
- m_child->dump(fp, indent + 1);
- if (m_successor != NULL)
- m_successor->dump(fp, indent);
+ if (m_child2 != NULL)
+ m_child2->dump(fp, indent + 1);
+ if (m_child3 != NULL)
+ m_child3->dump(fp, indent + 1);
}
/**
/** @class RplASExprStatement rplastree.hpp "rplexpr/rplastree.hpp"
*
- * @brief Implements an statement consisting of an expression
+ * @brief Implements an statement consisting of an expression.
+ *
+ * <code>m_child</code>: next statement</br>
+ * <code>m_child2</code>: expression
*/
/**
* @brief Constructor.
*/
RplASExprStatement::RplASExprStatement() :
- RplASNode1(AST_EXPR_STATEMENT),
+ RplASNode2(AST_EXPR_STATEMENT),
RplASStatement()
{
}
{
DEFINE_TABS(indent);
char buffer[256];
- fprintf(fp, "%sExpr id: %d succ: %d expr: %d %s\n", tabs, m_id,
- m_successor == NULL ? 0 : m_successor->id(),
+ fprintf(fp, "%sExpr id: %d expr: %d succ: %d %s\n", tabs, m_id,
+ m_child2 == NULL ? 0 : m_child2->id(),
m_child == NULL ? 0 : m_child->id(),
positionStr(buffer, sizeof buffer));
- if (m_child != NULL)
- m_child->dump(fp, indent + 1);
- if (m_successor != NULL)
- m_successor->dump(fp, indent);
+ if (m_child2 != NULL)
+ m_child2->dump(fp, indent + 1);
}
/** @class RplASNode1 rplastree.hpp "rplexpr/rplastree.hpp"
m_child = child;
}
+/**
+ * @brief Writes the internals of a statement list into a file.
+ *
+ * @param fp file to write
+ * @param indent the indent level of the statement list
+ * @param chain the chain of statements to dump
+ */
+void RplASNode1::dumpStatements(FILE* fp, int indent, RplASItem* statements)
+{
+ RplASNode1* chain = dynamic_cast<RplASNode1*>(statements);
+ while (chain != NULL){
+ chain->dump(fp, indent);
+ chain = dynamic_cast<RplASNode1*>(chain->m_child);
+ }
+}
+
/** @class RplASNode2 rplastree.hpp "rplexpr/rplastree.hpp"
*
* @brief Implements a inner node of the abstract syntax tree with two childs.
m_child5 = child5;
}
+/** @class RplASNode6 rplastree.hpp "rplexpr/rplastree.hpp"
+ *
+ * @brief Implements a inner node of the abstract syntax tree with 4 childs.
+ *
+ * This class is an abstract class.
+ */
+
+/**
+ * @brief RplASNode6::RplASNode6
+ * @param type
+ */
+RplASNode6::RplASNode6(RplASItemType type) :
+ RplASNode5(type),
+ m_child6(NULL)
+{
+}
+
+/**
+ * @brief Destructor.
+ */
+RplASNode6::~RplASNode6()
+{
+ delete m_child6;
+ m_child6 = NULL;
+}
+
+/**
+ * @brief Returns the child5.
+ *
+ * @return the child 5
+ */
+RplASItem* RplASNode6::child6() const
+{
+ return m_child6;
+}
+
+/**
+ * @brief Sets the child5.
+ *
+ * @param child5 the new child3
+ */
+void RplASNode6::setChild6(RplASItem* child6)
+{
+ m_child6 = child6;
+}
+
/** @class RplASUnaryOp rplastree.hpp "rplexpr/rplastree.hpp"
*
* @brief Implements a unary operation.
{
DEFINE_TABS(indent);
char buffer[256];
- fprintf(fp, "%sUnary %d op: %s (%d) Child: %d %s\n", tabs,
+ fprintf(fp, "%sUnary %d op: %s (%d) expr: %d %s\n", tabs,
m_id,
RplLexer::m_active->nameOfOp(m_operator).constData(),
m_operator,
m_child == NULL ? 0 : m_child->id(),
positionStr(buffer, sizeof buffer) );
if (m_child != NULL)
- m_child->dump(fp, indent);
+ m_child->dump(fp, indent + 1);
}
/** @class RplASStatement rplastree.hpp "rplexpr/rplastree.hpp"
*
* @brief Implements a base class for all statements.
+ *
+ * @note statements are always <code>RplASNode1</code> and m_child is used
+ * for the successors (next statement).
*/
/**
* @brief RplASStatement::RplASStatement
* @param op
*/
-RplASStatement::RplASStatement() :
- m_successor(NULL)
+RplASStatement::RplASStatement()
{
}
-/**
- * @brief Destructor
- */
-RplASStatement::~RplASStatement()
-{
- delete m_successor;
- m_successor = NULL;
-}
-/**
- * @brief Returns the next statement.
- * @return the next statement of a statement list
- */
-RplASItem* RplASStatement::successor() const
-{
- return m_successor;
-}
-
-/**
- * @brief Sets the next statement.
- *
- * @param successor the successor in the statement list
- */
-void RplASStatement::setSuccessor(RplASItem* successor)
-{
- m_successor = successor;
-}
-
-
-
/** @class RplASCondition rplastree.hpp "rplexpr/rplastree.hpp"
*
* @brief Implements a condition.
* The if statement has a condition, a then-part and an optional else-part.
* If the condition is evaluated to true, the then-part will be executed.
* Otherwise the else-part if it exists.
+ *
+ * <code>m_child</code>: next statement</br>
+ * <code>m_child2</code>: condition<br>
+ * <code>m_child3</code>: then part<br>
+ * <code>m_child4</code>: else part or NULL<br>
*/
RplASIf::RplASIf() :
- RplASNode3(AST_IF)
+ RplASNode4(AST_IF)
{
}
/**
* @brief Executes the statement.
*
- * Meaning of the childs:
- * m_child: condition
- * m_child2: if-part
- * m_child3: else-part
*/
void RplASIf::execute()
{
- RplASCondition* condition = dynamic_cast<RplASCondition*>(m_child);
+ RplASCondition* condition = dynamic_cast<RplASCondition*>(m_child2);
if (condition == NULL)
- throw RplASException(m_child == NULL ? m_position : m_child->position(),
+ throw RplASException(m_child2 == NULL ? m_position : m_child2->position(),
"if statement: not a condition");
RplASStatement* body = NULL;
if(condition->calcAsBool()){
- body = dynamic_cast<RplASStatement*>(m_child2);
+ body = dynamic_cast<RplASStatement*>(m_child3);
if (body == NULL)
throw RplASException(m_child2 == NULL ? m_position : m_child2->position(),
"if statement: then-part is not a statement");
- } else if (m_child2 != NULL){
- body = dynamic_cast<RplASStatement*>(m_child3);
+ } else if (m_child4 != NULL){
+ body = dynamic_cast<RplASStatement*>(m_child4);
if (body == NULL)
- throw RplASException(m_child3->position(),
+ throw RplASException(m_child4->position(),
"if statement: else-part is not a statement");
}
body->execute();
{
DEFINE_TABS(indent);
char buffer[256];
- fprintf(fp, "%sIf id: %d condition: %d then: %d else: %d %s\n", tabs,
- m_id, m_child->id(), m_child2->id(),
+ fprintf(fp, "%sIf id: %d condition: %d then: %d else: %d succ: %d%s\n", tabs,
+ m_id,
+ m_child2 == NULL ? 0 : m_child2->id(),
m_child3 == NULL ? 0 : m_child3->id(),
+ m_child4 == NULL ? 0 : m_child4->id(),
+ m_child == NULL ? 0 : m_child->id(),
positionStr(buffer, sizeof buffer));
- m_child->dump(fp, indent + 1);
m_child2->dump(fp, indent + 1);
if (m_child3 != NULL)
m_child3->dump(fp, indent + 1);
+ if (m_child4 != NULL)
+ m_child4->dump(fp, indent + 1);
}
/** @class RplASFor rplastree.hpp "rplexpr/rplastree.hpp"
* The initialization will be called first.
* Then the condition will be tested. If true the body will be executed
* and then the forwarding statement.
+ *
+ * <code>m_child</code>: next statement</br>
+ * <code>m_child2</code>: body<br>
+ * <code>m_child3</code>: iterator variable<br>
+ * <code>m_child4</code>: container variable<br>
*/
/**
* @param variable NULL or the iterator variable
*/
RplASForIterated::RplASForIterated(RplASNamedValue* variable) :
- RplASNode3(AST_ITERATED_FOR),
+ RplASNode4(AST_ITERATED_FOR),
RplASStatement()
{
m_child2 = variable;
/**
* @brief Executes the statement.
*
- * Meaning of the childs:
- * m_child: initialization
- * m_child2: condition
- * m_child3: forwarding statement
- * m_child4: body
*/
void RplASForIterated::execute()
{
{
DEFINE_TABS(indent);
char buffer[256];
- fprintf(fp, "%sforIt id: %d var: %d set: %d body: %d %s\n", tabs,
+ fprintf(fp, "%sforIt id: %d var: %d set: %d body: %d succ: %d %s\n", tabs,
m_id,
- m_child2 == NULL ? 0 : m_child2->id(),
m_child3 == NULL ? 0 : m_child3->id(),
+ m_child4 == NULL ? 0 : m_child4->id(),
+ m_child2 == NULL ? 0 : m_child2->id(),
m_child == NULL ? 0 : m_child->id(),
positionStr(buffer, sizeof buffer));
- if (m_child2 != NULL)
- m_child2->dump(fp, indent + 1);
if (m_child3 != NULL)
m_child3->dump(fp, indent + 1);
- if (m_child != NULL)
- m_child->dump(fp, indent + 1);
+ if (m_child4 != NULL)
+ m_child4->dump(fp, indent + 1);
+ dumpStatements(fp, indent + 1, m_child2);
}
/** @class RplASForCounted rplastree.hpp "rplexpr/rplastree.hpp"
*
* The start and end value will be calculated.
* The body will be executed so many times given by the start and end value.
+ *
+ * <code>m_child</code>: next statement</br>
+ * <code>m_child2</code>: body<br>
+ * <code>m_child3</code>: variable or NULL<br>
+ * <code>m_child4</code>: start value or NULL<br>
+ * <code>m_child5</code>: end value<br>
+ * <code>m_child6</code>: step value or NULL<br>
+ *
*/
/**
* @param variable NULL or the counter variable
*/
RplASForCounted::RplASForCounted(RplASNamedValue* variable) :
- RplASNode5(AST_ITERATED_FOR),
+ RplASNode6(AST_ITERATED_FOR),
RplASStatement()
{
- m_child2 = variable;
+ m_child3 = variable;
}
/**
* @brief Executes the statement.
*
- * Meaning of the childs:
- * m_child: body
- * m_child2: variable
- * m_child3: start value
- * m_child4: end value
- * m_child5: step value
*/
void RplASForCounted::execute()
{
- RplASStatement* body = dynamic_cast<RplASStatement*>(m_child);
+ RplASStatement* body = dynamic_cast<RplASStatement*>(m_child2);
if (body == NULL)
- throw RplASException(m_child == NULL ? m_position : m_child->position(),
+ throw RplASException(m_child2 == NULL ? m_position : m_child2->position(),
"forc statement: body is not a statement");
int start = 1;
int step = 1;
int end = 0;
RplASNamedValue* var = NULL;
- if (m_child2 != NULL){
- var = dynamic_cast<RplASNamedValue*>(m_child2);
+ if (m_child3 != NULL){
+ var = dynamic_cast<RplASNamedValue*>(m_child3);
}
for(int ii = start; ii <= end; ii += step){
body->execute();
{
DEFINE_TABS(indent);
char buffer[256];
- fprintf(fp, "%sforc id: %d var: %d from: %d to: %d step: %d body: %d %s\n",
+ fprintf(fp, "%sforC id: %d var: %d from: %d to: %d step: %d body: %d succ: %d %s\n",
tabs, m_id,
- m_child2 == NULL ? 0 : m_child2->id(),
m_child3 == NULL ? 0 : m_child3->id(),
m_child4 == NULL ? 0 : m_child4->id(),
m_child5 == NULL ? 0 : m_child5->id(),
+ m_child6 == NULL ? 0 : m_child6->id(),
+ m_child2 == NULL ? 0 : m_child2->id(),
m_child == NULL ? 0 : m_child->id(),
positionStr(buffer, sizeof buffer));
- if (m_child2 != NULL)
- m_child2->dump(fp, indent + 1);
if (m_child3 != NULL)
m_child3->dump(fp, indent + 1);
if (m_child4 != NULL)
m_child4->dump(fp, indent + 1);
if (m_child5 != NULL)
m_child5->dump(fp, indent + 1);
- if (m_child != NULL)
- m_child->dump(fp, indent + 1);
+ if (m_child6 != NULL)
+ m_child6->dump(fp, indent + 1);
+ dumpStatements(fp, indent + 1, m_child2);
}
/** @class RplASWhile rplastree.hpp "rplexpr/rplastree.hpp"
*
* The while statement has an a condition and a body.
* The body will be executed while the condition returns true.
+ *
+ * <code>m_child</code>: next statement</br>
+ * <code>m_child2</code>: condition<br>
+ * <code>m_child3</code>: body<br>
*/
RplASWhile::RplASWhile() :
- RplASNode2(AST_WHILE),
+ RplASNode3(AST_WHILE),
RplASStatement()
{
}
* @brief Executes the statement.
*
* Meaning of the childs:
- * m_child: body
- * m_child2: condition
*/
void RplASWhile::execute()
{
- RplASStatement* body = dynamic_cast<RplASStatement*>(m_child);
+ RplASStatement* body = dynamic_cast<RplASStatement*>(m_child3);
if (body == NULL)
- throw RplASException(m_child == NULL ? m_position : m_child->position(),
+ throw RplASException(m_child3 == NULL ? m_position : m_child3->position(),
"while statement: body is not a statement");
RplASCondition* condition = dynamic_cast<RplASCondition*>(m_child2);
if (condition == NULL)
{
DEFINE_TABS(indent);
char buffer[256];
- fprintf(fp, "%swhile id: %d condition: %d body: %d %s\n", tabs, m_id,
+ fprintf(fp, "%swhile id: %d condition: %d body: %d succ: %d %s\n", tabs, m_id,
m_child2 == NULL ? 0 : m_child2->id(),
+ m_child3 == NULL ? 0 : m_child3->id(),
m_child == NULL ? 0 : m_child->id(),
positionStr(buffer, sizeof buffer));
if (m_child2 != NULL)
m_child2->dump(fp, indent + 1);
- if (m_child != NULL)
- m_child->dump(fp, indent + 1);
+ dumpStatements(fp, indent + 1, m_child3);
}
/** @class RplASRepeat rplastree.hpp "rplexpr/rplastree.hpp"
*
* The while statement has an a condition and a body.
* The body will be executed while the condition returns true.
+ *
+ * <code>m_child</code>: next statement</br>
+ * <code>m_child2</code>: condition<br>
+ * <code>m_child3</code>: body<br>
*/
RplASRepeat::RplASRepeat() :
- RplASNode2(AST_REPEAT),
+ RplASNode3(AST_REPEAT),
RplASStatement()
{
}
*/
void RplASRepeat::execute()
{
- RplASStatement* body = dynamic_cast<RplASStatement*>(m_child);
+ RplASStatement* body = dynamic_cast<RplASStatement*>(m_child3);
if (body == NULL)
- throw RplASException(m_child == NULL ? m_position : m_child->position(),
- "while statement: body is not a statement");
+ throw RplASException(m_child3 == NULL ? m_position : m_child3->position(),
+ "repeat statement: body is not a statement");
RplASCondition* condition = dynamic_cast<RplASCondition*>(m_child2);
if (condition == NULL)
throw RplASException(m_child2 == NULL ? m_position : m_child2->position(),
- "for statement: not a condition");
+ "repeat statement: not a condition");
do {
body->execute();
} while(condition->calcAsBool());
{
DEFINE_TABS(indent);
char buffer[256];
- fprintf(fp, "%srepeat id: %d condition: %d body: %d %s\n", tabs, m_id,
+ fprintf(fp, "%srepeat id: %d condition: %d body: %d succ: %d %s\n", tabs, m_id,
m_child2 == NULL ? 0 : m_child2->id(),
+ m_child3 == NULL ? 0 : m_child3->id(),
m_child == NULL ? 0 : m_child->id(),
positionStr(buffer, sizeof buffer));
- if (m_child != NULL)
- m_child->dump(fp, indent + 1);
if (m_child2 != NULL)
m_child2->dump(fp, indent + 1);
+ dumpStatements(fp, indent + 1, m_child3);
}
/** @class RplASClass rplastree.hpp "rplexpr/rplastree.hpp"
}
}
+/** @class RplASMethodCall rplastree.hpp "rplexpr/rplastree.hpp"
+ *
+ * @brief Implements a method or function call for the Abstract Syntax Tree.
+ *
+ * <code>m_child</code>: next statement</br>
+ * <code>m_child2</code>: argument list<br>
+ */
/**
* @brief Constructor.
*/
{
DEFINE_TABS(indent);
char buffer[256];
- fprintf(fp, "%sCall %d instance: %d args: %d %s\n", tabs, m_id,
+ fprintf(fp, "%scall %d instance: %d args: %d %s\n", tabs, m_id,
m_child == NULL ? 0 : m_child->id(),
m_child2 == NULL ? 0 : m_child2->id(),
positionStr(buffer, sizeof buffer));
return dynamic_cast<RplASArgument*>(m_child2);
}
+/** @class RplASException rplastree.hpp "rplexpr/rplastree.hpp"
+ *
+ * @brief Implements a call of a method or function.
+ *
+ * <code>m_child</code>: ???</br>
+ * <code>m_child2</code>: argument list (or NULL)
+ */
/**
* @brief Sets the argument list.
*
/** @class RplASArgument rplastree.hpp "rplexpr/rplastree.hpp"
*
* @brief Implements an argument of a method for the Abstract Syntax Tree.
+ *
+ * <code>m_child</code>: next argument<br>
+ * <code>m_child2</code>: expression
*/
/**
* @brief constructor
{
}
+/**
+ * @brief Writes the internals of the instance into a file.
+ *
+ * @param fp target file
+ * @param no current number of the argument: 1..N
+ * @param indent nesting level
+ * @param tabs a string with tabs (count: indent)
+ */
+void RplASArgument::dumpOne(FILE* fp, int no, int indent, char tabs[])
+{
+ int succ = child() == NULL ? 0 : child()->id();
+ fprintf(fp, "%sArg %d id: %d expr: %d succ: %d\n", tabs, no, m_id,
+ child2()->id(), succ);
+ child2()->dump(fp, indent + 1);
+}
+/**
+ * @brief Writes the internals of the instance into a file.
+ *
+ * @param fp target file
+ * @param indent nesting level
+ */
+void RplASArgument::dump(FILE* fp, int indent)
+{
+ DEFINE_TABS(indent);
+ RplASArgument* current = this;
+ int no = 0;
+ do {
+ dumpOne(fp, ++no, indent, tabs);
+ current = static_cast<RplASArgument*>(current->child());
+ } while (this != NULL);
+}
public:
RplASItem* child() const;
void setChild(RplASItem* child);
+public:
+ static void dumpStatements(FILE* fp, int indent, RplASItem* statements);
protected:
RplASItem* m_child;
};
protected:
RplASItem* m_child5;
};
+class RplASNode6 : public RplASNode5
+{
+public:
+ RplASNode6(RplASItemType type);
+ virtual ~RplASNode6();
+public:
+ RplASItem*child6() const;
+ void setChild6(RplASItem* child5);
+protected:
+ RplASItem* m_child6;
+};
+
typedef QList<RplASVariant*> RplASListOfVariants;
typedef QMap<QString, RplASVariant*> RplASMapOfVariants;
public:
RplASNamedValue(const QString& name);
- RplASNamedValue(RplASItemType itemType, RplASClass* dataType,
+ RplASNamedValue(RplASClass* dataType,
const QString& name, int attributes);
public:
QString name() const;
{
public:
RplASStatement();
- virtual ~RplASStatement();
public:
virtual void execute() = 0;
- RplASItem* successor() const;
- void setSuccessor(RplASItem* successor);
-protected:
- RplASItem* m_successor;
};
-class RplASVarDefinition : public RplASNamedValue, public RplASStatement
+class RplASVarDefinition : public RplASNode3, public RplASStatement
{
public:
- RplASVarDefinition(RplASClass* type, const QString& name,
- int attributes = A_NONE);
+ RplASVarDefinition();
public:
virtual void execute();
virtual void calc(RplASVariant& value);
void dump(FILE* fp, int indent);
};
-class RplASExprStatement : public RplASNode1, public RplASStatement
+class RplASExprStatement : public RplASNode2, public RplASStatement
{
public:
RplASExprStatement();
void dump(FILE* fp, int indent);
};
-class RplASIf : public RplASNode3, public RplASStatement
+class RplASIf : public RplASNode4, public RplASStatement
{
public:
RplASIf();
virtual void dump(FILE* fp, int indent);
};
-class RplASForIterated : public RplASNode3, public RplASStatement
+class RplASForIterated : public RplASNode4, public RplASStatement
{
public:
RplASForIterated(RplASNamedValue* variable);
virtual void dump(FILE* fp, int indent);
};
-class RplASForCounted : public RplASNode5, public RplASStatement
+class RplASForCounted : public RplASNode6, public RplASStatement
{
public:
RplASForCounted(RplASNamedValue* variable);
virtual void dump(FILE* fp, int indent);
};
-class RplASWhile : public RplASNode2, public RplASStatement
+class RplASWhile : public RplASNode3, public RplASStatement
{
public:
RplASWhile();
virtual void dump(FILE* fp, int indent);
};
-class RplASRepeat : public RplASNode2, public RplASStatement
+class RplASRepeat : public RplASNode3, public RplASStatement
{
public:
RplASRepeat();
{
public:
RplASArgument();
+public:
+ void dump(FILE* fp, int indent);
+protected:
+ void dumpOne(FILE* fp, int no, int indent, char tabs[]);
};
class RplASMethod;
void setArg1(RplASArgument* arg1);
private:
RplASMethod* m_method;
- // body is child
- // arg1 is child2
};
class RplParameter : RplASItem
enum MFLocations{
L_PARSE_OPERAND_RPARENTH = 2001,
- L_PARSE_OPERAND_RPARENTH_FUNC,
+ L_PARSE_FREE1,
L_TERM_WRONG_STRING,
L_TERM_WRONG_NUMBER,
L_PARSE_OPERAND_WRONG = 2005,
L_PARSE_MAP_NO_COMMA,
L_PARSE_OPERAND_NOT_OPERAND = 2030,
L_PARSE_BODY_NO_START,
- L_PARSE_OPERAND_NO_BRACKET
+ L_PARSE_OPERAND_NO_BRACKET,
+ L_PARSE_ARGS_NO_COMMA_OR_PARENT
};
/** @class RplMFParser rpllexer.hpp "rplexpr/rplmfparser.hpp"
RplASItem* condition = parseExpr(0);
if (! m_lexer.currentToken()->isKeyword(K_THEN))
syntaxError(L_PARSE_IF_NO_THEN, "'then' expected");
- rc->setChild(condition);
+ rc->setChild2(condition);
RplASItem* body = parseBody(K_ELSE, K_FI);
- rc->setChild2(body);
+ rc->setChild3(body);
if (! m_lexer.currentToken()->isKeyword(K_ELSE, K_FI))
syntaxError(L_PARSE_IF_NO_ELSE, "'else' or 'fi' expected");
if ( m_lexer.currentToken()->isKeyword(K_ELSE)){
RplASItem* body = parseBody(K_FI);
- rc->setChild3(body);
+ rc->setChild4(body);
}
if (! m_lexer.currentToken()->isKeyword(K_FI))
syntaxError(L_PARSE_IF_NO_FI, "'fi' expected");
syntaxError(L_PARSE_WHILE_NO_DO, "'do' expected");
rc->setChild2(condition);
RplASItem* body = parseBody(K_OD);
- rc->setChild(body);
+ rc->setChild3(body);
if (! m_lexer.currentToken()->isKeyword(K_OD))
syntaxError(L_PARSE_WHILE_NO_OD, "'od' expected");
m_lexer.nextNonSpaceToken();
rc->setPosition(m_lexer.currentPosition());
RplASItem* body = parseBody(K_UNTIL);
- rc->setChild(body);
+ rc->setChild3(body);
if (! m_lexer.currentToken()->isKeyword(K_UNTIL))
syntaxError(L_PARSE_REPEAT_NO_UNTIL, "'until' expected");
RplASForIterated* node = new RplASForIterated(var);
rc = node;
node->setPosition(startPosition);
+ node->setChild3(var);
RplASItem* iterable = parseExpr(0);
- node->setChild3(iterable);
+ node->setChild4(iterable);
} else {
RplASForCounted* node = new RplASForCounted(var);
rc = node;
node->setPosition(startPosition);
+ node->setChild3(var);
if (token->isKeyword(K_FROM)){
- node->setChild3(parseExpr(0));
+ node->setChild4(parseExpr(0));
}
if (! m_lexer.currentToken()->isKeyword(K_TO)){
syntaxError(L_PARSE_FOR_NO_TO, "'to' expected");
}
- node->setChild4(parseExpr(0));
+ node->setChild5(parseExpr(0));
if (m_lexer.currentToken()->isKeyword(K_STEP)){
- node->setChild5(parseExpr(0));
+ node->setChild6(parseExpr(0));
}
}
if (! m_lexer.currentToken()->isKeyword(K_DO))
syntaxError(L_PARSE_FOR_NO_TO, "'to' expected");
- rc->setChild(parseBody(K_OD));
+ rc->setChild2(parseBody(K_OD));
m_lexer.nextNonSpaceToken();
return rc;
}
token = m_lexer.nextNonSpaceToken();
if (! token->isTokenType(TOKEN_ID))
syntaxError(L_DEFINITION_MISSING_ID, "variable name expected");
- RplASNamedValue* rc = new RplASVarDefinition(clazz, token->toString(), attr);
+ // freed in the destructor of the nodes:
+ RplASNamedValue* namedValue = new RplASNamedValue(clazz, token->toString(), attr);
+ namedValue->setPosition(m_lexer.currentPosition());
+ RplASVarDefinition* rc = new RplASVarDefinition();
rc->setPosition(m_lexer.currentPosition());
+ rc->setChild2(namedValue);
token = m_lexer.nextNonSpaceToken();
if (! token->isOperator(O_ASSIGN, O_SEMICOLON))
syntaxError(L_DEFINITION_NO_OP, "'=' or ';' expected");
if (token->id() == O_ASSIGN){
RplASItem* value = parseExpr(0);
- rc->setChild(value);
+ rc->setChild3(value);
token = m_lexer.currentToken();
}
if (! token->isOperator(O_SEMICOLON)){
RplASExprStatement* expr = dynamic_cast<RplASExprStatement*>
(parseExprStatement(false));
if (expr != NULL){
- // chaining per m_successor is for freeing while destruction:
- expr->setSuccessor(parent->child());
+ // chaining per m_child (= next statement) is for freeing while destruction:
+ expr->setChild(parent->child());
parent->setChild(expr);
// freed in the destructor of varList (~RplASVariant()):
variant = new RplASVariant();
} else {
if (token->id() == O_LPARENTH){
RplASMethodCall* call = new RplASMethodCall();
- call->setPosition(m_lexer.currentPosition());
+ call->setPosition(startPosition);
+
rc = call;
- RplASArgument* args = parseArguments();
- call->setArg1(args);
token = m_lexer.nextNonSpaceToken();
if (! token->isOperator(O_RPARENT)){
- QByteArray pos = startPosition->toString().toUtf8();
- // this call never comes back (exception!)
- syntaxError(L_PARSE_OPERAND_RPARENTH_FUNC,
- "')' expected. '(' is at %s", pos.constData());
+ m_lexer.undoLastToken();
+ RplASArgument* args = parseArguments();
+ call->setArg1(args);
}
} else {
RplASNamedValue* var = new RplASNamedValue(name);
var->setPosition(startPosition);
rc = var;
if (token->id() == O_LBRACKET){
- RplASItem indexExpr = parseExpr(0);
+ RplASItem* indexExpr = parseExpr(0);
if (! m_lexer.currentToken()->isOperator(O_RBRACKET))
syntaxError(L_PARSE_OPERAND_NO_BRACKET, "']' expected");
var->setChild(indexExpr);
}
if (readNext)
m_lexer.nextNonSpaceToken();
+// if (m_lexer.currentToken()->isOperator(O_DOT))
+
return rc;
}
if (item != NULL){
statement = new RplASExprStatement();
statement->setPosition(item->position());
- statement->setChild(item);
+ statement->setChild2(item);
}
if (eatSemicolon && m_lexer.currentToken()->isOperator(O_SEMICOLON))
m_lexer.nextNonSpaceToken();
RplToken* token = m_lexer.nextNonSpaceToken();
RplASItem* item = NULL;
RplASItem* body = NULL;
- RplASStatement* lastStatement = NULL;
+ RplASNode1* lastStatement = NULL;
bool again = true;
const RplSourcePosition* lastPos = NULL;
do {
if (body == NULL){
body = item;
} else {
- lastStatement->setSuccessor(item);
+ lastStatement->setChild(item);
}
- lastStatement = dynamic_cast<RplASStatement*>(item);
+ lastStatement = dynamic_cast<RplASNode1*>(item);
if (lastStatement == NULL)
error(L_PARSE_BODY_WRONG_ITEM, "wrong item type: %d",
item == NULL ? 0 : item->nodeType());
}
/**
- * @brief Parses an argument list.
+ * @brief Parses an argument list in a method call.
*
- * @return the first element of the argument list
+ * @pre the token '(' is read
+ * @post the token behind the ')' is read
+ * @return the first element of the argument list
*/
RplASArgument* RplMFParser::parseArguments()
{
- return NULL;
+ RplASArgument* first = NULL;
+ bool again = false;
+ do {
+ RplASItem* expr = parseExpr(0);
+ if (! m_lexer.currentToken()->isOperator(O_COMMA, O_RPARENT))
+ syntaxError(L_PARSE_ARGS_NO_COMMA_OR_PARENT, "',' or ')' expected");
+ again = m_lexer.currentToken()->isOperator(O_COMMA);
+ m_lexer.nextNonSpaceToken();
+ RplASArgument* current = new RplASArgument();
+ current->setPosition(expr->position());
+ } while (again);
+ return first;
}
== Classes:
== Variables:
== Body:
-Expr id: 6 succ: 0 expr: 2 <test>:1:1
+Expr id: 6 expr: 2 succ: 0 <test>:1:1
BinOp id: 2 op: + (26) left: 1 right: 4 <test>:1:1
const id: 1 value: 2 <test>:0:0
BinOp id: 4 op: * (30) left: 3 right: 5 <test>:1:3
== Classes:
== Variables:
== Body:
-varDef i (Int) id: 1 succ: 3 attr: 0x0 <test>:1:4
- const id: 2 value: 3 <test>:1:8
-varDef s (Str) id: 3 succ: 5 attr: 0x10 <test>:1:26
- const id: 4 value: 'Hi' <test>:1:30
-varDef l (List) id: 5 succ: 0 attr: 0x2 <test>:1:47
+varDef i id: 2 namedValue: 1 value: 3 succ: 5 <test>:1:4
+ namedValue i id: 1 attr: 0x0 <test>:1:4
+ const id: 3 value: 3 <test>:1:8
+varDef s id: 5 namedValue: 4 value: 6 succ: 8 <test>:1:26
+ namedValue s id: 4 attr: 0x10 <test>:1:26
+ const id: 6 value: 'Hi' <test>:1:30
+varDef l id: 8 namedValue: 7 value: 0 succ: 0 <test>:1:47
+ namedValue l id: 7 attr: 0x2 <test>:1:47
== Classes:
== Variables:
== Body:
-varDef a (Int) id: 1 succ: 3 attr: 0x0 <test>:1:4
-forc id: 3 var: 2 from: 4 to: 5 step: 6 body: 11 <test>:1:7
- namedValue b id: 2 attr: 0x0 <test>:2:4
- const id: 4 value: 10 <test>:2:11
- const id: 5 value: 1 <test>:2:17
- Unary 6 op: - (27) Child: 7 <test>:2:24
- const id: 7 value: 2 <test>:2:25
- Expr id: 11 succ: 0 expr: 9 <test>:3:2
- BinOp id: 9 op: += (6) left: 8 right: 10 <test>:3:2
- namedValue a id: 8 attr: 0x0 <test>:3:2
- const id: 10 value: 1 <test>:3:5
+varDef a id: 2 namedValue: 1 value: 0 succ: 4 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+forC id: 4 var: 3 from: 5 to: 6 step: 7 body: 12 succ: 0 <test>:1:7
+ namedValue b id: 3 attr: 0x0 <test>:2:4
+ const id: 5 value: 10 <test>:2:11
+ const id: 6 value: 1 <test>:2:17
+ Unary 7 op: - (27) expr: 8 <test>:2:24
+ const id: 8 value: 2 <test>:2:25
+ Expr id: 12 expr: 10 succ: 0 <test>:3:2
+ BinOp id: 10 op: += (6) left: 9 right: 11 <test>:3:2
+ namedValue a id: 9 attr: 0x0 <test>:3:2
+ const id: 11 value: 1 <test>:3:5
== Classes:
== Variables:
== Body:
-varDef a (Int) id: 1 succ: 2 attr: 0x0 <test>:1:4
-forc id: 2 var: 0 from: 0 to: 3 step: 0 body: 7 <test>:1:7
- const id: 3 value: 10 <test>:1:14
- Expr id: 7 succ: 0 expr: 5 <test>:1:22
- BinOp id: 5 op: += (6) left: 4 right: 6 <test>:1:22
- namedValue a id: 4 attr: 0x0 <test>:1:22
- const id: 6 value: 1 <test>:1:25
+varDef a id: 2 namedValue: 1 value: 0 succ: 3 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+forC id: 3 var: 0 from: 0 to: 4 step: 0 body: 8 succ: 0 <test>:1:7
+ const id: 4 value: 10 <test>:1:14
+ Expr id: 8 expr: 6 succ: 0 <test>:1:22
+ BinOp id: 6 op: += (6) left: 5 right: 7 <test>:1:22
+ namedValue a id: 5 attr: 0x0 <test>:1:22
+ const id: 7 value: 1 <test>:1:25
== Classes:
== Variables:
== Body:
-varDef a (Map) id: 1 succ: 3 attr: 0x0 <test>:1:4
-forIt id: 3 var: 2 set: 4 body: 8 <test>:1:7
- namedValue x id: 2 attr: 0x0 <test>:2:4
- namedValue a id: 4 attr: 0x0
- Expr id: 8 succ: 0 expr: 6 <test>:3:2
- BinOp id: 6 op: += (6) left: 5 right: 7 <test>:3:2
- namedValue a id: 5 attr: 0x0 <test>:3:2
- const id: 7 value: 1 <test>:3:5
+varDef a id: 2 namedValue: 1 value: 0 succ: 4 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+forIt id: 4 var: 3 set: 5 body: 9 succ: 0 <test>:1:7
+ namedValue x id: 3 attr: 0x0 <test>:2:4
+ namedValue a id: 5 attr: 0x0
+ Expr id: 9 expr: 7 succ: 0 <test>:3:2
+ BinOp id: 7 op: += (6) left: 6 right: 8 <test>:3:2
+ namedValue a id: 6 attr: 0x0 <test>:3:2
+ const id: 8 value: 1 <test>:3:5
== Classes:
== Variables:
== Body:
-varDef a (Int) id: 1 succ: 2 attr: 0x0 <test>:1:4
-varDef b (Int) id: 2 succ: 8 attr: 0x0 <test>:2:4
-Expr id: 8 succ: 9 expr: 4 <test>:3:2
- BinOp id: 4 op: = (5) left: 3 right: 6 <test>:3:2
- namedValue a id: 3 attr: 0x0 <test>:3:2
- BinOp id: 6 op: = (5) left: 5 right: 7 <test>:3:6
- namedValue b id: 5 attr: 0x0 <test>:3:6
- const id: 7 value: 2 <test>:3:8
-If id: 9 condition: 11 then: 18 else: 24 <test>:3:11
- BinOp id: 11 op: < (21) left: 10 right: 12 <test>:4:6
- const id: 10 value: 11 <test>:4:3
- const id: 12 value: 12 <test>:4:8
- Expr id: 18 succ: 0 expr: 14 <test>:5:7
- BinOp id: 14 op: = (5) left: 13 right: 16 <test>:5:7
- namedValue a id: 13 attr: 0x0 <test>:5:7
- BinOp id: 16 op: * (30) left: 15 right: 17 <test>:5:12
- const id: 15 value: 13 <test>:5:9
- const id: 17 value: 14 <test>:5:14
- Expr id: 24 succ: 0 expr: 20 <test>:6:7
- BinOp id: 20 op: = (5) left: 19 right: 22 <test>:6:7
- namedValue a id: 19 attr: 0x0 <test>:6:7
- BinOp id: 22 op: / (28) left: 21 right: 23 <test>:6:12
- const id: 21 value: 15 <test>:6:9
- const id: 23 value: 16 <test>:6:14
+varDef a id: 2 namedValue: 1 value: 0 succ: 4 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+varDef b id: 4 namedValue: 3 value: 0 succ: 10 <test>:2:4
+ namedValue b id: 3 attr: 0x0 <test>:2:4
+Expr id: 10 expr: 6 succ: 11 <test>:3:2
+ BinOp id: 6 op: = (5) left: 5 right: 8 <test>:3:2
+ namedValue a id: 5 attr: 0x0 <test>:3:2
+ BinOp id: 8 op: = (5) left: 7 right: 9 <test>:3:6
+ namedValue b id: 7 attr: 0x0 <test>:3:6
+ const id: 9 value: 2 <test>:3:8
+If id: 11 condition: 13 then: 20 else: 26 succ: 0<test>:3:11
+ BinOp id: 13 op: < (21) left: 12 right: 14 <test>:4:6
+ const id: 12 value: 11 <test>:4:3
+ const id: 14 value: 12 <test>:4:8
+ Expr id: 20 expr: 16 succ: 0 <test>:5:7
+ BinOp id: 16 op: = (5) left: 15 right: 18 <test>:5:7
+ namedValue a id: 15 attr: 0x0 <test>:5:7
+ BinOp id: 18 op: * (30) left: 17 right: 19 <test>:5:12
+ const id: 17 value: 13 <test>:5:9
+ const id: 19 value: 14 <test>:5:14
+ Expr id: 26 expr: 22 succ: 0 <test>:6:7
+ BinOp id: 22 op: = (5) left: 21 right: 24 <test>:6:7
+ namedValue a id: 21 attr: 0x0 <test>:6:7
+ BinOp id: 24 op: / (28) left: 23 right: 25 <test>:6:12
+ const id: 23 value: 15 <test>:6:9
+ const id: 25 value: 16 <test>:6:14
== Classes:
== Variables:
== Body:
-varDef x (Str) id: 1 succ: 2 attr: 0x0 <test>:1:4
-If id: 2 condition: 4 then: 9 else: 0 <test>:1:7
- BinOp id: 4 op: < (21) left: 3 right: 5 <test>:2:5
- const id: 3 value: 7 <test>:2:3
- const id: 5 value: 6 <test>:2:7
- Expr id: 9 succ: 0 expr: 7 <test>:3:7
- BinOp id: 7 op: = (5) left: 6 right: 8 <test>:3:7
- namedValue x id: 6 attr: 0x0 <test>:3:7
- const id: 8 value: '123' <test>:3:9
+varDef x id: 2 namedValue: 1 value: 0 succ: 3 <test>:1:4
+ namedValue x id: 1 attr: 0x0 <test>:1:4
+If id: 3 condition: 5 then: 10 else: 0 succ: 0<test>:1:7
+ BinOp id: 5 op: < (21) left: 4 right: 6 <test>:2:5
+ const id: 4 value: 7 <test>:2:3
+ const id: 6 value: 6 <test>:2:7
+ Expr id: 10 expr: 8 succ: 0 <test>:3:7
+ BinOp id: 8 op: = (5) left: 7 right: 9 <test>:3:7
+ namedValue x id: 7 attr: 0x0 <test>:3:7
+ const id: 9 value: '123' <test>:3:9
== Classes:
== Variables:
== Body:
-varDef b (List) id: 1 succ: 0 attr: 0x0 <test>:1:5
- listConst id: 2 <test>:1:9
+varDef b id: 2 namedValue: 1 value: 3 succ: 0 <test>:1:5
+ namedValue b id: 1 attr: 0x0 <test>:1:5
+ listConst id: 3 <test>:1:9
[]
== Classes:
== Variables:
== Body:
-varDef a (List) id: 1 succ: 9 attr: 0x0 <test>:1:5
- listConst id: 2 <test>:1:9
- [<formula 6>,3.140000,7,'hi',<formula 8>]
-varDef b (List) id: 9 succ: 0 attr: 0x0 <test>:1:39
- listConst id: 10 <test>:1:43
+varDef a id: 2 namedValue: 1 value: 3 succ: 11 <test>:1:5
+ namedValue a id: 1 attr: 0x0 <test>:1:5
+ listConst id: 3 <test>:1:9
+ [<formula 7>,3.140000,7,'hi',<formula 9>]
+varDef b id: 11 namedValue: 10 value: 12 succ: 0 <test>:1:39
+ namedValue b id: 10 attr: 0x0 <test>:1:39
+ listConst id: 12 <test>:1:43
[]
== Classes:
== Variables:
== Body:
-varDef a (Map) id: 1 succ: 0 attr: 0x0 <test>:1:4
- mapConst id: 2 <test>:1:8
+varDef a id: 2 namedValue: 1 value: 3 succ: 0 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+ mapConst id: 3 <test>:1:8
{}
== Classes:
== Variables:
== Body:
-varDef a (Map) id: 1 succ: 9 attr: 0x0 <test>:1:4
- mapConst id: 2 <test>:1:8
- {'a':<formula 6>,'bcd':3.140000,'ccc':7,'hi':<formula 8>}
-varDef b (Map) id: 9 succ: 0 attr: 0x0 <test>:2:4
- mapConst id: 10 <test>:2:8
+varDef a id: 2 namedValue: 1 value: 3 succ: 11 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+ mapConst id: 3 <test>:1:8
+ {'a':<formula 7>,'bcd':3.140000,'ccc':7,'hi':<formula 9>}
+varDef b id: 11 namedValue: 10 value: 12 succ: 0 <test>:2:4
+ namedValue b id: 10 attr: 0x0 <test>:2:4
+ mapConst id: 12 <test>:2:8
{}
== Classes:
== Variables:
== Body:
-varDef a (Int) id: 1 succ: 3 attr: 0x0 <test>:1:4
- const id: 2 value: 1 <test>:1:8
-varDef b (Int) id: 3 succ: 7 attr: 0x0 <test>:2:4
- const id: 4 value: 100 <test>:2:8
-Expr id: 7 succ: 10 expr: 5 <test>:2:13
- Unary 5 op: -- (41) Child: 6 <test>:2:13
- namedValue a id: 6 attr: 0x0 <test>:3:3
-Expr id: 10 succ: 20 expr: 9
- Unary 9 op: ++ (40) Child: 8
- namedValue b id: 8 attr: 0x0 <test>:4:1
-Expr id: 20 succ: 32 expr: 13 <test>:5:3
- BinOp id: 13 op: * (30) left: 12 right: 16 <test>:5:3
- Unary 12 op: -- (41) Child: 11
- namedValue a id: 11 attr: 0x0 <test>:5:1
- BinOp id: 16 op: ** (31) left: 14 right: 18 <test>:5:7
- Unary 14 op: ++ (40) Child: 15 <test>:5:4
- namedValue b id: 15 attr: 0x0 <test>:5:7
- BinOp id: 18 op: - (27) left: 17 right: 19 <test>:5:11
- const id: 17 value: 8 <test>:5:10
- const id: 19 value: 3 <test>:5:12
-Expr id: 32 succ: 0 expr: 22 <test>:6:1
- BinOp id: 22 op: = (5) left: 21 right: 24 <test>:6:1
- namedValue a id: 21 attr: 0x0 <test>:6:1
- BinOp id: 24 op: = (5) left: 23 right: 26 <test>:6:3
- namedValue b id: 23 attr: 0x0 <test>:6:3
- BinOp id: 26 op: + (26) left: 25 right: 30 <test>:6:6
- namedValue a id: 25 attr: 0x0 <test>:6:6
- BinOp id: 30 op: * (30) left: 28 right: 31 <test>:6:12
- BinOp id: 28 op: - (27) left: 27 right: 29 <test>:6:9
- namedValue b id: 27 attr: 0x0 <test>:6:9
- const id: 29 value: 2 <test>:6:10
- const id: 31 value: 3 <test>:6:13
+varDef a id: 2 namedValue: 1 value: 3 succ: 5 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+ const id: 3 value: 1 <test>:1:8
+varDef b id: 5 namedValue: 4 value: 6 succ: 9 <test>:2:4
+ namedValue b id: 4 attr: 0x0 <test>:2:4
+ const id: 6 value: 100 <test>:2:8
+Expr id: 9 expr: 7 succ: 12 <test>:2:13
+ Unary 7 op: -- (41) expr: 8 <test>:2:13
+ namedValue a id: 8 attr: 0x0 <test>:3:3
+Expr id: 12 expr: 11 succ: 22
+ Unary 11 op: ++ (40) expr: 10
+ namedValue b id: 10 attr: 0x0 <test>:4:1
+Expr id: 22 expr: 15 succ: 34 <test>:5:3
+ BinOp id: 15 op: * (30) left: 14 right: 18 <test>:5:3
+ Unary 14 op: -- (41) expr: 13
+ namedValue a id: 13 attr: 0x0 <test>:5:1
+ BinOp id: 18 op: ** (31) left: 16 right: 20 <test>:5:7
+ Unary 16 op: ++ (40) expr: 17 <test>:5:4
+ namedValue b id: 17 attr: 0x0 <test>:5:7
+ BinOp id: 20 op: - (27) left: 19 right: 21 <test>:5:11
+ const id: 19 value: 8 <test>:5:10
+ const id: 21 value: 3 <test>:5:12
+Expr id: 34 expr: 24 succ: 0 <test>:6:1
+ BinOp id: 24 op: = (5) left: 23 right: 26 <test>:6:1
+ namedValue a id: 23 attr: 0x0 <test>:6:1
+ BinOp id: 26 op: = (5) left: 25 right: 28 <test>:6:3
+ namedValue b id: 25 attr: 0x0 <test>:6:3
+ BinOp id: 28 op: + (26) left: 27 right: 32 <test>:6:6
+ namedValue a id: 27 attr: 0x0 <test>:6:6
+ BinOp id: 32 op: * (30) left: 30 right: 33 <test>:6:12
+ BinOp id: 30 op: - (27) left: 29 right: 31 <test>:6:9
+ namedValue b id: 29 attr: 0x0 <test>:6:9
+ const id: 31 value: 2 <test>:6:10
+ const id: 33 value: 3 <test>:6:13
== Classes:
== Variables:
== Body:
-varDef a (Int) id: 1 succ: 2 attr: 0x0 <test>:1:4
-repeat id: 2 condition: 7 body: 5 <test>:1:7
- Expr id: 5 succ: 0 expr: 4
- Unary 4 op: ++ (40) Child: 3
- namedValue a id: 3 attr: 0x0 <test>:3:1
- BinOp id: 7 op: != (20) left: 6 right: 9 <test>:4:8
- namedValue a id: 6 attr: 0x0 <test>:4:8
- BinOp id: 9 op: * (30) left: 8 right: 10 <test>:4:13
- const id: 8 value: 2 <test>:4:11
- const id: 10 value: 3 <test>:4:15
+varDef a id: 2 namedValue: 1 value: 0 succ: 3 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+repeat id: 3 condition: 8 body: 6 succ: 0 <test>:1:7
+ BinOp id: 8 op: != (20) left: 7 right: 10 <test>:4:8
+ namedValue a id: 7 attr: 0x0 <test>:4:8
+ BinOp id: 10 op: * (30) left: 9 right: 11 <test>:4:13
+ const id: 9 value: 2 <test>:4:11
+ const id: 11 value: 3 <test>:4:15
+ Expr id: 6 expr: 5 succ: 0
+ Unary 5 op: ++ (40) expr: 4
+ namedValue a id: 4 attr: 0x0 <test>:3:1
== Classes:
== Variables:
== Body:
-varDef a (Int) id: 1 succ: 3 attr: 0x0 <test>:1:4
- const id: 2 value: 20 <test>:1:8
-while id: 3 condition: 5 body: 10 <test>:1:12
- BinOp id: 5 op: < (21) left: 4 right: 6 <test>:2:8
- const id: 4 value: 3 <test>:2:6
- const id: 6 value: 5 <test>:2:10
- Expr id: 10 succ: 0 expr: 8 <test>:3:3
- BinOp id: 8 op: = (5) left: 7 right: 9 <test>:3:3
- namedValue a id: 7 attr: 0x0 <test>:3:3
- const id: 9 value: 7 <test>:3:5
+varDef a id: 2 namedValue: 1 value: 3 succ: 4 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+ const id: 3 value: 20 <test>:1:8
+while id: 4 condition: 6 body: 11 succ: 0 <test>:1:12
+ BinOp id: 6 op: < (21) left: 5 right: 7 <test>:2:8
+ const id: 5 value: 3 <test>:2:6
+ const id: 7 value: 5 <test>:2:10
+ Expr id: 11 expr: 9 succ: 0 <test>:3:3
+ BinOp id: 9 op: = (5) left: 8 right: 10 <test>:3:3
+ namedValue a id: 8 attr: 0x0 <test>:3:3
+ const id: 10 value: 7 <test>:3:5
parser.parse();
checkAST("map2.txt", __LINE__);
}
+ void methodCallTest(){
+ setSource("max(4**(5),3.14*8));");
+ //setSource("rand();\nsin(a);\nmax(1+2*3,4**(5-4));");
+ RplMFParser parser(m_source, m_tree);
+ parser.parse();
+ checkAST("methc1.txt", __LINE__);
+ }
virtual void doIt(void) {
+ methodCallTest();
mapTest();
forItTest();
forCTest();