enum {
LOC_VARDEF_EXEC_1 = RPL_FIRST_OF(RPL_MODULE_ASTREE), // 11001
- LOC_UNOP_1,
- LOC_UNOP_2,
- LOC_UNOP_3,
- LOC_UNOP_4, // 10005
+ LOC_UNOP_CALC_1,
+ LOC_UNARY_CHECK_1,
+ LOC_UNARY_CHECK_2,
+ LOC_UNARY_CHECK_3, // 11005
LOC_BINOP_1,
LOC_BINOP_CALC_1,
LOC_BINOP_CALC_2,
LOC_BINOP_CALC_3,
- LOC_BINOP_CALC_4,
+ LOC_BINOP_CALC_4, // 11010
LOC_BINOP_CALC_5,
LOC_BINOP_CALC_6,
LOC_BINOP_CALC_7,
LOC_BINOP_CALC_8,
- LOC_BINOP_CALC_9,
+ LOC_BINOP_CALC_9, // 11015
LOC_BINOP_CALC_10,
LOC_BINOP_CALC_11,
LOC_BINOP_CALC_12,
+ LOC_VARDEF_CHECK_1,
+ LOC_VARDEF_CHECK_2, // 11020
+ LOC_CONV_CHECK_1,
+ LOC_CONV_CHECK_2,
+ LOC_CONV_TRY_1,
+ LOC_ITEM_FORCE_ERROR_1,
+ LOC_UNARY_CHECK_4, // 11025
LOC_COUNT
};
m_flags = flags;
}
+/**
+ * @brief Tests the compatibility of 2 data types.
+ * @param class1 1st class to inspect
+ * @param class2 2nd class to inspect
+ * @return true: classes are compatible<br>
+ * false: otherwise
+ */
+bool RplASItem::typeCheck(RplASClass* class1, RplASClass* class2){
+ bool rc;
+ if (class1 == NULL || class2 == NULL)
+ rc = false;
+ else
+ //@ToDo: subclasses
+ rc = class1 == class2;
+ return rc;
+}
+
+/**
+ * @brief Issues an error message.
+ *
+ * @param location an error specific id
+ * @param parser for error processing
+ * @param format the error message with placeholders (like <code>printf</code>)
+ * @param ... the values for the placeholders
+ * @return false (for chaining)
+ */
+bool RplASItem::error(int location, RplParser& parser, const char* format, ...)
+{
+ va_list varList;
+ va_start(varList, format);
+ parser.addMessage(RplParser::LT_ERROR, location, m_position, format, varList);
+ va_end(varList);
+ return false;
+}
+
+/**
+ * @brief Ensures the occurrence of an error.
+ *
+ * When called a previous error should be happend. If not an internal error
+ * will be issued.
+ *
+ * @param parser for error processing
+ * @return <code>false</code> (for chaining)
+ */
+bool RplASItem::ensureError(RplParser& parser)
+{
+ if (parser.errors() == 0)
+ error(LOC_ITEM_FORCE_ERROR_1, parser, "lost error (internal error)");
+ return false;
+}
/** @class RplASCalculable rplastree.hpp "rplexpr/rplastree.hpp"
*
* @brief An abstract base class for items which calculates a value.
*
*/
+/**
+ * @brief Constructor.
+ */
+RplASCalculable::RplASCalculable() :
+ m_class(NULL)
+{
+}
+/**
+ * @brief Returns the class of the node
+ * @return the class
+ */
+
+RplASClass* RplASCalculable::clazz() const
+{
+ return m_class;
+}
+/**
+ * @brief Sets the class of the node.
+ * @param clazz the new class
+ */
+void RplASCalculable::setClass(RplASClass* clazz)
+{
+ m_class = clazz;
+}
/** @class RplASStorable rplastree.hpp "rplexpr/rplastree.hpp"
*
value.copyValue(m_value);
}
+/**
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: a constant is always correct
+ */
+bool RplASConstant::check(RplParser& parser)
+{
+ return true;
+}
+
/**
* @brief Writes the internals into a file.
*
value.copyValue(m_value);
}
+/**
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: a constant is always correct
+ */
+bool RplASListConstant::check(RplParser& parser)
+{
+ return true;
+}
+
/**
* @brief Writes the internals into a file.
*
RplASVariant& value = thread.reserveValue();
value.copyValue(m_value);
}
+
+/**
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: a constant is always correct
+ */
+bool RplASMapConstant::check(RplParser& parser)
+{
+ return true;
+}
/**
* @brief Writes the internals into a file.
*
RplASNode1(AST_NAMED_VALUE),
m_name(name),
m_attributes(attributes),
- m_dataType(dataType),
m_symbolSpace(space),
m_variableNo(-1)
{
{
thread.valueToTop(m_symbolSpace, m_variableNo);
}
+
+/**
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: node is correct<br>
+ * <code>false</code>: otherwise
+ */
+bool RplASNamedValue::check(RplParser& parser)
+{
+ return true;
+}
/**
* @brief Writes the internals into a file.
*
m_name.constData(), m_id, m_attributes,
positionStr(buffer, sizeof buffer));
}
-/**
- * @brief Returns the data type (class) of the instance.
- *
- * @return the data type
- */
-RplASClass* RplASNamedValue::dataType() const
-{
- return m_dataType;
-}
-
-/**
- * @brief Assigns the top of stack of the thread to the instance.
- *
- * @param thread the execution unit, a virtual machine thread
- */
-void RplASNamedValue::assign(RplVMThread& thread)
-{
-
-}
/**
* @brief Returns the symbol space of the variable.
return m_variableNo;
}
+/** @class RplASConversion rplastree.hpp "rplexpr/rplastree.hpp"
+ *
+ * @brief Implements a data type conversion.
+ *
+ * <code>m_child</code>: the expression which will be converted
+ */
+/**
+ * @brief Constructor.
+ * @param expression the expression to convert
+ */
+RplASConversion::RplASConversion(RplASItem* expression) :
+ RplASNode1(AST_CONVERSION),
+ m_conversion(C_UNDEF)
+{
+ m_child = expression;
+ m_position = expression->position();
+}
+
+/**
+ * @brief Convert an expression to another data type.
+ *
+ * Possible conversions: @see <code>RplASConversion::Conversion</code>
+ *
+ * @param thread execution value
+ */
+void RplASConversion::calc(RplVMThread& thread)
+{
+ RplASCalculable* expr = dynamic_cast<RplASCalculable*>(m_child);
+ expr->calc(thread);
+ RplASVariant& value = thread.topOfValues();
+ switch(m_conversion){
+ case C_INT_TO_FLOAT:
+ value.setFloat((qreal) value.asInt());
+ break;
+ case C_FLOAT_TO_INT:
+ value.setInt((int) value.asFloat());
+ break;
+ case C_BOOL_TO_INT:
+ value.setInt((int) value.asBool());
+ break;
+ case C_BOOL_TO_FLOAT:
+ value.setFloat((qreal) value.asBool());
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+ * @brief Returns the conversion type of two classes.
+ *
+ * @param from class to convert
+ * @param to result class of the conversion
+ *
+ * @return <code>C_UNDEF</code>: not convertable<br>
+ * otherwise: the conversion type
+ */
+RplASConversion::Conversion RplASConversion::findConversion(RplASClass* from,
+ RplASClass* to)
+{
+ Conversion rc = C_UNDEF;
+ if (from == RplASFloat::m_instance){
+ if (to == RplASInteger::m_instance)
+ rc = C_FLOAT_TO_INT;
+ } else if (from == RplASInteger::m_instance){
+ if (to == RplASFloat::m_instance)
+ rc = C_INT_TO_FLOAT;
+ } else if (from == RplASBoolean::m_instance){
+ if (to == RplASInteger::m_instance)
+ rc = C_BOOL_TO_INT;
+ else if (to == RplASInteger::m_instance)
+ rc = C_BOOL_TO_INT;
+ else if (to == RplASFloat::m_instance)
+ rc = C_BOOL_TO_FLOAT;
+ }
+ return rc;
+}
+
+/**
+ * @brief Checks the node.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: node is correct<br>
+ * <code>false</code>: otherwise
+ */
+bool RplASConversion::check(RplParser& parser)
+{
+ bool rc = false;
+ RplASCalculable* expr = dynamic_cast<RplASCalculable*>(m_child);
+ if (expr == NULL){
+ parser.error(LOC_CONV_CHECK_1, "missing expr");
+ } else {
+ RplASClass* from = expr->clazz();
+ rc = m_child->check(parser);
+ if (rc){
+ m_conversion = findConversion(from, m_class);
+ if (m_conversion != C_UNDEF)
+ rc = true;
+ else
+ parser.error(LOC_CONV_CHECK_2,
+ "invalid data type conversion: %s -> %s",
+ from->name().constData(),
+ m_class->name().constData());
+ }
+ }
+ return rc;
+}
+
+/**
+ * @brief Writes the internals into a file.
+ *
+ * @param writer writes to output
+ * @param indent nesting level
+ */
+void RplASConversion::dump(RplWriter& writer, int indent)
+{
+ char buffer[256];
+ writer.formatIndented(indent, "conversion %s id: %d expr: %d %s",
+ m_class->name().constData(), m_id, m_child->id(),
+ positionStr(buffer, sizeof buffer));
+}
+
+/**
+ * @brief Tries to find a conversion to a given type.
+ *
+ * Checks if an expression has a given type. If not it will be tried to find
+ * a conversion. If this is not possible an error occurres. Otherwise the
+ * converter will be returned.
+ *
+ * @param expected the expected data type
+ * @param expr the expression to convert
+ * @param parser for error processing
+ *
+ * @return NULL: no conversion necessary<br>
+ * otherwise: a converter to the given type
+ */
+RplASConversion* RplASConversion::tryConversion(RplASClass* expected,
+ RplASItem* expr, RplParser& parser)
+{
+ RplASConversion* rc = NULL;
+ if (expr->check(parser)){
+ RplASCalculable* expr2 = dynamic_cast<RplASCalculable*>(expr);
+ if (expr2 != NULL){
+ Conversion type = findConversion(expr2->clazz(), expected);
+ if (type == C_UNDEF){
+ parser.error(LOC_CONV_TRY_1,
+ "invalid data type conversion: %s -> %s",
+ expr2->clazz()->name().constData(),
+ expected->name().constData());
+ } else if (expr2->clazz() != expected){
+ rc = new RplASConversion(expr);
+ rc->m_conversion = type;
+ rc->setClass(expected);
+ }
+ }
+ }
+ return rc;
+}
+
/** @class RplASIndexedValue rplastree.hpp "rplexpr/rplastree.hpp"
*
* @brief Implements an indexed values (member of a list)
*
- * <code>m_child</code>: the parent: a list expression
+ * <code>m_child</code>: the parent: a list/map expression
* <code>m_child2</code>: the index expression
*/
RplASIndexedValue::RplASIndexedValue() :
{
}
+/**
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: node is correct<br>
+ * <code>false</code>: otherwise
+ */
+bool RplASIndexedValue::check(RplParser& parser)
+{
+ bool rc = false;
+ RplASCalculable* list = dynamic_cast<RplASCalculable*>(m_child);
+ if (list == NULL)
+ throw RplASException(m_position, "indexed value: empty list");
+ m_child->check(parser);
+ RplASConversion* converter = RplASConversion::tryConversion(
+ RplASInteger::m_instance, m_child, parser);
+ if (converter == NULL){
+ RplASClass* clazz = list->clazz();
+ rc = clazz != NULL && clazz == RplASInteger::m_instance;
+ } else {
+ m_child = converter;
+ rc = true;
+ }
+ return rc;
+}
+
/**
* @brief Writes the internals into an output media.
*
if (m_endOfScope > 0)
qsnprintf(endOfScope, sizeof endOfScope, "-%d:0", m_endOfScope);
char buffer[256];
- writer.formatIndented(indent, "varDef %s %s id: %d namedValue: %d value: %d succ: %d %s%s",
- namedValue == NULL || namedValue->dataType() == NULL
- ? "?" : namedValue->dataType()->name().constData(),
+ writer.formatIndented(indent,
+ "varDef %s %s id: %d namedValue: %d value: %d succ: %d %s%s",
+ clazz() == NULL ? "?" : clazz()->name().constData(),
name.constData(), m_id,
m_child2 == NULL ? 0 : m_child2->id(),
m_child3 == NULL ? 0 : m_child3->id(),
*
* @return the data type
*/
-RplASClass* RplASVarDefinition::datatype() const
+RplASClass* RplASVarDefinition::clazz() const
{
RplASNamedValue* namedValue = dynamic_cast<RplASNamedValue*>(m_child2);
- RplASClass* rc = namedValue->dataType();
+ RplASClass* rc = namedValue == NULL ? NULL : namedValue->clazz();
return rc;
}
/**
/**
- * @brief Executes the statement.
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: node is correct<br>
+ * <code>false</code>: otherwise
*/
-void RplASVarDefinition::execute(RplVMThread& thread)
+bool RplASVarDefinition::check(RplParser& parser)
{
+ bool rc = false;
if (m_child3 != NULL){
RplASNamedValue* var = dynamic_cast<RplASNamedValue*>(m_child2);
if (var == NULL)
- error(thread.logger(), LOC_VARDEF_EXEC_1,
- "Not a named value: id: %d",
+ error(LOC_VARDEF_CHECK_1, parser, "Not a named value: id: %d",
m_child2 == NULL ? 0 : m_child2->id());
else{
- RplASCalculable* expr = dynamic_cast<RplASCalculable*>(m_child3);
- if (expr == NULL)
- error(thread.logger(), LOC_VARDEF_EXEC_1,
- "not calculable: id: %d",
- m_child3 == NULL ? 0 : m_child2->id());
+ if (m_child3 == NULL)
+ // no initialization:
+ rc = true;
else {
- expr->calc(thread);
- var->assign(thread);
+ rc = m_child3->check(parser);
+ if (rc){
+ RplASCalculable* expr = dynamic_cast<RplASCalculable*>(m_child3);
+ if (! typeCheck(var->clazz(), expr->clazz()))
+ rc = error(LOC_VARDEF_CHECK_2, parser,
+ "data types are not compatible: %s/%s",
+ var->clazz()->name().constData(),
+ expr->clazz() == NULL ? "?"
+ : expr->clazz()->name().constData());
+ }
}
}
}
+ return rc;
+}
+
+/**
+ * @brief Executes the statement.
+ */
+void RplASVarDefinition::execute(RplVMThread& thread)
+{
+ RplASNamedValue* var = dynamic_cast<RplASNamedValue*>(m_child2);
+ RplASCalculable* expr = dynamic_cast<RplASCalculable*>(m_child3);
+ expr->calc(thread);
+ RplASVariant& value = thread.popValue();
+ RplASVariant& destination = thread.valueOfVariable(
+ var->m_symbolSpace, var->m_variableNo);
+ if (thread.tracing())
+ thread.vm()->traceWriter()->format("%s = %.80s [%.80s]",
+ var->m_name.constData(),
+ value.toString().constData(),
+ destination.toString().constData());
+ destination.copyValue(value);
}
/** @class RplASExprStatement rplastree.hpp "rplexpr/rplastree.hpp"
m_flags |= NF_STATEMENT;
}
+/**
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: node is correct<br>
+ * <code>false</code>: otherwise
+ */
+bool RplASExprStatement::check(RplParser& parser)
+{
+ bool rc = m_child2->check(parser);
+ RplASCalculable* expr = dynamic_cast<RplASCalculable*> (m_child2);
+ if (expr == NULL)
+ rc = false;
+ return rc;
+}
/**
* @brief Executes the statement.
*/
void RplASExprStatement::execute(RplVMThread& thread)
{
-
+ RplASCalculable* expr = dynamic_cast<RplASCalculable*> (m_child2);
+ expr->calc(thread);
+ RplASVariant& value = thread.popValue();
+ value.destroyValue();
}
/**
*/
void RplASNode1::setChild(RplASItem* child)
{
+ if (child->id() == 2)
+ m_child = child;
m_child = child;
}
*
* @brief Implements an unary operation.
*
- * This is an operation with one operand, e.g. the boolean not operation.
+ * This is an operation with one operand, e.g. the boolean 'not' operation.
+ *
+ * <code>m_child</code>: operand
*/
/**
switch(m_operator){
case UOP_PLUS:
break;
- case UOP_MINUS:
- switch (value.variantType()){
- case RplASVariant::VT_FLOAT:
- value.setFloat(- value.asFloat());
- break;
- case RplASVariant::VT_INTEGER:
- value.setInt(- value.asInt());
- break;
- case RplASVariant::VT_BOOL:
- case RplASVariant::VT_OBJECT:
- default:
- error(thread.logger(), LOC_UNOP_1, "wrong type %s for '-'",
- value.nameOfType());
- break;
- }
+ case UOP_MINUS_INT:
+ value.setInt(- value.asInt());
break;
- case UOP_LOGICAL_NOT:
- switch (value.variantType()){
- case RplASVariant::VT_FLOAT:
- value.setBool(value.asFloat() != 0.0);
- break;
- case RplASVariant::VT_INTEGER:
- value.setBool(value.asInt() != 0);
- break;
- case RplASVariant::VT_BOOL:
- value.setBool(! value.asBool());
- break;
- case RplASVariant::VT_OBJECT:
- default:
- error(thread.logger(), LOC_UNOP_2, "wrong type %s for '!'",
- value.nameOfType());
- break;
- }
+ case UOP_MINUS_FLOAT:
+ value.setFloat(- value.asFloat());
break;
- case UOP_BIT_NOT:
- switch (value.variantType()){
- case RplASVariant::VT_INTEGER:
- value.setInt(~value.asInt());
- break;
- case RplASVariant::VT_FLOAT:
- case RplASVariant::VT_BOOL:
- case RplASVariant::VT_OBJECT:
- default:
- error(thread.logger(), LOC_UNOP_3, "wrong type %s for '~'",
- value.nameOfType());
- break;
- }
+ case UOP_NOT_BOOL:
+ value.setBool(! value.asBool());
+ break;
+ case UOP_NOT_INT:
+ value.setInt(~value.asInt());
break;
+ case UOP_DEC:
+ case UOP_INC:
default:
- error(thread.logger(), LOC_UNOP_4, "unknown operator: %d", m_operator);
+ error(thread.logger(), LOC_UNOP_CALC_1, "unknown operator: %d", m_operator);
break;
}
}
+/**
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: node is correct<br>
+ * <code>false</code>: otherwise
+ */
+bool RplASUnaryOp::check(RplParser& parser)
+{
+ bool rc = m_child->check(parser);
+ if (rc){
+ RplASCalculable* expr = dynamic_cast<RplASCalculable*>(m_child);
+ RplASClass* clazz = expr == NULL ? NULL : expr->clazz();
+ if (clazz == NULL){
+ rc = ensureError(parser);
+ } else {
+ switch(m_operator){
+ case UOP_PLUS:
+ if (clazz != RplASInteger::m_instance
+ && clazz != RplASFloat::m_instance)
+ rc = error(LOC_UNARY_CHECK_1, parser,
+ "wrong data type for unary operator '+': %s",
+ clazz->name().constData());
+ break;
+ case UOP_MINUS_INT:
+ if (clazz != RplASFloat::m_instance)
+ m_operator = UOP_MINUS_FLOAT;
+ else if (clazz != RplASInteger::m_instance)
+ rc = error(LOC_UNARY_CHECK_2, parser,
+ "wrong data type for unary operator '-': %s",
+ clazz->name().constData());
+ break;
+ case UOP_NOT_BOOL:
+ if (clazz != RplASBoolean::m_instance)
+ rc = error(LOC_UNARY_CHECK_3, parser,
+ "wrong data type for unary operator '!': %s",
+ clazz->name().constData());
+ break;
+ case UOP_NOT_INT:
+ if (clazz != RplASInteger::m_instance)
+ rc = error(LOC_UNARY_CHECK_4, parser,
+ "wrong data type for unary operator '!': %s",
+ clazz->name().constData());
+ break;
+ case UOP_DEC:
+ break;
+ case UOP_INC:
+ break;
+ default:
+ throw RplASException(position(), "unknown operator: %d", m_operator);
+ break;
+ }
+ }
+ }
+ return rc;
+}
+
/**
* @brief Returns the operator of the unary operation.
*
/**
* @brief Returns the name (a string) of an unary operator.
*
- * @param op the op to convert
+ * @param op the operand to convert
* @return the name of the operator
*/
const char*RplASUnaryOp::nameOfOp(RplASUnaryOp::UnaryOp op)
case UOP_PLUS:
rc="+";
break;
- case UOP_MINUS:
+ case UOP_MINUS_INT:
+ case UOP_MINUS_FLOAT:
rc="-";
break;
- case UOP_LOGICAL_NOT:
+ case UOP_NOT_BOOL:
rc="!";
break;
- case UOP_BIT_NOT:
+ case UOP_NOT_INT:
rc="~";
break;
case UOP_INC:
throw RplASException(m_position, "child of condition is not calculable");
node->calc(thread);
}
+
+/**
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: node is correct<br>
+ * <code>false</code>: otherwise
+ */
+bool RplASCondition::check(RplParser& parser)
+{
+ return false;
+}
/**
* @brief Calculates the boolean value and returns it.
*/
m_flags |= NF_STATEMENT;
}
+/**
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: node is correct<br>
+ * <code>false</code>: otherwise
+ */
+bool RplASIf::check(RplParser& parser)
+{
+ return false;
+}
+
/**
* @brief Executes the statement.
*
m_child2 = variable;
}
+/**
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: node is correct<br>
+ * <code>false</code>: otherwise
+ */
+bool RplASForIterated::check(RplParser& parser)
+{
+ return false;
+}
+
/**
* @brief Executes the statement.
*
m_child3 = variable;
}
+/**
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: node is correct<br>
+ * <code>false</code>: otherwise
+ */
+bool RplASForCounted::check(RplParser& parser)
+{
+ return false;
+}
+
/**
* @brief Executes the statement.
*
m_flags |= NF_STATEMENT;
}
+/**
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: node is correct<br>
+ * <code>false</code>: otherwise
+ */
+bool RplASWhile::check(RplParser& parser)
+{
+ return false;
+}
+
/**
* @brief Executes the statement.
*
m_flags |= NF_STATEMENT;
}
+/**
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: node is correct<br>
+ * <code>false</code>: otherwise
+ */
+bool RplASRepeat::check(RplParser& parser)
+{
+ return false;
+}
+
/**
* @brief Executes the statement.
*
m_child3 = parent;
}
+/**
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: node is correct<br>
+ * <code>false</code>: otherwise
+ */
+bool RplASMethodCall::check(RplParser& parser)
+{
+ return false;
+}
+
/**
* @brief Writes the internals into a file.
}
}
+/**
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: node is correct<br>
+ * <code>false</code>: otherwise
+ */
+bool RplASBinaryOp::check(RplParser& parser)
+{
+ return false;
+}
+
/**
* @brief Returns the operator.
*
{
}
+/**
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: node is correct<br>
+ * <code>false</code>: otherwise
+ */
+bool RplASMethod::check(RplParser& parser)
+{
+ return false;
+}
+
+/**
+ * @brief Executes the statement.
+ *
+ * This method will be never called. Must exit: Otherwise the class is abstract.
+ */
+void RplASMethod::execute(RplVMThread& thread)
+{
+}
+
/**
* @brief Writes the internals of the instance into a file.
else {
RplASVarDefinition* def = dynamic_cast<RplASVarDefinition*>(args->child2());
RplASVarDefinition* defOther = dynamic_cast<RplASVarDefinition*>(otherArgs->child2());
- if (def->datatype() != defOther->datatype())
+ if (def->clazz() != defOther->clazz())
rc = false;
}
}
{
}
+/**
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: node is correct<br>
+ * <code>false</code>: otherwise
+ */
+bool RplASArgument::check(RplParser& parser)
+{
+ return false;
+}
+
/**
* @brief Writes the internals of the instance into a file.
*
{
}
+/**
+ * @brief Checks the correctness of the instance.
+ *
+ * @param parser for error processing
+ * @return <code>true</code>: node is correct<br>
+ * <code>false</code>: otherwise
+ */
+bool RplASField::check(RplParser& parser)
+{
+ return false;
+}
+
/**
* @brief Writes the internals of the instance into a file.
*
AST_MAP_CONSTANT,
AST_MAP_ENTRY,
AST_NAMED_VALUE,
+ AST_CONVERSION,
AST_INDEXED_VALUE,
AST_FIELD,
AST_VAR_DEFINITION,
};
class RplASTree;
+class RplParser;
class RplASItem
{
public:
friend class RplASTree;
RplASItem(RplASItemType type);
virtual ~RplASItem();
+public:
+ virtual bool check(RplParser& parser) = 0;
public:
const RplSourcePosition* position() const;
void setPosition(const RplSourcePosition* position);
int flags() const;
void setFlags(int flags);
+ bool typeCheck(RplASClass* clazz1, RplASClass* clazz2);
+ bool error(int location, RplParser& parser, const char* format, ...);
+ bool ensureError(RplParser& parser);
protected:
unsigned int m_id:16;
RplASItemType m_nodeType:8;
class RplVMThread;
class RplASCalculable
{
+public:
+ RplASCalculable();
public:
virtual void calc(RplVMThread& thread) = 0;
+public:
+ RplASClass* clazz() const;
+ void setClass(RplASClass* clazz);
+protected:
+ RplASClass* m_class;
};
class RplStackFrame;
-class RplASStorable : RplASCalculable {
+class RplASStorable : public RplASCalculable {
};
class RplVMThread;
class RplASConstant : public RplASItem, public RplASCalculable
RplASConstant();
public:
virtual void calc(RplVMThread& thread);
+ virtual bool check(RplParser& parser);
public:
virtual void dump(RplWriter& writer,int indent);
RplASVariant& value();
RplASListConstant();
public:
virtual void calc(RplVMThread& thread);
+ virtual bool check(RplParser& parser);
+
public:
virtual void dump(RplWriter& writer,int indent);
RplASVariant& value();
RplASMapConstant();
public:
virtual void calc(RplVMThread& thread);
+ virtual bool check(RplParser& parser);
public:
virtual void dump(RplWriter& writer,int indent);
RplASVariant& value();
class RplSymbolSpace;
class RplASNamedValue : public RplASNode1, public RplASStorable
{
+ friend class RplASVarDefinition;
public:
enum Attributes {
A_NONE,
public:
RplASNamedValue(RplASClass* dataType, RplSymbolSpace* space,
const QByteArray& name, int attributes);
+public:
+ virtual void calc(RplVMThread& thread);
+ virtual bool check(RplParser& parser);
public:
const QByteArray& name() const;
void setSymbolSpace(RplSymbolSpace* space, int variableNo);
- virtual void calc(RplVMThread& thread);
void dump(RplWriter& writer, int indent);
- RplASClass* dataType() const;
- void assign(RplVMThread& thread);
RplSymbolSpace* symbolSpace() const;
int variableNo() const;
void setVariableNo(int variableNo);
protected:
QByteArray m_name;
int m_attributes;
- RplASClass* m_dataType;
RplSymbolSpace* m_symbolSpace;
int m_variableNo;
};
+class RplASConversion : public RplASNode1, public RplASCalculable {
+public:
+ enum Conversion {
+ C_UNDEF,
+ C_INT_TO_FLOAT,
+ C_FLOAT_TO_INT,
+ C_BOOL_TO_INT,
+ C_BOOL_TO_FLOAT
+ };
+
+public:
+ RplASConversion(RplASItem* expression);
+public:
+ virtual void calc(RplVMThread& thread);
+ virtual bool check(RplParser& parser);
+ virtual void dump(RplWriter& writer,int indent);
+public:
+ static RplASConversion* tryConversion(RplASClass* expected, RplASItem* expr,
+ RplParser& parser);
+ static Conversion findConversion(RplASClass* from, RplASClass* to);
+private:
+ Conversion m_conversion;
+};
class RplASIndexedValue : public RplASNode2 {
public:
RplASIndexedValue();
+public:
+ virtual bool check(RplParser& parser);
public:
void dump(RplWriter& writer, int indent);
};
public:
RplASVarDefinition();
public:
+ virtual bool check(RplParser& parser);
virtual void execute(RplVMThread& thread);
+public:
void dump(RplWriter& writer, int indent);
const QByteArray& name() const;
- RplASClass* datatype() const;
int endOfScope() const;
void setEndOfScope(int endOfScope);
-
+ RplASClass* clazz() const;
private:
/// the column of the blockend containing the definition.
/// if 0: end is end of method or end of class
public:
RplASExprStatement();
public:
+ virtual bool check(RplParser& parser);
virtual void execute(RplVMThread& thread);
+public:
void dump(RplWriter& writer, int indent);
};
enum UnaryOp {
UOP_UNDEF,
UOP_PLUS,
- UOP_MINUS,
- UOP_LOGICAL_NOT,
- UOP_BIT_NOT,
+ UOP_MINUS_INT,
+ UOP_MINUS_FLOAT,
+ UOP_NOT_BOOL,
+ UOP_NOT_INT,
UOP_INC,
UOP_DEC
};
RplASUnaryOp(UnaryOp op, RplASItemType type);
public:
virtual void calc(RplVMThread& thread);
+ virtual bool check(RplParser& parser);
+public:
int getOperator() const;
void dump(RplWriter& writer, int indent);
public:
public:
RplASBinaryOp();
public:
- void calc(RplVMThread& thread);
+ virtual void calc(RplVMThread& thread);
+ virtual bool check(RplParser& parser);
+public:
BinOperator getOperator() const;
void setOperator(BinOperator op);
void dump(RplWriter& writer, int indent);
public:
RplASCondition();
public:
- void calc(RplVMThread& thread);
+ virtual void calc(RplVMThread& thread);
+ virtual bool check(RplParser& parser);
+public:
bool calcAsBool(RplVMThread& thread);
void dump(RplWriter& writer, int indent);
};
public:
RplASIf();
public:
+ virtual bool check(RplParser& parser);
virtual void execute(RplVMThread& thread);
virtual void dump(RplWriter& writer, int indent);
};
public:
RplASForIterated(RplASVarDefinition* variable);
public:
+ virtual bool check(RplParser& parser);
virtual void execute(RplVMThread& thread);
virtual void dump(RplWriter& writer, int indent);
};
public:
RplASForCounted(RplASVarDefinition* variable);
public:
+ virtual bool check(RplParser& parser);
virtual void execute(RplVMThread& thread);
virtual void dump(RplWriter& writer, int indent);
};
public:
RplASWhile();
public:
+ virtual bool check(RplParser& parser);
virtual void execute(RplVMThread& thread);
virtual void dump(RplWriter& writer, int indent);
};
public:
RplASRepeat();
public:
+ virtual bool check(RplParser& parser);
virtual void execute(RplVMThread& thread);
virtual void dump(RplWriter& writer, int indent);
};
{
public:
RplASArgument();
+public:
+ virtual bool check(RplParser& parser);
public:
void dump(RplWriter& writer, int indent);
protected:
public:
RplASMethodCall(const QByteArray& name, RplASItem* parent);
public:
- void dump(RplWriter& writer, int indent);
+ virtual bool check(RplParser& parser);
virtual void execute(RplVMThread& thread);
+public:
+ void dump(RplWriter& writer, int indent);
public:
RplASMethod* method() const;
{
public:
RplASField(const QByteArray& name);
+public:
+ virtual bool check(RplParser& parser);
public:
void dump(RplWriter& writer, int indent);
private:
public:
RplASMethod(const QByteArray& name, RplASTree& tree);
public:
- void execute(RplVMThread& thread);
+ virtual bool check(RplParser& parser);
+ virtual void execute(RplVMThread& thread);
+public:
void dump(RplWriter& writer, int indent);
RplSymbolSpace* symbols() const;
void setSymbols();
};
#include "rplexpr/rplasclasses.hpp"
+
+#include "rplparser.hpp"
class RplSymbolSpace;
class RplASTree
{
RplASVarDefinition* var = space->findVariable(name);
RplASClass* clazz = NULL;
if (var != NULL)
- clazz = var->datatype();
+ clazz = var->clazz();
RplASNamedValue* var2 = new RplASNamedValue(clazz, space,
name, RplASNamedValue::A_NONE);
var2->setPosition(position);
rc = RplASUnaryOp::UOP_PLUS;
break;
case O_MINUS:
- rc = RplASUnaryOp::UOP_MINUS;
+ rc = RplASUnaryOp::UOP_MINUS_INT;
break;
case O_NOT:
- rc = RplASUnaryOp::UOP_LOGICAL_NOT;
+ rc = RplASUnaryOp::UOP_NOT_BOOL;
break;
case O_BIT_NOT:
- rc = RplASUnaryOp::UOP_BIT_NOT;
+ rc = RplASUnaryOp::UOP_NOT_INT;
break;
case O_INC:
rc = RplASUnaryOp::UOP_INC;
break;
case K_CLASS:
parseClass();
+ item = NULL;
break;
case K_FUNCTION:
case K_GENERATOR:
parseMethod();
+ item = NULL;
break;
case K_IMPORT:
parseImport();
+ item = NULL;
break;
case K_CONST:
case K_LAZY:
* @param location unique id of the error/warning message
* @param position position of the error/warning
* @param message message with placeholdes like sprintf()
+ * @return false (for chaining)
*/
-void RplParser::addSimpleMessage(LevelTag prefix, int location,
+bool RplParser::addSimpleMessage(LevelTag prefix, int location,
const RplSourcePosition* position,
const char* message){
char buffer[2048];
memcpy(buffer + used, message, length);
buffer[used + length] = '\0';
m_messages.append(buffer);
+ return false;
}
/**
* @param position position of the error/warning
* @param format message with placeholdes like sprintf()
* @param varList the variable argument list
+ * @return false (for chaining)
*/
-void RplParser::addMessage(LevelTag prefix, int location,
+bool RplParser::addMessage(LevelTag prefix, int location,
const RplSourcePosition* position,
const char* format, va_list varList){
char buffer[2048];
qvsnprintf(buffer, sizeof buffer, format, varList);
- addSimpleMessage(prefix, location, position, buffer);
+ return addSimpleMessage(prefix, location, position, buffer);
}
/**
* @param location unique id of the error/warning message
* @param format message with placeholdes like sprintf()
* @param ... optional: the variable argument list
+ * @return false (for chaining)
*/
-void RplParser::error(int location, const char* format, ...)
+bool RplParser::error(int location, const char* format, ...)
{
va_list ap;
va_start(ap, format);
va_end(ap);
if (++m_errors >= m_maxErrors)
throw RplParserStop("too many errors");
+ return false;
}
/**
* @brief Adds an error message with an additional info message.
* @param message describes the error
* @param message2 the additional message
* @param ... optional: the variable argument list
+ * @return false (for chaining)
*/
-void RplParser::error(int location, const RplSourcePosition* position,
+bool RplParser::error(int location, const RplSourcePosition* position,
const char* message, const char* message2)
{
addSimpleMessage(LT_ERROR, location, m_lexer.currentPosition(), message);
addSimpleMessage(LT_INFO, location + 1, position, message2);
if (++m_errors >= m_maxErrors)
throw RplParserStop("too many errors");
+ return false;
}
/**
if (++m_warnings >= m_maxWarnings)
throw RplParserStop("too many warnings");
}
+/**
+ * @brief Return the number of errors.
+ *
+ * @return the count of errors occurred until now
+ */
+int RplParser::errors() const
+{
+ return m_errors;
+}
+/**
+ * @brief Return the number of warnings.
+ *
+ * @return the count of errors occurred until now
+ */
+int RplParser::warnings() const
+{
+ return m_warnings;
+}
public:
RplParser(RplLexer& lexer, RplASTree& ast);
public:
- void addSimpleMessage(LevelTag prefix, int location,
+ bool addSimpleMessage(LevelTag prefix, int location,
const RplSourcePosition* pos,
const char* message);
- void addMessage(LevelTag prefix, int location,
+ bool addMessage(LevelTag prefix, int location,
const RplSourcePosition* pos,
const char* format, va_list varList);
void syntaxError(int location, const char* message);
void syntaxError(int location, const char* message, const char* symbol,
const RplSourcePosition* position);
- void error(int location, const char* format, ...);
- void error(int location, const RplSourcePosition* position,
+ bool error(int location, const char* format, ...);
+ bool error(int location, const RplSourcePosition* position,
const char* message, const char* message2);
void warning(int location, const char* format, ...);
-
+ int errors() const;
+ int warnings() const;
protected:
RplLexer& m_lexer;
RplASTree& m_tree;
m_id(m_nextId++),
m_debugMode(false),
m_singleStep(false),
+ m_tracing(false),
m_maxStack(maxStack),
m_frameStack(),
// the stack is never empty!
return rc;
}
+/**
+ * @brief Returns whether each execution step should be dumped.
+ * @return true: tracing is on<br>
+ * false: otherwise
+ */
+bool RplVMThread::tracing() const
+{
+ return m_tracing;
+}
+
+/**
+ * @brief Sets the tracing flag: if set each execution step is dumped.
+ * @param tracing true: tracing will be done<br>
+ * false: tracing will not be done
+ */
+void RplVMThread::setTracing(bool tracing)
+{
+ m_tracing = tracing;
+}
+
+/**
+ * @brief Returns the parent, a virtual machine.
+ *
+ * @return the virtual machine
+ */
+RplVirtualMachine* RplVMThread::vm() const
+{
+ return m_vm;
+}
/** @class RplVirtualMachine rplvm.hpp "rplexpr/rplvm.hpp"
*
m_flags &= ~flag;
}
+/**
+ * @brief Returns the trace writer.
+ * @return the trace writer
+ */
+RplWriter* RplVirtualMachine::traceWriter() const
+{
+ return m_traceWriter;
+}
+
/**
* @brief Sets the trace writer.
*
void valueToTop(RplSymbolSpace* symbolSpace, int variableNo);
RplASVariant& lValue(RplASItem* item);
RplASVariant& valueOfVariable(RplSymbolSpace* symbolSpace, int variableNo);
+ bool tracing() const;
+ void setTracing(bool tracing);
+ RplVirtualMachine* vm() const;
+
protected:
int m_id;
bool m_debugMode;
bool m_singleStep;
+ bool m_tracing;
int m_maxStack;
StackFrameList m_frameStack;
int m_topOfFrames;
bool hasFlag(VMFlag flag) const;
void setFlag(VMFlag flag);
void clearFlag(VMFlag flag);
+ RplWriter* traceWriter() const;
void setTraceWriter(RplWriter* traceWriter);
RplASTree& tree() const;
--- /dev/null
+2+3*4
+= <test> (module) parent: $global
+== Body:
+Expr id: 6 expr: 2 succ: 0 <test>:1:1
+ BinOp id: 2 op: + (17) left: 1 right: 4 <test>:1:1
+ const id: 1 value: 2 <test>:0:0
+ BinOp id: 4 op: * (19) left: 3 right: 5 <test>:1:3
+ const id: 3 value: 3 <test>:1:2
+ const id: 5 value: 4 <test>:1:4
--- /dev/null
+file.find('*.c')[0].name;
+[1,2,3].join(' ');
+3.14.trunc;
+= <test> (module) parent: $global
+== Body:
+Expr id: 8 expr: 7 succ: 15 <test>:1:24
+ field name id: 7 parent: 5 succ: <test>:1:24
+ indexedValue id: 5 index: 6 parent: 2 <test>:1:16
+ const id: 6 value: 0 <test>:1:17
+ call find Id: 2 args: 4 parent: 1 succ: 0 <test>:1:9
+ arg 1 id: 4 expr: 3 succ: 0
+ const id: 3 value: '*.c' <test>:1:10
+ namedValue file id: 1 attr: 0x0 <test>:1:4
+Expr id: 15 expr: 12 succ: 18 <test>:2:12
+ call join Id: 12 args: 14 parent: 9 succ: 0 <test>:2:12
+ arg 1 id: 14 expr: 13 succ: 0
+ const id: 13 value: ' ' <test>:2:13
+ listConst id: 9 <test>:1:26
+ [1,2,<formula 11>]
+Expr id: 18 expr: 17 succ: 0 <test>:3:10
+ field trunc id: 17 parent: 16 succ: <test>:3:10
+ const id: 16 value: 3.140000 <test>:2:19
--- /dev/null
+Int a;
+for b from 10 to 1 step -2 do
+a += 1;
+od
+= <test> (module) parent: $global
+== Variables:
+varDef Int a id: 2 namedValue: 1 value: 0 succ: 5 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+varDef Int b id: 4 namedValue: 3 value: 0 succ: 0 <test>:2:4-3:0
+ namedValue b id: 3 attr: 0x40 <test>:2:4
+== Body:
+varDef Int a id: 2 namedValue: 1 value: 0 succ: 5 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+forC id: 5 var: 3 from: 6 to: 7 step: 8 body: 13 succ: 0 <test>:1:7
+ namedValue b id: 3 attr: 0x40 <test>:2:4
+ const id: 6 value: 10 <test>:2:11
+ const id: 7 value: 1 <test>:2:17
+ Unary 8 op: - (2) expr: 9 <test>:2:24
+ const id: 9 value: 2 <test>:2:25
+ Expr id: 13 expr: 11 succ: 0 <test>:3:2
+ BinOp id: 11 op: += (2) left: 10 right: 12 <test>:3:2
+ namedValue a id: 10 attr: 0x0 <test>:3:2
+ const id: 12 value: 1 <test>:3:5
--- /dev/null
+Int a; for to 10 do a += 1 od
+= <test> (module) parent: $global
+== Variables:
+varDef Int a id: 2 namedValue: 1 value: 0 succ: 5 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+varDef Int $1_7 id: 4 namedValue: 3 value: 0 succ: 0 <test>:1:7-1:0
+ namedValue $1_7 id: 3 attr: 0x40 <test>:1:7
+== Body:
+varDef Int a id: 2 namedValue: 1 value: 0 succ: 5 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+forC id: 5 var: 3 from: 0 to: 6 step: 0 body: 10 succ: 0 <test>:1:7
+ namedValue $1_7 id: 3 attr: 0x40 <test>:1:7
+ const id: 6 value: 10 <test>:1:14
+ Expr id: 10 expr: 8 succ: 0 <test>:1:22
+ BinOp id: 8 op: += (2) left: 7 right: 9 <test>:1:22
+ namedValue a id: 7 attr: 0x0 <test>:1:22
+ const id: 9 value: 1 <test>:1:25
--- /dev/null
+Map a;
+for x in a do
+a += 1;
+od
+= <test> (module) parent: $global
+== Variables:
+varDef Map a id: 2 namedValue: 1 value: 0 succ: 5 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+varDef Int x id: 4 namedValue: 3 value: 0 succ: 0 <test>:2:4-3:0
+ namedValue x id: 3 attr: 0x40 <test>:2:4
+== Body:
+varDef Map a id: 2 namedValue: 1 value: 0 succ: 5 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+forIt id: 5 var: 3 set: 6 body: 10 succ: 0 <test>:1:7
+ namedValue x id: 3 attr: 0x40 <test>:2:4
+ namedValue a id: 6 attr: 0x0 <test>:2:11
+ Expr id: 10 expr: 8 succ: 0 <test>:3:2
+ BinOp id: 8 op: += (2) left: 7 right: 9 <test>:3:2
+ namedValue a id: 7 attr: 0x0 <test>:3:2
+ const id: 9 value: 1 <test>:3:5
--- /dev/null
+Int a;
+Int b;
+a = b = 2;
+if 11 < 12
+then a = 13 * 14
+else a = 15 / 16
+fi
+= <test> (module) parent: $global
+== Variables:
+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
+== Body:
+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: = (1) left: 5 right: 8 <test>:3:2
+ namedValue a id: 5 attr: 0x0 <test>:3:2
+ BinOp id: 8 op: = (1) 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: < (35) 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: = (1) left: 15 right: 18 <test>:5:7
+ namedValue a id: 15 attr: 0x0 <test>:5:7
+ BinOp id: 18 op: * (19) 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: = (1) left: 21 right: 24 <test>:6:7
+ namedValue a id: 21 attr: 0x0 <test>:6:7
+ BinOp id: 24 op: / (20) left: 23 right: 25 <test>:6:12
+ const id: 23 value: 15 <test>:6:9
+ const id: 25 value: 16 <test>:6:14
--- /dev/null
+Str x;
+if 7 < 6
+then x = '123';
+fi
+= <test> (module) parent: $global
+== Variables:
+varDef x id: 2 namedValue: 1 value: 0 succ: 3 <test>:1:4
+ namedValue x id: 1 attr: 0x0 <test>:1:4
+== Body:
+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: < (35) 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: = (1) left: 7 right: 9 <test>:3:7
+ namedValue x id: 7 attr: 0x0 <test>:3:7
+ const id: 9 value: '123' <test>:3:9
--- /dev/null
+List b = [];
+= <test> (module) parent: $global
+== Variables:
+varDef List 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
+ []
+== Body:
+varDef List 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
+ []
--- /dev/null
+List a = [2+3, 3.14, 7, 'hi', a]; List b = [];
+= <test> (module) parent: $global
+== Variables:
+varDef List 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 List 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
+ []
+== Body:
+varDef List 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 List 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
+ []
--- /dev/null
+Int a=2+3*4;
+func Void main():
+a;
+endf
+= <test> (module) parent: $global
+== Methods:
+Method <NoneType> main() id: 8 parent: <test> args: 0 body: 10 <test>:1:13
+ Expr id: 10 expr: 9 succ: 0 <test>:3:1
+ namedValue a id: 9 attr: 0x0 <test>:3:1
+ = <test>.main (method) parent: <test>
+== Variables:
+varDef Int a id: 2 namedValue: 1 value: 4 succ: 0 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+ BinOp id: 4 op: + (17) left: 3 right: 6 <test>:1:7
+ const id: 3 value: 2 <test>:1:6
+ BinOp id: 6 op: * (19) left: 5 right: 7 <test>:1:9
+ const id: 5 value: 3 <test>:1:8
+ const id: 7 value: 4 <test>:1:10
+== Body:
+varDef Int a id: 2 namedValue: 1 value: 4 succ: 0 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+ BinOp id: 4 op: + (17) left: 3 right: 6 <test>:1:7
+ const id: 3 value: 2 <test>:1:6
+ BinOp id: 6 op: * (19) left: 5 right: 7 <test>:1:9
+ const id: 5 value: 3 <test>:1:8
+ const id: 7 value: 4 <test>:1:10
--- /dev/null
+Map a = {};
+= <test> (module) parent: $global
+== Variables:
+varDef Map 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
+ {}
+== Body:
+varDef Map 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
+ {}
--- /dev/null
+Map a = {'a': 2+3,'bcd':3.14,'ccc':7, 'hi':'world'};
+Map b = {};
+= <test> (module) parent: $global
+== Variables:
+varDef Map 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 Map 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
+ {}
+== Body:
+varDef Map 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 Map 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
+ {}
--- /dev/null
+func Float pi: 3.1415; endf func Str delim(): '/' endf;
+= <test> (module) parent: $global
+== Methods:
+Method <NoneType> delim() id: 4 parent: <test> args: 0 body: 6 <test>:1:28
+ Expr id: 6 expr: 5 succ: 0 <test>:1:46
+ const id: 5 value: '/' <test>:1:46
+ = <test>.delim (method) parent: <test>
+Method <NoneType> pi() id: 1 parent: <test> args: 0 body: 3 <test>:0:0
+ Expr id: 3 expr: 2 succ: 0 <test>:1:15
+ const id: 2 value: 3.141500 <test>:1:15
+ = <test>.pi (method) parent: <test>
--- /dev/null
+func Int fac(const Int n):
+Int rc; if rc <= 1 then rc = 1 else rc = n*fac(n-1) fi
+rc endf
+= <test> (module) parent: $global
+== Methods:
+Method <NoneType> fac() id: 1 parent: <test> args: 4 body: 6 <test>:0:55
+ Expr id: 4 expr: 3 succ: 0
+ varDef Int n id: 3 namedValue: 2 value: 0 succ: 0 <test>:1:23
+ namedValue n id: 2 attr: 0x22 <test>:1:23
+ varDef Int rc id: 6 namedValue: 5 value: 0 succ: 7 <test>:2:4
+ namedValue rc id: 5 attr: 0x0 <test>:2:4
+ If id: 7 condition: 9 then: 14 else: 24 succ: 26<test>:2:8
+ BinOp id: 9 op: <= (34) left: 8 right: 10 <test>:2:14
+ namedValue rc id: 8 attr: 0x0 <test>:2:14
+ const id: 10 value: 1 <test>:2:17
+ Expr id: 14 expr: 12 succ: 0 <test>:2:27
+ BinOp id: 12 op: = (1) left: 11 right: 13 <test>:2:27
+ namedValue rc id: 11 attr: 0x0 <test>:2:27
+ const id: 13 value: 1 <test>:2:29
+ Expr id: 24 expr: 16 succ: 0 <test>:2:39
+ BinOp id: 16 op: = (1) left: 15 right: 18 <test>:2:39
+ namedValue rc id: 15 attr: 0x0 <test>:2:39
+ BinOp id: 18 op: * (19) left: 17 right: 19 <test>:2:42
+ namedValue n id: 17 attr: 0x0 <test>:2:42
+ call fac Id: 19 args: 23 parent: 0 succ: 0 <test>:2:46
+ arg 1 id: 23 expr: 21 succ: 0
+ BinOp id: 21 op: - (18) left: 20 right: 22 <test>:2:48
+ namedValue n id: 20 attr: 0x0 <test>:2:48
+ const id: 22 value: 1 <test>:2:49
+ Expr id: 26 expr: 25 succ: 0 <test>:3:3
+ namedValue rc id: 25 attr: 0x0 <test>:3:3
+ = <test>.fac (method) parent: <test>
+ == Variables:
+ varDef Int n id: 3 namedValue: 2 value: 0 succ: 0 <test>:1:23
+ namedValue n id: 2 attr: 0x22 <test>:1:23
+ varDef Int rc id: 6 namedValue: 5 value: 0 succ: 7 <test>:2:4
+ namedValue rc id: 5 attr: 0x0 <test>:2:4
--- /dev/null
+func Int max(Int a, Int b):
+ Int rc = a;
+if a < b then rc = b; fi
+rc
+endf
+func Int max(const Int a, Int b, Int c):
+max(a, max(b, c))
+endf
+= <test> (module) parent: $global
+== Methods:
+Method <NoneType> max() id: 21 parent: <test> args: 24 body: 40 <test>:5:5
+ Expr id: 24 expr: 23 succ: 27
+ varDef Int a id: 23 namedValue: 22 value: 0 succ: 0 <test>:6:23
+ namedValue a id: 22 attr: 0x22 <test>:6:23
+ Expr id: 40 expr: 31 succ: 0 <test>:7:3
+ call max Id: 31 args: 33 parent: 0 succ: 0 <test>:7:3
+ arg 1 id: 33 expr: 32 succ: 39
+ namedValue a id: 32 attr: 0x0 <test>:7:5
+ arg 2 id: 39 expr: 34 succ: 0
+ call max Id: 34 args: 36 parent: 0 succ: 0 <test>:7:10
+ arg 1 id: 36 expr: 35 succ: 38
+ namedValue b id: 35 attr: 0x0 <test>:7:12
+ arg 2 id: 38 expr: 37 succ: 0
+ namedValue c id: 37 attr: 0x0 <test>:7:15
+ = <test>.max (method) parent: <test>
+ == Variables:
+ varDef Int a id: 23 namedValue: 22 value: 0 succ: 0 <test>:6:23
+ namedValue a id: 22 attr: 0x22 <test>:6:23
+ varDef Int b id: 26 namedValue: 25 value: 0 succ: 0 <test>:6:30
+ namedValue b id: 25 attr: 0x20 <test>:6:30
+ varDef Int c id: 29 namedValue: 28 value: 0 succ: 0 <test>:6:37
+ namedValue c id: 28 attr: 0x20 <test>:6:37
--- /dev/null
+func Int max(const Int a, Int b, Int c):
+func Int max(Int a, Int b):
+ Int rc = a;
+if a < b then rc = b; fi
+rc
+endf
+max(a, max(b, c))
+endf
+= <test> (module) parent: $global
+== Methods:
+Method <NoneType> max() id: 1 parent: <test> args: 4 body: 40 <test>:0:4
+ Expr id: 4 expr: 3 succ: 7
+ varDef Int a id: 3 namedValue: 2 value: 0 succ: 0 <test>:1:23
+ namedValue a id: 2 attr: 0x22 <test>:1:23
+ Expr id: 40 expr: 31 succ: 0 <test>:7:3
+ call max Id: 31 args: 33 parent: 0 succ: 0 <test>:7:3
+ arg 1 id: 33 expr: 32 succ: 39
+ namedValue a id: 32 attr: 0x0 <test>:7:5
+ arg 2 id: 39 expr: 34 succ: 0
+ call max Id: 34 args: 36 parent: 0 succ: 0 <test>:7:10
+ arg 1 id: 36 expr: 35 succ: 38
+ namedValue b id: 35 attr: 0x0 <test>:7:12
+ arg 2 id: 38 expr: 37 succ: 0
+ namedValue c id: 37 attr: 0x0 <test>:7:15
+ = <test>.max (method) parent: <test>
+ == Methods:
+ Method <NoneType> max() id: 11 parent: <test>.max args: 14 body: 19 <test>:1:41
+ Expr id: 14 expr: 13 succ: 17
+ varDef Int a id: 13 namedValue: 12 value: 0 succ: 0 <test>:2:17
+ namedValue a id: 12 attr: 0x20 <test>:2:17
+ varDef Int rc id: 19 namedValue: 18 value: 20 succ: 21 <test>:3:5
+ namedValue rc id: 18 attr: 0x0 <test>:3:5
+ namedValue a id: 20 attr: 0x0 <test>:3:11
+ If id: 21 condition: 23 then: 28 else: 0 succ: 30<test>:3:13
+ BinOp id: 23 op: < (35) left: 22 right: 24 <test>:4:5
+ namedValue a id: 22 attr: 0x0 <test>:4:5
+ namedValue b id: 24 attr: 0x0 <test>:4:9
+ Expr id: 28 expr: 26 succ: 0 <test>:4:17
+ BinOp id: 26 op: = (1) left: 25 right: 27 <test>:4:17
+ namedValue rc id: 25 attr: 0x0 <test>:4:17
+ namedValue b id: 27 attr: 0x0 <test>:4:20
+ Expr id: 30 expr: 29 succ: 0 <test>:5:3
+ namedValue rc id: 29 attr: 0x0 <test>:5:3
+ = <test>.max.max (method) parent: <test>.max
+ == Variables:
+ varDef Int a id: 13 namedValue: 12 value: 0 succ: 0 <test>:2:17
+ namedValue a id: 12 attr: 0x20 <test>:2:17
+ varDef Int b id: 16 namedValue: 15 value: 0 succ: 0 <test>:2:24
+ namedValue b id: 15 attr: 0x20 <test>:2:24
+ varDef Int rc id: 19 namedValue: 18 value: 20 succ: 21 <test>:3:5
+ namedValue rc id: 18 attr: 0x0 <test>:3:5
+ namedValue a id: 20 attr: 0x0 <test>:3:11
+ == Variables:
+ varDef Int a id: 3 namedValue: 2 value: 0 succ: 0 <test>:1:23
+ namedValue a id: 2 attr: 0x22 <test>:1:23
+ varDef Int b id: 6 namedValue: 5 value: 0 succ: 0 <test>:1:30
+ namedValue b id: 5 attr: 0x20 <test>:1:30
+ varDef Int c id: 9 namedValue: 8 value: 0 succ: 0 <test>:1:37
+ namedValue c id: 8 attr: 0x20 <test>:1:37
--- /dev/null
+rand();
+sin(a);
+max(1+2*3,4**(5-4));
+= <test> (module) parent: $global
+== Body:
+Expr id: 2 expr: 1 succ: 6 <test>:1:4
+ call rand Id: 1 args: 0 parent: 0 succ: 0 <test>:1:4
+Expr id: 6 expr: 3 succ: 20 <test>:2:3
+ call sin Id: 3 args: 5 parent: 0 succ: 0 <test>:2:3
+ arg 1 id: 5 expr: 4 succ: 0
+ namedValue a id: 4 attr: 0x0 <test>:2:5
+Expr id: 20 expr: 7 succ: 0 <test>:3:3
+ call max Id: 7 args: 13 parent: 0 succ: 0 <test>:3:3
+ arg 1 id: 13 expr: 9 succ: 19
+ BinOp id: 9 op: + (17) left: 8 right: 11 <test>:3:5
+ const id: 8 value: 1 <test>:3:4
+ BinOp id: 11 op: * (19) left: 10 right: 12 <test>:3:7
+ const id: 10 value: 2 <test>:3:6
+ const id: 12 value: 3 <test>:3:8
+ arg 2 id: 19 expr: 15 succ: 0
+ BinOp id: 15 op: ** (22) left: 14 right: 17 <test>:3:11
+ const id: 14 value: 4 <test>:3:10
+ BinOp id: 17 op: - (18) left: 16 right: 18 <test>:3:15
+ const id: 16 value: 5 <test>:3:14
+ const id: 18 value: 4 <test>:3:16
--- /dev/null
+Int a = 1;
+Int b = 100;
+--a;
+b++;
+a--*++b**(8-3);
+a=b=(a+(b-2)*3)
+= <test> (module) parent: $global
+== Variables:
+varDef Int 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 Int 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
+== Body:
+varDef Int 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 Int 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: -- (6) expr: 8 <test>:2:13
+ namedValue a id: 8 attr: 0x0 <test>:3:3
+Expr id: 12 expr: 11 succ: 22
+ Unary 11 op: ++ (5) 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: * (19) left: 14 right: 18 <test>:5:3
+ Unary 14 op: -- (6) expr: 13
+ namedValue a id: 13 attr: 0x0 <test>:5:1
+ BinOp id: 18 op: ** (22) left: 16 right: 20 <test>:5:7
+ Unary 16 op: ++ (5) expr: 17 <test>:5:4
+ namedValue b id: 17 attr: 0x0 <test>:5:7
+ BinOp id: 20 op: - (18) 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: = (1) left: 23 right: 26 <test>:6:1
+ namedValue a id: 23 attr: 0x0 <test>:6:1
+ BinOp id: 26 op: = (1) left: 25 right: 28 <test>:6:3
+ namedValue b id: 25 attr: 0x0 <test>:6:3
+ BinOp id: 28 op: + (17) left: 27 right: 32 <test>:6:6
+ namedValue a id: 27 attr: 0x0 <test>:6:6
+ BinOp id: 32 op: * (19) left: 30 right: 33 <test>:6:12
+ BinOp id: 30 op: - (18) 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
--- /dev/null
+Int a;
+repeat
+a++;
+until a != 2 * 3;
+= <test> (module) parent: $global
+== Variables:
+varDef Int a id: 2 namedValue: 1 value: 0 succ: 3 <test>:1:4
+ namedValue a id: 1 attr: 0x0 <test>:1:4
+== Body:
+varDef Int 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: != (33) left: 7 right: 10 <test>:4:8
+ namedValue a id: 7 attr: 0x0 <test>:4:8
+ BinOp id: 10 op: * (19) 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: ++ (5) expr: 4
+ namedValue a id: 4 attr: 0x0 <test>:3:1
--- /dev/null
+Str x1 = "x1 123456789 123456789 123456789 123456789 123456789";
+Str x2 = "x2 123456789 123456789 123456789 123456789 123456789";
+Str x3 = "x3 123456789 123456789 123456789 123456789 123456789";
--- /dev/null
+Str x1 = "x1 123456789 123456789 123456789 123456789 123456789";
+Str x2 = "x2 123456789 123456789 123456789 123456789 123456789";
+Str x3 = "x3 123456789 123456789 123456789 123456789 123456789";
+= test/rplmfparser/string1.mf (module) parent: $global
+== Variables:
+varDef Str x1 id: 2 namedValue: 1 value: 3 succ: 5 test/rplmfparser/string1.mf:1:4
+ namedValue x1 id: 1 attr: 0x0 test/rplmfparser/string1.mf:1:4
+ const id: 3 value: 'x1 123456789 123456789 123456789 123456789 123456789' test/rplmfparser/string1.mf:1:9
+varDef Str x2 id: 5 namedValue: 4 value: 6 succ: 8 test/rplmfparser/string1.mf:3:4
+ namedValue x2 id: 4 attr: 0x0 test/rplmfparser/string1.mf:3:4
+ const id: 6 value: 'x2 123456789 123456789 123456789 123456789 123456789' test/rplmfparser/string1.mf:3:9
+varDef Str x3 id: 8 namedValue: 7 value: 9 succ: 0 test/rplmfparser/string1.mf:5:4
+ namedValue x3 id: 7 attr: 0x0 test/rplmfparser/string1.mf:5:4
+ const id: 9 value: 'x3 123456789 123456789 123456789 123456789 123456789' test/rplmfparser/string1.mf:5:9
+== Body:
+varDef Str x1 id: 2 namedValue: 1 value: 3 succ: 5 test/rplmfparser/string1.mf:1:4
+ namedValue x1 id: 1 attr: 0x0 test/rplmfparser/string1.mf:1:4
+ const id: 3 value: 'x1 123456789 123456789 123456789 123456789 123456789' test/rplmfparser/string1.mf:1:9
+varDef Str x2 id: 5 namedValue: 4 value: 6 succ: 8 test/rplmfparser/string1.mf:3:4
+ namedValue x2 id: 4 attr: 0x0 test/rplmfparser/string1.mf:3:4
+ const id: 6 value: 'x2 123456789 123456789 123456789 123456789 123456789' test/rplmfparser/string1.mf:3:9
+varDef Str x3 id: 8 namedValue: 7 value: 9 succ: 0 test/rplmfparser/string1.mf:5:4
+ namedValue x3 id: 7 attr: 0x0 test/rplmfparser/string1.mf:5:4
+ const id: 9 value: 'x3 123456789 123456789 123456789 123456789 123456789' test/rplmfparser/string1.mf:5:9
--- /dev/null
+const lazy Str s = 'Hi';
+const List l;
+Int i = 3;
+= <test> (module) parent: $global
+== Variables:
+varDef Str s id: 2 namedValue: 1 value: 3 succ: 5 <test>:1:15
+ namedValue s id: 1 attr: 0x12 <test>:1:15
+ const id: 3 value: 'Hi' <test>:1:19
+varDef List l id: 5 namedValue: 4 value: 0 succ: 7 <test>:2:11
+ namedValue l id: 4 attr: 0x2 <test>:2:11
+varDef Int i id: 7 namedValue: 6 value: 8 succ: 0 <test>:3:4
+ namedValue i id: 6 attr: 0x0 <test>:3:4
+ const id: 8 value: 3 <test>:3:8
+== Body:
+varDef Str s id: 2 namedValue: 1 value: 3 succ: 5 <test>:1:15
+ namedValue s id: 1 attr: 0x12 <test>:1:15
+ const id: 3 value: 'Hi' <test>:1:19
+varDef List l id: 5 namedValue: 4 value: 0 succ: 7 <test>:2:11
+ namedValue l id: 4 attr: 0x2 <test>:2:11
+varDef Int i id: 7 namedValue: 6 value: 8 succ: 0 <test>:3:4
+ namedValue i id: 6 attr: 0x0 <test>:3:4
+ const id: 8 value: 3 <test>:3:8
--- /dev/null
+Int a = 20;
+while 3 < 5 do
+ a = 7
+od
+= <test> (module) parent: $global
+== Variables:
+varDef Int 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
+== Body:
+varDef Int 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: < (35) 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: = (1) left: 8 right: 10 <test>:3:3
+ namedValue a id: 8 attr: 0x0 <test>:3:3
+ const id: 10 value: 7 <test>:3:5
+++ /dev/null
-2+3*4
-= <test> (module) parent: $global
-== Body:
-Expr id: 6 expr: 2 succ: 0 <test>:1:1
- BinOp id: 2 op: + (17) left: 1 right: 4 <test>:1:1
- const id: 1 value: 2 <test>:0:0
- BinOp id: 4 op: * (19) left: 3 right: 5 <test>:1:3
- const id: 3 value: 3 <test>:1:2
- const id: 5 value: 4 <test>:1:4
+++ /dev/null
-file.find('*.c')[0].name;
-[1,2,3].join(' ');
-3.14.trunc;
-= <test> (module) parent: $global
-== Body:
-Expr id: 8 expr: 7 succ: 15 <test>:1:24
- field name id: 7 parent: 5 succ: <test>:1:24
- indexedValue id: 5 index: 6 parent: 2 <test>:1:16
- const id: 6 value: 0 <test>:1:17
- call find Id: 2 args: 4 parent: 1 succ: 0 <test>:1:9
- arg 1 id: 4 expr: 3 succ: 0
- const id: 3 value: '*.c' <test>:1:10
- namedValue file id: 1 attr: 0x0 <test>:1:4
-Expr id: 15 expr: 12 succ: 18 <test>:2:12
- call join Id: 12 args: 14 parent: 9 succ: 0 <test>:2:12
- arg 1 id: 14 expr: 13 succ: 0
- const id: 13 value: ' ' <test>:2:13
- listConst id: 9 <test>:1:26
- [1,2,<formula 11>]
-Expr id: 18 expr: 17 succ: 0 <test>:3:10
- field trunc id: 17 parent: 16 succ: <test>:3:10
- const id: 16 value: 3.140000 <test>:2:19
+++ /dev/null
-Int a;
-for b from 10 to 1 step -2 do
-a += 1;
-od
-= <test> (module) parent: $global
-== Variables:
-varDef Int a id: 2 namedValue: 1 value: 0 succ: 5 <test>:1:4
- namedValue a id: 1 attr: 0x0 <test>:1:4
-varDef Int b id: 4 namedValue: 3 value: 0 succ: 0 <test>:2:4-3:0
- namedValue b id: 3 attr: 0x40 <test>:2:4
-== Body:
-varDef Int a id: 2 namedValue: 1 value: 0 succ: 5 <test>:1:4
- namedValue a id: 1 attr: 0x0 <test>:1:4
-forC id: 5 var: 3 from: 6 to: 7 step: 8 body: 13 succ: 0 <test>:1:7
- namedValue b id: 3 attr: 0x40 <test>:2:4
- const id: 6 value: 10 <test>:2:11
- const id: 7 value: 1 <test>:2:17
- Unary 8 op: - (2) expr: 9 <test>:2:24
- const id: 9 value: 2 <test>:2:25
- Expr id: 13 expr: 11 succ: 0 <test>:3:2
- BinOp id: 11 op: += (2) left: 10 right: 12 <test>:3:2
- namedValue a id: 10 attr: 0x0 <test>:3:2
- const id: 12 value: 1 <test>:3:5
+++ /dev/null
-Int a; for to 10 do a += 1 od
-= <test> (module) parent: $global
-== Variables:
-varDef Int a id: 2 namedValue: 1 value: 0 succ: 5 <test>:1:4
- namedValue a id: 1 attr: 0x0 <test>:1:4
-varDef Int $1_7 id: 4 namedValue: 3 value: 0 succ: 0 <test>:1:7-1:0
- namedValue $1_7 id: 3 attr: 0x40 <test>:1:7
-== Body:
-varDef Int a id: 2 namedValue: 1 value: 0 succ: 5 <test>:1:4
- namedValue a id: 1 attr: 0x0 <test>:1:4
-forC id: 5 var: 3 from: 0 to: 6 step: 0 body: 10 succ: 0 <test>:1:7
- namedValue $1_7 id: 3 attr: 0x40 <test>:1:7
- const id: 6 value: 10 <test>:1:14
- Expr id: 10 expr: 8 succ: 0 <test>:1:22
- BinOp id: 8 op: += (2) left: 7 right: 9 <test>:1:22
- namedValue a id: 7 attr: 0x0 <test>:1:22
- const id: 9 value: 1 <test>:1:25
+++ /dev/null
-Map a;
-for x in a do
-a += 1;
-od
-= <test> (module) parent: $global
-== Variables:
-varDef Map a id: 2 namedValue: 1 value: 0 succ: 5 <test>:1:4
- namedValue a id: 1 attr: 0x0 <test>:1:4
-varDef Int x id: 4 namedValue: 3 value: 0 succ: 0 <test>:2:4-3:0
- namedValue x id: 3 attr: 0x40 <test>:2:4
-== Body:
-varDef Map a id: 2 namedValue: 1 value: 0 succ: 5 <test>:1:4
- namedValue a id: 1 attr: 0x0 <test>:1:4
-forIt id: 5 var: 3 set: 6 body: 10 succ: 0 <test>:1:7
- namedValue x id: 3 attr: 0x40 <test>:2:4
- namedValue a id: 6 attr: 0x0 <test>:2:11
- Expr id: 10 expr: 8 succ: 0 <test>:3:2
- BinOp id: 8 op: += (2) left: 7 right: 9 <test>:3:2
- namedValue a id: 7 attr: 0x0 <test>:3:2
- const id: 9 value: 1 <test>:3:5
+++ /dev/null
-Int a;
-Int b;
-a = b = 2;
-if 11 < 12
-then a = 13 * 14
-else a = 15 / 16
-fi
-= <test> (module) parent: $global
-== Variables:
-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
-== Body:
-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: = (1) left: 5 right: 8 <test>:3:2
- namedValue a id: 5 attr: 0x0 <test>:3:2
- BinOp id: 8 op: = (1) 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: < (35) 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: = (1) left: 15 right: 18 <test>:5:7
- namedValue a id: 15 attr: 0x0 <test>:5:7
- BinOp id: 18 op: * (19) 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: = (1) left: 21 right: 24 <test>:6:7
- namedValue a id: 21 attr: 0x0 <test>:6:7
- BinOp id: 24 op: / (20) left: 23 right: 25 <test>:6:12
- const id: 23 value: 15 <test>:6:9
- const id: 25 value: 16 <test>:6:14
+++ /dev/null
-Str x;
-if 7 < 6
-then x = '123';
-fi
-= <test> (module) parent: $global
-== Variables:
-varDef x id: 2 namedValue: 1 value: 0 succ: 3 <test>:1:4
- namedValue x id: 1 attr: 0x0 <test>:1:4
-== Body:
-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: < (35) 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: = (1) left: 7 right: 9 <test>:3:7
- namedValue x id: 7 attr: 0x0 <test>:3:7
- const id: 9 value: '123' <test>:3:9
+++ /dev/null
-List b = [];
-= <test> (module) parent: $global
-== Variables:
-varDef List 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
- []
-== Body:
-varDef List 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
- []
+++ /dev/null
-List a = [2+3, 3.14, 7, 'hi', a]; List b = [];
-= <test> (module) parent: $global
-== Variables:
-varDef List 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 List 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
- []
-== Body:
-varDef List 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 List 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
- []
+++ /dev/null
-Map a = {};
-= <test> (module) parent: $global
-== Variables:
-varDef Map 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
- {}
-== Body:
-varDef Map 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
- {}
+++ /dev/null
-Map a = {'a': 2+3,'bcd':3.14,'ccc':7, 'hi':'world'};
-Map b = {};
-= <test> (module) parent: $global
-== Variables:
-varDef Map 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 Map 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
- {}
-== Body:
-varDef Map 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 Map 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
- {}
+++ /dev/null
-func Float pi: 3.1415; endf func Str delim(): '/' endf;
-= <test> (module) parent: $global
-== Methods:
-Method <NoneType> delim() id: 4 parent: <test> args: 0 body: 6 <test>:1:28
- Expr id: 6 expr: 5 succ: 0 <test>:1:46
- const id: 5 value: '/' <test>:1:46
- = <test>.delim (method) parent: <test>
-Method <NoneType> pi() id: 1 parent: <test> args: 0 body: 3 <test>:0:0
- Expr id: 3 expr: 2 succ: 0 <test>:1:15
- const id: 2 value: 3.141500 <test>:1:15
- = <test>.pi (method) parent: <test>
+++ /dev/null
-func Int fac(const Int n):
-Int rc; if rc <= 1 then rc = 1 else rc = n*fac(n-1) fi
-rc endf
-= <test> (module) parent: $global
-== Methods:
-Method <NoneType> fac() id: 1 parent: <test> args: 4 body: 6 <test>:0:55
- Expr id: 4 expr: 3 succ: 0
- varDef Int n id: 3 namedValue: 2 value: 0 succ: 0 <test>:1:23
- namedValue n id: 2 attr: 0x22 <test>:1:23
- varDef Int rc id: 6 namedValue: 5 value: 0 succ: 7 <test>:2:4
- namedValue rc id: 5 attr: 0x0 <test>:2:4
- If id: 7 condition: 9 then: 14 else: 24 succ: 26<test>:2:8
- BinOp id: 9 op: <= (34) left: 8 right: 10 <test>:2:14
- namedValue rc id: 8 attr: 0x0 <test>:2:14
- const id: 10 value: 1 <test>:2:17
- Expr id: 14 expr: 12 succ: 0 <test>:2:27
- BinOp id: 12 op: = (1) left: 11 right: 13 <test>:2:27
- namedValue rc id: 11 attr: 0x0 <test>:2:27
- const id: 13 value: 1 <test>:2:29
- Expr id: 24 expr: 16 succ: 0 <test>:2:39
- BinOp id: 16 op: = (1) left: 15 right: 18 <test>:2:39
- namedValue rc id: 15 attr: 0x0 <test>:2:39
- BinOp id: 18 op: * (19) left: 17 right: 19 <test>:2:42
- namedValue n id: 17 attr: 0x0 <test>:2:42
- call fac Id: 19 args: 23 parent: 0 succ: 0 <test>:2:46
- arg 1 id: 23 expr: 21 succ: 0
- BinOp id: 21 op: - (18) left: 20 right: 22 <test>:2:48
- namedValue n id: 20 attr: 0x0 <test>:2:48
- const id: 22 value: 1 <test>:2:49
- Expr id: 26 expr: 25 succ: 0 <test>:3:3
- namedValue rc id: 25 attr: 0x0 <test>:3:3
- = <test>.fac (method) parent: <test>
- == Variables:
- varDef Int n id: 3 namedValue: 2 value: 0 succ: 0 <test>:1:23
- namedValue n id: 2 attr: 0x22 <test>:1:23
- varDef Int rc id: 6 namedValue: 5 value: 0 succ: 7 <test>:2:4
- namedValue rc id: 5 attr: 0x0 <test>:2:4
+++ /dev/null
-func Int max(Int a, Int b):
- Int rc = a;
-if a < b then rc = b; fi
-rc
-endf
-func Int max(const Int a, Int b, Int c):
-max(a, max(b, c))
-endf
-= <test> (module) parent: $global
-== Methods:
-Method <NoneType> max() id: 21 parent: <test> args: 24 body: 40 <test>:5:5
- Expr id: 24 expr: 23 succ: 27
- varDef Int a id: 23 namedValue: 22 value: 0 succ: 0 <test>:6:23
- namedValue a id: 22 attr: 0x22 <test>:6:23
- Expr id: 40 expr: 31 succ: 0 <test>:7:3
- call max Id: 31 args: 33 parent: 0 succ: 0 <test>:7:3
- arg 1 id: 33 expr: 32 succ: 39
- namedValue a id: 32 attr: 0x0 <test>:7:5
- arg 2 id: 39 expr: 34 succ: 0
- call max Id: 34 args: 36 parent: 0 succ: 0 <test>:7:10
- arg 1 id: 36 expr: 35 succ: 38
- namedValue b id: 35 attr: 0x0 <test>:7:12
- arg 2 id: 38 expr: 37 succ: 0
- namedValue c id: 37 attr: 0x0 <test>:7:15
- = <test>.max (method) parent: <test>
- == Variables:
- varDef Int a id: 23 namedValue: 22 value: 0 succ: 0 <test>:6:23
- namedValue a id: 22 attr: 0x22 <test>:6:23
- varDef Int b id: 26 namedValue: 25 value: 0 succ: 0 <test>:6:30
- namedValue b id: 25 attr: 0x20 <test>:6:30
- varDef Int c id: 29 namedValue: 28 value: 0 succ: 0 <test>:6:37
- namedValue c id: 28 attr: 0x20 <test>:6:37
+++ /dev/null
-func Int max(const Int a, Int b, Int c):
-func Int max(Int a, Int b):
- Int rc = a;
-if a < b then rc = b; fi
-rc
-endf
-max(a, max(b, c))
-endf
-= <test> (module) parent: $global
-== Methods:
-Method <NoneType> max() id: 1 parent: <test> args: 4 body: 40 <test>:0:4
- Expr id: 4 expr: 3 succ: 7
- varDef Int a id: 3 namedValue: 2 value: 0 succ: 0 <test>:1:23
- namedValue a id: 2 attr: 0x22 <test>:1:23
- Expr id: 40 expr: 31 succ: 0 <test>:7:3
- call max Id: 31 args: 33 parent: 0 succ: 0 <test>:7:3
- arg 1 id: 33 expr: 32 succ: 39
- namedValue a id: 32 attr: 0x0 <test>:7:5
- arg 2 id: 39 expr: 34 succ: 0
- call max Id: 34 args: 36 parent: 0 succ: 0 <test>:7:10
- arg 1 id: 36 expr: 35 succ: 38
- namedValue b id: 35 attr: 0x0 <test>:7:12
- arg 2 id: 38 expr: 37 succ: 0
- namedValue c id: 37 attr: 0x0 <test>:7:15
- = <test>.max (method) parent: <test>
- == Methods:
- Method <NoneType> max() id: 11 parent: <test>.max args: 14 body: 19 <test>:1:41
- Expr id: 14 expr: 13 succ: 17
- varDef Int a id: 13 namedValue: 12 value: 0 succ: 0 <test>:2:17
- namedValue a id: 12 attr: 0x20 <test>:2:17
- varDef Int rc id: 19 namedValue: 18 value: 20 succ: 21 <test>:3:5
- namedValue rc id: 18 attr: 0x0 <test>:3:5
- namedValue a id: 20 attr: 0x0 <test>:3:11
- If id: 21 condition: 23 then: 28 else: 0 succ: 30<test>:3:13
- BinOp id: 23 op: < (35) left: 22 right: 24 <test>:4:5
- namedValue a id: 22 attr: 0x0 <test>:4:5
- namedValue b id: 24 attr: 0x0 <test>:4:9
- Expr id: 28 expr: 26 succ: 0 <test>:4:17
- BinOp id: 26 op: = (1) left: 25 right: 27 <test>:4:17
- namedValue rc id: 25 attr: 0x0 <test>:4:17
- namedValue b id: 27 attr: 0x0 <test>:4:20
- Expr id: 30 expr: 29 succ: 0 <test>:5:3
- namedValue rc id: 29 attr: 0x0 <test>:5:3
- = <test>.max.max (method) parent: <test>.max
- == Variables:
- varDef Int a id: 13 namedValue: 12 value: 0 succ: 0 <test>:2:17
- namedValue a id: 12 attr: 0x20 <test>:2:17
- varDef Int b id: 16 namedValue: 15 value: 0 succ: 0 <test>:2:24
- namedValue b id: 15 attr: 0x20 <test>:2:24
- varDef Int rc id: 19 namedValue: 18 value: 20 succ: 21 <test>:3:5
- namedValue rc id: 18 attr: 0x0 <test>:3:5
- namedValue a id: 20 attr: 0x0 <test>:3:11
- == Variables:
- varDef Int a id: 3 namedValue: 2 value: 0 succ: 0 <test>:1:23
- namedValue a id: 2 attr: 0x22 <test>:1:23
- varDef Int b id: 6 namedValue: 5 value: 0 succ: 0 <test>:1:30
- namedValue b id: 5 attr: 0x20 <test>:1:30
- varDef Int c id: 9 namedValue: 8 value: 0 succ: 0 <test>:1:37
- namedValue c id: 8 attr: 0x20 <test>:1:37
+++ /dev/null
-rand();
-sin(a);
-max(1+2*3,4**(5-4));
-= <test> (module) parent: $global
-== Body:
-Expr id: 2 expr: 1 succ: 6 <test>:1:4
- call rand Id: 1 args: 0 parent: 0 succ: 0 <test>:1:4
-Expr id: 6 expr: 3 succ: 20 <test>:2:3
- call sin Id: 3 args: 5 parent: 0 succ: 0 <test>:2:3
- arg 1 id: 5 expr: 4 succ: 0
- namedValue a id: 4 attr: 0x0 <test>:2:5
-Expr id: 20 expr: 7 succ: 0 <test>:3:3
- call max Id: 7 args: 13 parent: 0 succ: 0 <test>:3:3
- arg 1 id: 13 expr: 9 succ: 19
- BinOp id: 9 op: + (17) left: 8 right: 11 <test>:3:5
- const id: 8 value: 1 <test>:3:4
- BinOp id: 11 op: * (19) left: 10 right: 12 <test>:3:7
- const id: 10 value: 2 <test>:3:6
- const id: 12 value: 3 <test>:3:8
- arg 2 id: 19 expr: 15 succ: 0
- BinOp id: 15 op: ** (22) left: 14 right: 17 <test>:3:11
- const id: 14 value: 4 <test>:3:10
- BinOp id: 17 op: - (18) left: 16 right: 18 <test>:3:15
- const id: 16 value: 5 <test>:3:14
- const id: 18 value: 4 <test>:3:16
+++ /dev/null
-Int a = 1;
-Int b = 100;
---a;
-b++;
-a--*++b**(8-3);
-a=b=(a+(b-2)*3)
-= <test> (module) parent: $global
-== Variables:
-varDef Int 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 Int 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
-== Body:
-varDef Int 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 Int 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: -- (6) expr: 8 <test>:2:13
- namedValue a id: 8 attr: 0x0 <test>:3:3
-Expr id: 12 expr: 11 succ: 22
- Unary 11 op: ++ (5) 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: * (19) left: 14 right: 18 <test>:5:3
- Unary 14 op: -- (6) expr: 13
- namedValue a id: 13 attr: 0x0 <test>:5:1
- BinOp id: 18 op: ** (22) left: 16 right: 20 <test>:5:7
- Unary 16 op: ++ (5) expr: 17 <test>:5:4
- namedValue b id: 17 attr: 0x0 <test>:5:7
- BinOp id: 20 op: - (18) 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: = (1) left: 23 right: 26 <test>:6:1
- namedValue a id: 23 attr: 0x0 <test>:6:1
- BinOp id: 26 op: = (1) left: 25 right: 28 <test>:6:3
- namedValue b id: 25 attr: 0x0 <test>:6:3
- BinOp id: 28 op: + (17) left: 27 right: 32 <test>:6:6
- namedValue a id: 27 attr: 0x0 <test>:6:6
- BinOp id: 32 op: * (19) left: 30 right: 33 <test>:6:12
- BinOp id: 30 op: - (18) 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
+++ /dev/null
-Int a;
-repeat
-a++;
-until a != 2 * 3;
-= <test> (module) parent: $global
-== Variables:
-varDef Int a id: 2 namedValue: 1 value: 0 succ: 3 <test>:1:4
- namedValue a id: 1 attr: 0x0 <test>:1:4
-== Body:
-varDef Int 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: != (33) left: 7 right: 10 <test>:4:8
- namedValue a id: 7 attr: 0x0 <test>:4:8
- BinOp id: 10 op: * (19) 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: ++ (5) expr: 4
- namedValue a id: 4 attr: 0x0 <test>:3:1
+++ /dev/null
-Str x1 = "x1 123456789 123456789 123456789 123456789 123456789";
-Str x2 = "x2 123456789 123456789 123456789 123456789 123456789";
-Str x3 = "x3 123456789 123456789 123456789 123456789 123456789";
+++ /dev/null
-Str x1 = "x1 123456789 123456789 123456789 123456789 123456789";
-Str x2 = "x2 123456789 123456789 123456789 123456789 123456789";
-Str x3 = "x3 123456789 123456789 123456789 123456789 123456789";
-= test/rplmfparser/string1.mf (module) parent: $global
-== Variables:
-varDef Str x1 id: 2 namedValue: 1 value: 3 succ: 5 test/rplmfparser/string1.mf:1:4
- namedValue x1 id: 1 attr: 0x0 test/rplmfparser/string1.mf:1:4
- const id: 3 value: 'x1 123456789 123456789 123456789 123456789 123456789' test/rplmfparser/string1.mf:1:9
-varDef Str x2 id: 5 namedValue: 4 value: 6 succ: 8 test/rplmfparser/string1.mf:3:4
- namedValue x2 id: 4 attr: 0x0 test/rplmfparser/string1.mf:3:4
- const id: 6 value: 'x2 123456789 123456789 123456789 123456789 123456789' test/rplmfparser/string1.mf:3:9
-varDef Str x3 id: 8 namedValue: 7 value: 9 succ: 0 test/rplmfparser/string1.mf:5:4
- namedValue x3 id: 7 attr: 0x0 test/rplmfparser/string1.mf:5:4
- const id: 9 value: 'x3 123456789 123456789 123456789 123456789 123456789' test/rplmfparser/string1.mf:5:9
-== Body:
-varDef Str x1 id: 2 namedValue: 1 value: 3 succ: 5 test/rplmfparser/string1.mf:1:4
- namedValue x1 id: 1 attr: 0x0 test/rplmfparser/string1.mf:1:4
- const id: 3 value: 'x1 123456789 123456789 123456789 123456789 123456789' test/rplmfparser/string1.mf:1:9
-varDef Str x2 id: 5 namedValue: 4 value: 6 succ: 8 test/rplmfparser/string1.mf:3:4
- namedValue x2 id: 4 attr: 0x0 test/rplmfparser/string1.mf:3:4
- const id: 6 value: 'x2 123456789 123456789 123456789 123456789 123456789' test/rplmfparser/string1.mf:3:9
-varDef Str x3 id: 8 namedValue: 7 value: 9 succ: 0 test/rplmfparser/string1.mf:5:4
- namedValue x3 id: 7 attr: 0x0 test/rplmfparser/string1.mf:5:4
- const id: 9 value: 'x3 123456789 123456789 123456789 123456789 123456789' test/rplmfparser/string1.mf:5:9
+++ /dev/null
-const lazy Str s = 'Hi';
-const List l;
-Int i = 3;
-= <test> (module) parent: $global
-== Variables:
-varDef Str s id: 2 namedValue: 1 value: 3 succ: 5 <test>:1:15
- namedValue s id: 1 attr: 0x12 <test>:1:15
- const id: 3 value: 'Hi' <test>:1:19
-varDef List l id: 5 namedValue: 4 value: 0 succ: 7 <test>:2:11
- namedValue l id: 4 attr: 0x2 <test>:2:11
-varDef Int i id: 7 namedValue: 6 value: 8 succ: 0 <test>:3:4
- namedValue i id: 6 attr: 0x0 <test>:3:4
- const id: 8 value: 3 <test>:3:8
-== Body:
-varDef Str s id: 2 namedValue: 1 value: 3 succ: 5 <test>:1:15
- namedValue s id: 1 attr: 0x12 <test>:1:15
- const id: 3 value: 'Hi' <test>:1:19
-varDef List l id: 5 namedValue: 4 value: 0 succ: 7 <test>:2:11
- namedValue l id: 4 attr: 0x2 <test>:2:11
-varDef Int i id: 7 namedValue: 6 value: 8 succ: 0 <test>:3:4
- namedValue i id: 6 attr: 0x0 <test>:3:4
- const id: 8 value: 3 <test>:3:8
+++ /dev/null
-Int a = 20;
-while 3 < 5 do
- a = 7
-od
-= <test> (module) parent: $global
-== Variables:
-varDef Int 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
-== Body:
-varDef Int 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: < (35) 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: = (1) left: 8 right: 10 <test>:3:3
- namedValue a id: 8 attr: 0x0 <test>:3:3
- const id: 10 value: 7 <test>:3:5
void checkAST(const char* fileExpected, int lineNo){
QByteArray fnExpected = "test";
fnExpected += QDir::separator().toLatin1();
- fnExpected += "rplmfparser";
+ fnExpected += "mfparser";
fnExpected += (char) QDir::separator().toLatin1();
fnExpected += fileExpected;
QByteArray fnCurrent = getTempFile(fileExpected, "rplmfparser");
parser.parse();
checkAST("meth4.txt", __LINE__);
}
+ void mainTest(){
+ setSource("Int a=2+3*4;\nfunc Void main():\na;\nendf");
+ RplMFParser parser(m_source, m_tree);
+ parser.parse();
+ checkAST("main1.txt", __LINE__);
+ }
virtual void doIt(void) {
- fileClassTest();
+ mainTest();
varDefTest();
repeatTest();
baseTest();
forCTest();
listTest();
opTest();
+ fileClassTest();
}
};
void testRplMFParser() {
vm.setFlag(RplVirtualMachine::VF_TRACE_STATEMENTS);
RplFileWriter writer(fnCurrent);
vm.setTraceWriter(&writer);
+ writer.write(m_currentSource);
vm.executeModule("<test>");
assertEqualFiles(fnExpected.constData(), fnCurrent.constData(),
__FILE__, lineNo);