diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 15c523d6..324576db 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1102,6 +1102,7 @@ Mercury: lexer: Prolog extensions: - .m + - .moo MiniD: # Legacy searchable: false diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index 652fef38..073330af 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -217,6 +217,9 @@ "ABAP": [ ".abap" ], + "Moocode": [ + ".moo" + ], "Java": [ ".java" ], @@ -340,7 +343,8 @@ ".bsv" ], "Mercury": [ - ".m" + ".m", + ".moo" ], "Erlang": [ ".erl", @@ -563,8 +567,8 @@ "zshrc" ] }, - "tokens_total": 484777, - "languages_total": 561, + "tokens_total": 485338, + "languages_total": 564, "tokens": { "Groovy": { "SHEBANG#!groovy": 1, @@ -24491,6 +24495,41 @@ "pos": 2, "endclass.": 1 }, + "Moocode": { + "@verb": 1, + "toy": 3, + "do_the_work": 3, + "this": 5, + "none": 1, + "@program": 2, + "if": 4, + "(": 13, + "this.wound": 8, + ")": 13, + "object_utils": 1, + "isa": 1, + "this.location": 3, + "room": 1, + "announce_all": 2, + "this.name": 4, + "continue_msg": 1, + ";": 8, + "-": 1, + "fork": 1, + "endfork": 1, + "else": 1, + "wind_down_msg": 1, + "endif": 4, + "<": 1, + ".": 2, + "wind": 1, + "+": 1, + "player": 1, + "tell": 1, + "player.location": 1, + "announce": 1, + "player.name": 1 + }, "Java": { "package": 6, "clojure.lang": 1, @@ -36959,29 +36998,29 @@ }, "Mercury": { "%": 416, - "-": 6914, - "module": 45, + "-": 6967, + "module": 46, "rot13_verbose.": 1, - "interface.": 12, - "import_module": 124, + "interface.": 13, + "import_module": 126, "io.": 8, - "pred": 253, + "pred": 255, "main": 15, - "(": 3284, + "(": 3351, "io__state": 4, - ")": 3284, - ".": 592, - "mode": 6, + ")": 3351, + ".": 610, + "mode": 8, "di": 54, "uo": 58, - "is": 244, - "det.": 182, - "implementation.": 11, - "char": 7, - "int": 124, - "require.": 5, + "is": 246, + "det.": 184, + "implementation.": 12, + "char": 10, + "int": 129, + "require.": 6, "rot13a/2": 1, - "A": 6, + "A": 14, "table": 1, "to": 16, "map": 7, @@ -36996,8 +37035,8 @@ "input": 1, "not": 7, "rot13a": 55, - "in": 506, - "out": 334, + "in": 510, + "out": 337, "semidet.": 10, "rot13/2": 1, "Applies": 1, @@ -37011,13 +37050,13 @@ "else": 8, "io__read_char": 1, "Res": 8, - "{": 23, + "{": 27, "ok": 3, - "}": 24, + "}": 28, "io__write_char": 1, - ";": 898, - "eof": 3, - "error": 6, + ";": 913, + "eof": 6, + "error": 7, "ErrorCode": 4, "io__error_message": 2, "ErrorMessage": 4, @@ -37041,10 +37080,10 @@ "sub_string_search": 1, "Index": 3, "NewIndex": 2, - "+": 125, + "+": 127, "mod": 1, - "*": 18, - "//": 1, + "*": 20, + "//": 2, "index_det": 1, "read_char": 1, "print": 3, @@ -37056,9 +37095,9 @@ "store": 52, "T": 52, "where": 8, - "[": 184, - "]": 184, - "type": 56, + "[": 203, + "]": 203, + "type": 57, "S": 133, "instance": 4, "io.state": 3, @@ -37132,7 +37171,7 @@ "store_ref": 1, "store.new_ref": 1, "store.ref_functor": 1, - "string": 114, + "string": 115, "store.arg_ref": 1, "ArgT": 4, "store.new_arg_ref": 3, @@ -37203,7 +37242,7 @@ "representation": 1, "pragma": 41, "foreign_type": 10, - "C": 24, + "C": 34, "MR_Word": 24, "can_pass_as_mercury_type": 5, "equality": 5, @@ -37287,7 +37326,7 @@ "FieldInfo": 1, "Constructors": 2, "init": 8, - "num": 8, + "num": 11, "setField": 4, "Set": 2, "according": 2, @@ -37409,7 +37448,7 @@ "mdbcomp.prim_data.": 3, "parse_tree.": 1, "parse_tree.prog_data.": 2, - "list.": 3, + "list.": 4, "maybe.": 3, "term.": 3, "polymorphism_process_module": 2, @@ -37425,7 +37464,7 @@ "pred_info": 20, "proc_info": 11, "proc_id": 12, - "list": 77, + "list": 82, "prog_var": 58, "builtin_state": 1, "maybe": 20, @@ -37547,7 +37586,7 @@ "ArgTypes": 6, "pred_info_set_arg_types": 1, "PredInfo1": 5, - "|": 28, + "|": 38, "OldHeadVarTypes": 2, "type_list_subsumes": 2, "Subn": 3, @@ -38292,6 +38331,32 @@ "NonLocals1": 2, "CallGoalExpr": 2, "CallGoal": 2, + "expr.": 1, + "token": 5, + "parse": 1, + "exprn/1": 1, + "xx": 1, + "scan": 16, + "rule": 3, + "exprn": 7, + "Num": 18, + "term": 10, + "B": 8, + "factor": 6, + "/": 1, + "Chars": 2, + "Toks": 13, + "Toks0": 11, + "list__reverse": 1, + "Cs": 9, + "char__is_whitespace": 1, + "char__is_digit": 2, + "takewhile": 1, + "Digits": 2, + "Rest": 2, + "string__from_char_list": 1, + "NumStr": 2, + "string__det_to_int": 1, "char.": 1, "getopt_io.": 1, "short_option": 36, @@ -38378,7 +38443,6 @@ "debug_code_gen_pred_id": 3, "debug_opt": 3, "debug_term": 4, - "term": 1, "termination": 3, "analysis": 1, "debug_opt_pred_id": 3, @@ -51924,6 +51988,7 @@ "Org": 358, "Turing": 44, "ABAP": 1500, + "Moocode": 93, "Java": 8987, "Omgrofl": 57, "GAS": 133, @@ -51960,7 +52025,7 @@ "RMarkdown": 19, "Stylus": 76, "Bluespec": 1298, - "Mercury": 30628, + "Mercury": 31096, "Erlang": 2928, "NSIS": 725, "Arduino": 20, @@ -52072,6 +52137,7 @@ "Org": 1, "Turing": 1, "ABAP": 1, + "Moocode": 2, "Java": 6, "Omgrofl": 1, "GAS": 1, @@ -52108,7 +52174,7 @@ "RMarkdown": 1, "Stylus": 1, "Bluespec": 2, - "Mercury": 8, + "Mercury": 9, "Erlang": 5, "NSIS": 2, "Arduino": 1, @@ -52155,5 +52221,5 @@ "Protocol Buffer": 1, "Scheme": 2 }, - "md5": "1c540f92a03ec13cf822b38473b5a4ff" + "md5": "9dbc6271b8d729f78fea54760082d89a" } \ No newline at end of file diff --git a/samples/Mercury/expr.moo b/samples/Mercury/expr.moo new file mode 100644 index 00000000..30a140ab --- /dev/null +++ b/samples/Mercury/expr.moo @@ -0,0 +1,72 @@ +:- module expr. + +:- interface. + +:- import_module char, int, list. + +:- type token + ---> ('+') + ; ('-') + ; ('*') + ; ('/') + ; num(int) + ; ('(') + ; (')') + ; eof + . + +:- parse(exprn/1, token, eof, xx, in, out). + +:- pred scan(list(char), list(token)). +:- mode scan(in, out) is det. + +:- implementation. + +:- import_module string, require. + +:- rule exprn(int). +exprn(Num) ---> exprn(A), [+], term(B), { Num = A + B }. +exprn(Num) ---> exprn(A), [-], term(B), { Num = A - B }. +exprn(Num) ---> term(Num). + +:- rule term(int). +term(Num) ---> term(A), [*], factor(B), { Num = A * B }. +term(Num) ---> term(A), [/], factor(B), { Num = A // B }. +term(Num) ---> factor(Num). + +:- rule factor(int). +factor(Num) ---> ['('], exprn(Num), [')']. +factor(Num) ---> [num(Num)]. + +scan(Chars, Toks) :- + scan(Chars, [], Toks0), + list__reverse(Toks0, Toks). + +:- pred scan(list(char), list(token), list(token)). +:- mode scan(in, in, out) is det. + +scan([], Toks, [eof|Toks]). +scan([C|Cs], Toks0, Toks) :- + ( char__is_whitespace(C) -> + scan(Cs, Toks0, Toks) + ; char__is_digit(C) -> + takewhile(char__is_digit, [C|Cs], Digits, Rest), + string__from_char_list(Digits, NumStr), + Num = string__det_to_int(NumStr), + scan(Rest, [num(Num)|Toks0], Toks) + ; C = ('+') -> + scan(Cs, ['+'|Toks0], Toks) + ; C = ('-') -> + scan(Cs, ['-'|Toks0], Toks) + ; C = ('*') -> + scan(Cs, ['*'|Toks0], Toks) + ; C = ('/') -> + scan(Cs, ['/'|Toks0], Toks) + ; C = ('(') -> + scan(Cs, ['('|Toks0], Toks) + ; C = (')') -> + scan(Cs, [')'|Toks0], Toks) + ; + error("expr: syntax error in input") + ). + diff --git a/samples/Moocode/hello.moo b/samples/Moocode/hello.moo new file mode 100644 index 00000000..ba9dda3a --- /dev/null +++ b/samples/Moocode/hello.moo @@ -0,0 +1,5 @@ +@program toy:wind +this.wound = this.wound + 2; +player:tell("You wind up the ", this.name,"."); +player.location:announce(player.name, " winds up the ", this.name,"."); +. diff --git a/samples/Moocode/toy.moo b/samples/Moocode/toy.moo new file mode 100644 index 00000000..fec09b39 --- /dev/null +++ b/samples/Moocode/toy.moo @@ -0,0 +1,19 @@ +@verb toy:do_the_work this none this +@program toy:do_the_work +if (this.wound) + if ($object_utils:isa(this.location,$room)) + this.location:announce_all(this.name," ", this:continue_msg()); + this.wound = this.wound - 1; + if (this.wound) + fork (15) + this:do_the_work(); + endfork + else + this.location:announce_all(this.name, " ", this:wind_down_msg()); + endif + endif + if (this.wound < 0) + this.wound = 0; + endif +endif +.