From 7efad571767daa39b48993f070512c6c6127db2d Mon Sep 17 00:00:00 2001 From: Giacomand Date: Mon, 25 Mar 2013 09:49:00 +0000 Subject: [PATCH 1/6] Added: * DM (Dream Maker) language. * Sample DM file. The DM language is used in an engine known as BYOND which allows users to easily create their own games in a language that is designed to be accessible for newcomers. I do not know how much a language has to be used on the site to be considered but searching for "BYOND" does show a lot of people using the language. I am also still learning git so if I have missed something then please let me know. --- lib/linguist/languages.yml | 8 ++++ samples/DM/example.dm | 79 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 samples/DM/example.dm diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 68b3c04c..17dc3973 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -343,6 +343,14 @@ DCPU-16 ASM: Diff: primary_extension: .diff + +DM: + type: programming + color: "#075ff1" + primary_extension: .dm + aliases: + - byond + Dylan: type: programming diff --git a/samples/DM/example.dm b/samples/DM/example.dm new file mode 100644 index 00000000..fa39836f --- /dev/null +++ b/samples/DM/example.dm @@ -0,0 +1,79 @@ +// This is a single line comment. +/* + This is a multi-line comment +*/ + +// Pre-processor keywords + +#define PI 3.1415 + +#if PI == 4 +DoStuff() +#elif PI == 3 +DoOtherStuff() +#else +DoNothing() +#endif + + +var/GlobalCounter = 0 +var/const/CONST_VARIABLE = 2 +var/list/MyList = list("anything", 1, new /datum/entity) +var/list/EmptyList[99] // creates a list of 99 null entries +var/list/NullList = null + +/* + Entity Class +*/ + +/datum/entity + var/name = "Entity" + var/number = 0 + +/datum/entity/proc/myFunction() + world.log << "Entity has called myFunction" + +/datum/entity/New() + number = GlobalCounter++ + +/* + Unit Class, Extends from Entity +*/ + +/datum/entity/unit + name = "Unit" + +/datum/entity/unit/New() + ..() // calls the parent's proc; equal to super() and base() in other languages + number = rand(1, 99) + +/datum/entity/unit/myFunction() + world.log << "Unit has overriden and called myFunction" + +// Global Function +/proc/ReverseList(var/list/input) + var/list/output = list() + for(var/i = input.len; i >= 1; i--) // IMPORTANT: List Arrays count from 1. + output += input[i] // "+= x" is ".Add(x)" + return output + +// Bitflags +/proc/DoStuff() + var/bitflag = 0 + bitflag |= 8 + return bitflag + +/proc/DoOtherStuff() + var/bitflag = 65535 // 16 bits is the maximum amount + bitflag &= ~8 + return bitflag + +// Logic +/proc/DoNothing() + var/pi = PI + if(pi == 4) + world.log << "PI is 4" + else if(pi == CONST_VARIABLE) + world.log << "PI is [CONST_VARIABLE]!" + else + world.log << "PI is approximety [pi]" From d4312c05bfbdfa12c81fa33ab5bdb21c610fbb1f Mon Sep 17 00:00:00 2001 From: Giacomand Date: Mon, 25 Mar 2013 09:54:23 +0000 Subject: [PATCH 2/6] - Updated sample file. --- samples/DM/example.dm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/samples/DM/example.dm b/samples/DM/example.dm index fa39836f..b8f1fad4 100644 --- a/samples/DM/example.dm +++ b/samples/DM/example.dm @@ -8,11 +8,17 @@ #define PI 3.1415 #if PI == 4 -DoStuff() + +#define G 5 + #elif PI == 3 -DoOtherStuff() + +#define I 6 + #else -DoNothing() + +#define K 7 + #endif @@ -77,3 +83,5 @@ var/list/NullList = null world.log << "PI is [CONST_VARIABLE]!" else world.log << "PI is approximety [pi]" + +#undef PI // Undefine PI \ No newline at end of file From d5c3978a6edbc1d72f83f23964133e40149e6b13 Mon Sep 17 00:00:00 2001 From: Giacomand Date: Mon, 25 Mar 2013 10:13:38 +0000 Subject: [PATCH 3/6] * Fixed a mis-formating. --- lib/linguist/languages.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 17dc3973..e57eb942 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -351,7 +351,6 @@ DM: aliases: - byond - Dylan: type: programming color: "#3ebc27" From 465d60ba86e8a1393b843a9b2cddbcd5f322419c Mon Sep 17 00:00:00 2001 From: Giacomand Date: Mon, 25 Mar 2013 16:07:19 +0000 Subject: [PATCH 4/6] * Missed setting the lexer to Text Only. --- lib/linguist/languages.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index e57eb942..2037a56c 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -347,6 +347,7 @@ Diff: DM: type: programming color: "#075ff1" + lexer: Text only primary_extension: .dm aliases: - byond From e26bf5a0d2529fab60b40b025d91e5846893fc83 Mon Sep 17 00:00:00 2001 From: Giacomand Date: Mon, 25 Mar 2013 16:14:06 +0000 Subject: [PATCH 5/6] - Moving diff to after DM. --- lib/linguist/languages.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 2037a56c..4e25f7b9 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -340,9 +340,6 @@ DCPU-16 ASM: - .dasm aliases: - dasm16 - -Diff: - primary_extension: .diff DM: type: programming @@ -352,6 +349,9 @@ DM: aliases: - byond +Diff: + primary_extension: .diff + Dylan: type: programming color: "#3ebc27" From e408b5fbaa2e6cfc4f7b5cb254e31fc65f4db6e8 Mon Sep 17 00:00:00 2001 From: Giacomand Date: Mon, 25 Mar 2013 16:26:14 +0000 Subject: [PATCH 6/6] * Trying this. --- lib/linguist/languages.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 4e25f7b9..274c21c2 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -304,6 +304,14 @@ D-ObjDump: type: data lexer: d-objdump primary_extension: .d-objdump + +DM: + type: programming + color: "#075ff1" + lexer: Text only + primary_extension: .dm + aliases: + - byond DOT: type: programming @@ -341,14 +349,6 @@ DCPU-16 ASM: aliases: - dasm16 -DM: - type: programming - color: "#075ff1" - lexer: Text only - primary_extension: .dm - aliases: - - byond - Diff: primary_extension: .diff