summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Sencha-lang/main.cpp')
-rw-r--r--Sencha-lang/main.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/Sencha-lang/main.cpp b/Sencha-lang/main.cpp
index 07fd038..d2e9848 100644
--- a/Sencha-lang/main.cpp
+++ b/Sencha-lang/main.cpp
@@ -118,6 +118,16 @@ SenchaObject s_tan(vector<ASTExpression *> arguments)
return result;
}
+SenchaObject len(vector<ASTExpression *> arguments)
+{
+ SenchaObject result;
+ SenchaObject argument = arguments[0]->evaluate();
+ if(argument.type == SenchaObject::string_literal)
+ {
+ result = SenchaObject(int(argument.text.size()));
+ }
+ return result;
+}
int how_depth_change(vector<Token> tokens)
@@ -151,6 +161,7 @@ void interactive()
context.register_function("cos", s_cos);
context.register_function("tan", s_tan);
context.register_function("sleep", sleep);
+ context.register_function("len", len);
Parser parser(&context);
ASTInspector inspector;
@@ -205,6 +216,7 @@ int main(int argc, char *argv[])
context.register_function("cos", s_cos);
context.register_function("tan", s_tan);
context.register_function("sleep", sleep);
+ context.register_function("len", len);
Parser parser(&context);