summaryrefslogtreecommitdiff
path: root/tests/lexers/moocode
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lexers/moocode')
-rw-r--r--tests/lexers/moocode/example.txt663
-rw-r--r--tests/lexers/moocode/example2.txt255
2 files changed, 918 insertions, 0 deletions
diff --git a/tests/lexers/moocode/example.txt b/tests/lexers/moocode/example.txt
new file mode 100644
index 00000000..3bc56d61
--- /dev/null
+++ b/tests/lexers/moocode/example.txt
@@ -0,0 +1,663 @@
+---input---
+you_lose_msg = "Either that person does not exist, or has a different password.";
+if (!(caller in {#0, this}))
+ return E_PERM;
+ "...caller isn't :do_login_command...";
+elseif (args && (args[1] == "test"))
+ return this:test(@listdelete(args, 1));
+elseif (!(length(args) in {1, 2}))
+ notify(player, tostr("Usage: ", verb, " <existing-player-name> <password>"));
+elseif (!valid(candidate = this:_match_player(name = strsub(args[1], " ", "_"))))
+ if (name == "guest")
+ "must be no guests";
+ this:notify_lines(this:registration_text("guest"));
+ else
+ notify(player, you_lose_msg);
+ endif
+ "...unknown player...";
+elseif (is_clear_property(candidate, "password") || ((typeof(candidate.password) == STR) && ((length(candidate.password) < 2) || (crypt({@args, ""}[2], candidate.password) != candidate.password))))
+ notify(player, you_lose_msg);
+ "...bad password...";
+ server_log(tostr("FAILED CONNECT: ", args[1], " (", candidate, ") on ", connection_name(player), ($string_utils:connection_hostname(connection_name(player)) in candidate.all_connect_places) ? "" | "******"));
+elseif (((candidate.name == "guest") && this.sitematch_guests) && valid(foreigner = $country_db:get_guest()))
+ notify(player, tostr("Okay,... Logging you in as `", foreigner:name(), "'"));
+ this:record_connection(foreigner);
+ return foreigner;
+elseif ((parent(candidate) == $guest) && (!valid(candidate = candidate:defer())))
+ if (candidate == #-3)
+ notify(player, "Sorry, guest characters are not allowed from your site right now.");
+ elseif (candidate == #-2)
+ this:notify_lines(this:registration_text("blacklisted", "Sorry, guest characters are not allowed from your site."));
+ elseif (candidate == #-4)
+ this:notify_lines(this:registration_text("guest"));
+ else
+ notify(player, "Sorry, all of our guest characters are in use right now.");
+ endif
+else
+ if ((!(name in candidate.aliases)) && (name != tostr(candidate)))
+ notify(player, tostr("Okay,... ", name, " is in use. Logging you in as `", candidate:name(), "'"));
+ endif
+ if (this:is_newted(candidate))
+ notify(player, "");
+ notify(player, this:newt_message_for(candidate));
+ notify(player, "");
+ else
+ this:record_connection(candidate);
+ if (verb[1] == "s")
+ candidate.use_do_command = 0;
+ endif
+ return candidate;
+ endif
+endif
+return 0;
+
+---tokens---
+'you_lose_msg' Text
+' ' Text
+'=' Operator
+' ' Text
+'"Either that person does not exist, or has a different password."' Literal.String
+';' Operator
+'\n' Text
+
+'if' Keyword
+' ' Text
+'(!(' Operator
+'caller' Name.Variable.Instance
+' ' Text
+'in' Keyword
+' ' Text
+'{' Operator
+'#0' Name.Entity
+',' Operator
+' ' Text
+'this' Name.Variable.Instance
+'}))' Operator
+'\n ' Text
+'return' Keyword
+' ' Text
+'E_PERM' Name.Exception
+';' Operator
+'\n ' Text
+'"...caller isn\'t :do_login_command..."' Literal.String
+';' Operator
+'\n' Text
+
+'elseif' Keyword
+' ' Text
+'(' Operator
+'args' Name.Variable.Instance
+' ' Text
+'&&' Operator
+' ' Text
+'(' Operator
+'args' Name.Variable.Instance
+'[' Operator
+'1' Literal.Number.Integer
+']' Operator
+' ' Text
+'==' Operator
+' ' Text
+'"test"' Literal.String
+'))' Operator
+'\n ' Text
+'return' Keyword
+' ' Text
+'this' Name.Variable.Instance
+':' Operator
+'test' Name.Function
+'(' Operator
+'@' Operator
+'listdelete' Name.Function
+'(' Operator
+'args' Name.Variable.Instance
+',' Operator
+' ' Text
+'1' Literal.Number.Integer
+'));' Operator
+'\n' Text
+
+'elseif' Keyword
+' ' Text
+'(!(' Operator
+'length' Name.Builtin
+'(' Operator
+'args' Name.Variable.Instance
+')' Operator
+' ' Text
+'in' Keyword
+' ' Text
+'{' Operator
+'1' Literal.Number.Integer
+',' Operator
+' ' Text
+'2' Literal.Number.Integer
+'}))' Operator
+'\n ' Text
+'notify' Name.Function
+'(' Operator
+'player' Name.Variable.Instance
+',' Operator
+' ' Text
+'tostr' Name.Function
+'(' Operator
+'"Usage: "' Literal.String
+',' Operator
+' ' Text
+'verb' Text
+',' Operator
+' ' Text
+'" <existing-player-name> <password>"' Literal.String
+'));' Operator
+'\n' Text
+
+'elseif' Keyword
+' ' Text
+'(!' Operator
+'valid' Name.Function
+'(' Operator
+'candidate' Text
+' ' Text
+'=' Operator
+' ' Text
+'this' Name.Variable.Instance
+':' Operator
+'_match_player' Name.Function
+'(' Operator
+'name' Text
+' ' Text
+'=' Operator
+' ' Text
+'strsub' Name.Function
+'(' Operator
+'args' Name.Variable.Instance
+'[' Operator
+'1' Literal.Number.Integer
+'],' Operator
+' ' Text
+'" "' Literal.String
+',' Operator
+' ' Text
+'"_"' Literal.String
+'))))' Operator
+'\n ' Text
+'if' Keyword
+' ' Text
+'(' Operator
+'name' Text
+' ' Text
+'==' Operator
+' ' Text
+'"guest"' Literal.String
+')' Operator
+'\n ' Text
+'"must be no guests"' Literal.String
+';' Operator
+'\n ' Text
+'this' Name.Variable.Instance
+':' Operator
+'notify_lines' Name.Function
+'(' Operator
+'this' Name.Variable.Instance
+':' Operator
+'registration_text' Name.Function
+'(' Operator
+'"guest"' Literal.String
+'));' Operator
+'\n ' Text
+'else' Keyword
+'\n ' Text
+'notify' Name.Function
+'(' Operator
+'player' Name.Variable.Instance
+',' Operator
+' ' Text
+'you_lose_msg' Text
+');' Operator
+'\n ' Text
+'endif' Keyword
+'\n ' Text
+'"...unknown player..."' Literal.String
+';' Operator
+'\n' Text
+
+'elseif' Keyword
+' ' Text
+'(' Operator
+'is_clear_property' Name.Function
+'(' Operator
+'candidate' Text
+',' Operator
+' ' Text
+'"password"' Literal.String
+')' Operator
+' ' Text
+'||' Operator
+' ' Text
+'((' Operator
+'typeof' Name.Function
+'(' Operator
+'candidate' Text
+'.' Operator
+'password' Text
+')' Operator
+' ' Text
+'==' Operator
+' ' Text
+'STR' Text
+')' Operator
+' ' Text
+'&&' Operator
+' ' Text
+'((' Operator
+'length' Name.Builtin
+'(' Operator
+'candidate' Text
+'.' Operator
+'password' Text
+')' Operator
+' ' Text
+'<' Operator
+' ' Text
+'2' Literal.Number.Integer
+')' Operator
+' ' Text
+'||' Operator
+' ' Text
+'(' Operator
+'crypt' Name.Function
+'(' Operator
+'{@' Operator
+'args' Name.Variable.Instance
+',' Operator
+' ' Text
+'""' Literal.String
+'}[' Operator
+'2' Literal.Number.Integer
+'],' Operator
+' ' Text
+'candidate' Text
+'.' Operator
+'password' Text
+')' Operator
+' ' Text
+'!=' Operator
+' ' Text
+'candidate' Text
+'.' Operator
+'password' Text
+'))))' Operator
+'\n ' Text
+'notify' Name.Function
+'(' Operator
+'player' Name.Variable.Instance
+',' Operator
+' ' Text
+'you_lose_msg' Text
+');' Operator
+'\n ' Text
+'"...bad password..."' Literal.String
+';' Operator
+'\n ' Text
+'server_log' Name.Function
+'(' Operator
+'tostr' Name.Function
+'(' Operator
+'"FAILED CONNECT: "' Literal.String
+',' Operator
+' ' Text
+'args' Name.Variable.Instance
+'[' Operator
+'1' Literal.Number.Integer
+'],' Operator
+' ' Text
+'" ("' Literal.String
+',' Operator
+' ' Text
+'candidate' Text
+',' Operator
+' ' Text
+'") on "' Literal.String
+',' Operator
+' ' Text
+'connection_name' Name.Function
+'(' Operator
+'player' Name.Variable.Instance
+'),' Operator
+' ' Text
+'(' Operator
+'$string_utils' Name.Entity
+':' Operator
+'connection_hostname' Name.Function
+'(' Operator
+'connection_name' Name.Function
+'(' Operator
+'player' Name.Variable.Instance
+'))' Operator
+' ' Text
+'in' Keyword
+' ' Text
+'candidate' Text
+'.' Operator
+'all_connect_places' Text
+')' Operator
+' ' Text
+'?' Operator
+' ' Text
+'""' Literal.String
+' ' Text
+'|' Operator
+' ' Text
+'"******"' Literal.String
+'));' Operator
+'\n' Text
+
+'elseif' Keyword
+' ' Text
+'(((' Operator
+'candidate' Text
+'.' Operator
+'name' Text
+' ' Text
+'==' Operator
+' ' Text
+'"guest"' Literal.String
+')' Operator
+' ' Text
+'&&' Operator
+' ' Text
+'this' Name.Variable.Instance
+'.' Operator
+'sitematch_guests' Text
+')' Operator
+' ' Text
+'&&' Operator
+' ' Text
+'valid' Name.Function
+'(' Operator
+'foreigner' Text
+' ' Text
+'=' Operator
+' ' Text
+'$country_db' Name.Entity
+':' Operator
+'get_guest' Name.Function
+'(' Operator
+')))' Operator
+'\n ' Text
+'notify' Name.Function
+'(' Operator
+'player' Name.Variable.Instance
+',' Operator
+' ' Text
+'tostr' Name.Function
+'(' Operator
+'"Okay,... Logging you in as `"' Literal.String
+',' Operator
+' ' Text
+'foreigner' Text
+':' Operator
+'name' Name.Function
+'(' Operator
+'),' Operator
+' ' Text
+'"\'"' Literal.String
+'));' Operator
+'\n ' Text
+'this' Name.Variable.Instance
+':' Operator
+'record_connection' Name.Function
+'(' Operator
+'foreigner' Text
+');' Operator
+'\n ' Text
+'return' Keyword
+' ' Text
+'foreigner' Text
+';' Operator
+'\n' Text
+
+'elseif' Keyword
+' ' Text
+'((' Operator
+'parent' Name.Function
+'(' Operator
+'candidate' Text
+')' Operator
+' ' Text
+'==' Operator
+' ' Text
+'$guest' Name.Entity
+')' Operator
+' ' Text
+'&&' Operator
+' ' Text
+'(!' Operator
+'valid' Name.Function
+'(' Operator
+'candidate' Text
+' ' Text
+'=' Operator
+' ' Text
+'candidate' Text
+':' Operator
+'defer' Name.Function
+'(' Operator
+'))))' Operator
+'\n ' Text
+'if' Keyword
+' ' Text
+'(' Operator
+'candidate' Text
+' ' Text
+'==' Operator
+' ' Text
+'#-3' Name.Entity
+')' Operator
+'\n ' Text
+'notify' Name.Function
+'(' Operator
+'player' Name.Variable.Instance
+',' Operator
+' ' Text
+'"Sorry, guest characters are not allowed from your site right now."' Literal.String
+');' Operator
+'\n ' Text
+'elseif' Keyword
+' ' Text
+'(' Operator
+'candidate' Text
+' ' Text
+'==' Operator
+' ' Text
+'#-2' Name.Entity
+')' Operator
+'\n ' Text
+'this' Name.Variable.Instance
+':' Operator
+'notify_lines' Name.Function
+'(' Operator
+'this' Name.Variable.Instance
+':' Operator
+'registration_text' Name.Function
+'(' Operator
+'"blacklisted"' Literal.String
+',' Operator
+' ' Text
+'"Sorry, guest characters are not allowed from your site."' Literal.String
+'));' Operator
+'\n ' Text
+'elseif' Keyword
+' ' Text
+'(' Operator
+'candidate' Text
+' ' Text
+'==' Operator
+' ' Text
+'#-4' Name.Entity
+')' Operator
+'\n ' Text
+'this' Name.Variable.Instance
+':' Operator
+'notify_lines' Name.Function
+'(' Operator
+'this' Name.Variable.Instance
+':' Operator
+'registration_text' Name.Function
+'(' Operator
+'"guest"' Literal.String
+'));' Operator
+'\n ' Text
+'else' Keyword
+'\n ' Text
+'notify' Name.Function
+'(' Operator
+'player' Name.Variable.Instance
+',' Operator
+' ' Text
+'"Sorry, all of our guest characters are in use right now."' Literal.String
+');' Operator
+'\n ' Text
+'endif' Keyword
+'\n' Text
+
+'else' Keyword
+'\n ' Text
+'if' Keyword
+' ' Text
+'((!(' Operator
+'name' Text
+' ' Text
+'in' Keyword
+' ' Text
+'candidate' Text
+'.' Operator
+'aliases' Text
+'))' Operator
+' ' Text
+'&&' Operator
+' ' Text
+'(' Operator
+'name' Text
+' ' Text
+'!=' Operator
+' ' Text
+'tostr' Name.Function
+'(' Operator
+'candidate' Text
+')))' Operator
+'\n ' Text
+'notify' Name.Function
+'(' Operator
+'player' Name.Variable.Instance
+',' Operator
+' ' Text
+'tostr' Name.Function
+'(' Operator
+'"Okay,... "' Literal.String
+',' Operator
+' ' Text
+'name' Text
+',' Operator
+' ' Text
+'" is in use. Logging you in as `"' Literal.String
+',' Operator
+' ' Text
+'candidate' Text
+':' Operator
+'name' Name.Function
+'(' Operator
+'),' Operator
+' ' Text
+'"\'"' Literal.String
+'));' Operator
+'\n ' Text
+'endif' Keyword
+'\n ' Text
+'if' Keyword
+' ' Text
+'(' Operator
+'this' Name.Variable.Instance
+':' Operator
+'is_newted' Name.Function
+'(' Operator
+'candidate' Text
+'))' Operator
+'\n ' Text
+'notify' Name.Function
+'(' Operator
+'player' Name.Variable.Instance
+',' Operator
+' ' Text
+'""' Literal.String
+');' Operator
+'\n ' Text
+'notify' Name.Function
+'(' Operator
+'player' Name.Variable.Instance
+',' Operator
+' ' Text
+'this' Name.Variable.Instance
+':' Operator
+'newt_message_for' Name.Function
+'(' Operator
+'candidate' Text
+'));' Operator
+'\n ' Text
+'notify' Name.Function
+'(' Operator
+'player' Name.Variable.Instance
+',' Operator
+' ' Text
+'""' Literal.String
+');' Operator
+'\n ' Text
+'else' Keyword
+'\n ' Text
+'this' Name.Variable.Instance
+':' Operator
+'record_connection' Name.Function
+'(' Operator
+'candidate' Text
+');' Operator
+'\n ' Text
+'if' Keyword
+' ' Text
+'(' Operator
+'verb' Text
+'[' Operator
+'1' Literal.Number.Integer
+']' Operator
+' ' Text
+'==' Operator
+' ' Text
+'"s"' Literal.String
+')' Operator
+'\n ' Text
+'candidate' Text
+'.' Operator
+'use_do_command' Text
+' ' Text
+'=' Operator
+' ' Text
+'0' Literal.Number.Integer
+';' Operator
+'\n ' Text
+'endif' Keyword
+'\n ' Text
+'return' Keyword
+' ' Text
+'candidate' Text
+';' Operator
+'\n ' Text
+'endif' Keyword
+'\n' Text
+
+'endif' Keyword
+'\n' Text
+
+'return' Keyword
+' ' Text
+'0' Literal.Number.Integer
+';' Operator
+'\n' Text
diff --git a/tests/lexers/moocode/example2.txt b/tests/lexers/moocode/example2.txt
new file mode 100644
index 00000000..3f66db1d
--- /dev/null
+++ b/tests/lexers/moocode/example2.txt
@@ -0,0 +1,255 @@
+---input---
+if (this.running)
+ player:tell("[Train] Error: already a jump in progress");
+ return;
+endif
+this.running = 1;
+this.aborted = 0;
+this:announce_all("[Train] departure in 20 seconds");
+dest = this.targets[random(length(this.targets))];
+this:announce_all("[Train] Next stop is '", dest:title(), "'");
+this:announce_all("You hear the engines starting up");
+this.location:announce("The MOOTrain starts up his engines");
+suspend(20);
+if (this.aborted)
+ this.running = 0;
+ this.aborted = 0;
+ return;
+endif
+this:announce_all("[Train] Departure!");
+this.location:announce_all("The MOOTrain leaves into the 42th dimension!");
+this:announce_all("Outside you see the lights of the 42th dimension");
+this:moveto(dest);
+suspend(4);
+this:announce_all("The glowing gets less, until you can see the clear shape of the room, the MOOTrain has landed in");
+this.location:announce_all("The MOOTrain arrives out of the 42th dimension!");
+this:announce_all("[Train] arrived in '", dest:title(), "'");
+this.running = 0;
+
+---tokens---
+'if' Keyword
+' ' Text
+'(' Operator
+'this' Name.Variable.Instance
+'.' Operator
+'running' Text
+')' Operator
+'\n ' Text
+'player' Name.Variable.Instance
+':' Operator
+'tell' Name.Function
+'(' Operator
+'"[Train] Error: already a jump in progress"' Literal.String
+');' Operator
+'\n ' Text
+'return' Keyword
+';' Operator
+'\n' Text
+
+'endif' Keyword
+'\n' Text
+
+'this' Name.Variable.Instance
+'.' Operator
+'running' Text
+' ' Text
+'=' Operator
+' ' Text
+'1' Literal.Number.Integer
+';' Operator
+'\n' Text
+
+'this' Name.Variable.Instance
+'.' Operator
+'aborted' Text
+' ' Text
+'=' Operator
+' ' Text
+'0' Literal.Number.Integer
+';' Operator
+'\n' Text
+
+'this' Name.Variable.Instance
+':' Operator
+'announce_all' Name.Function
+'(' Operator
+'"[Train] departure in 20 seconds"' Literal.String
+');' Operator
+'\n' Text
+
+'dest' Text
+' ' Text
+'=' Operator
+' ' Text
+'this' Name.Variable.Instance
+'.' Operator
+'targets' Text
+'[' Operator
+'random' Name.Builtin
+'(' Operator
+'length' Name.Builtin
+'(' Operator
+'this' Name.Variable.Instance
+'.' Operator
+'targets' Text
+'))];' Operator
+'\n' Text
+
+'this' Name.Variable.Instance
+':' Operator
+'announce_all' Name.Function
+'(' Operator
+'"[Train] Next stop is \'"' Literal.String
+',' Operator
+' ' Text
+'dest' Text
+':' Operator
+'title' Name.Function
+'(' Operator
+'),' Operator
+' ' Text
+'"\'"' Literal.String
+');' Operator
+'\n' Text
+
+'this' Name.Variable.Instance
+':' Operator
+'announce_all' Name.Function
+'(' Operator
+'"You hear the engines starting up"' Literal.String
+');' Operator
+'\n' Text
+
+'this' Name.Variable.Instance
+'.' Operator
+'location' Text
+':' Operator
+'announce' Name.Function
+'(' Operator
+'"The MOOTrain starts up his engines"' Literal.String
+');' Operator
+'\n' Text
+
+'suspend' Name.Function
+'(' Operator
+'20' Literal.Number.Integer
+');' Operator
+'\n' Text
+
+'if' Keyword
+' ' Text
+'(' Operator
+'this' Name.Variable.Instance
+'.' Operator
+'aborted' Text
+')' Operator
+'\n ' Text
+'this' Name.Variable.Instance
+'.' Operator
+'running' Text
+' ' Text
+'=' Operator
+' ' Text
+'0' Literal.Number.Integer
+';' Operator
+'\n ' Text
+'this' Name.Variable.Instance
+'.' Operator
+'aborted' Text
+' ' Text
+'=' Operator
+' ' Text
+'0' Literal.Number.Integer
+';' Operator
+'\n ' Text
+'return' Keyword
+';' Operator
+'\n' Text
+
+'endif' Keyword
+'\n' Text
+
+'this' Name.Variable.Instance
+':' Operator
+'announce_all' Name.Function
+'(' Operator
+'"[Train] Departure!"' Literal.String
+');' Operator
+'\n' Text
+
+'this' Name.Variable.Instance
+'.' Operator
+'location' Text
+':' Operator
+'announce_all' Name.Function
+'(' Operator
+'"The MOOTrain leaves into the 42th dimension!"' Literal.String
+');' Operator
+'\n' Text
+
+'this' Name.Variable.Instance
+':' Operator
+'announce_all' Name.Function
+'(' Operator
+'"Outside you see the lights of the 42th dimension"' Literal.String
+');' Operator
+'\n' Text
+
+'this' Name.Variable.Instance
+':' Operator
+'moveto' Name.Function
+'(' Operator
+'dest' Text
+');' Operator
+'\n' Text
+
+'suspend' Name.Function
+'(' Operator
+'4' Literal.Number.Integer
+');' Operator
+'\n' Text
+
+'this' Name.Variable.Instance
+':' Operator
+'announce_all' Name.Function
+'(' Operator
+'"The glowing gets less, until you can see the clear shape of the room, the MOOTrain has landed in"' Literal.String
+');' Operator
+'\n' Text
+
+'this' Name.Variable.Instance
+'.' Operator
+'location' Text
+':' Operator
+'announce_all' Name.Function
+'(' Operator
+'"The MOOTrain arrives out of the 42th dimension!"' Literal.String
+');' Operator
+'\n' Text
+
+'this' Name.Variable.Instance
+':' Operator
+'announce_all' Name.Function
+'(' Operator
+'"[Train] arrived in \'"' Literal.String
+',' Operator
+' ' Text
+'dest' Text
+':' Operator
+'title' Name.Function
+'(' Operator
+'),' Operator
+' ' Text
+'"\'"' Literal.String
+');' Operator
+'\n' Text
+
+'this' Name.Variable.Instance
+'.' Operator
+'running' Text
+' ' Text
+'=' Operator
+' ' Text
+'0' Literal.Number.Integer
+';' Operator
+'\n' Text