Add support for Monkey
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
diff --git a/components.js b/components.js
index 919b3c1..fc07c5d 100644
--- a/components.js
+++ b/components.js
@@ -219,6 +219,10 @@ var components = {
"title": "MATLAB",
"owner": "Golmote"
},
+ "monkey": {
+ "title": "Monkey",
+ "owner": "Golmote"
+ },
"nasm": {
"title": "NASM",
"owner": "rbmj"
diff --git a/components/prism-monkey.js b/components/prism-monkey.js
new file mode 100644
index 0000000..a1bc8a5
--- /dev/null
+++ b/components/prism-monkey.js
@@ -0,0 +1,24 @@
+Prism.languages.monkey = {
+ 'string': /"[^"\r\n]*"/,
+ 'comment': [
+ /^#Rem\s+[\s\S]*?^#End/im,
+ /'.+/,
+ ],
+ 'preprocessor': {
+ pattern: /^\s*#.+/,
+ alias: 'comment'
+ },
+ 'function': /\w+(?=\()/,
+ 'type-char': {
+ pattern: /(\w)[?%#$]/,
+ lookbehind: true,
+ alias: 'variable'
+ },
+ 'number': {
+ pattern: /((?:\.\.)?)(?:(?:\b|\B-\.?|\B\.)\d+((?!\.\.)\.\d*)?|\$[\da-f]+)/i,
+ lookbehind: true
+ },
+ 'keyword': /\b(?:Void|Strict|Public|Private|Property|Bool|Int|Float|String|Array|Object|Continue|Exit|Import|Extern|New|Self|Super|Try|Catch|Eachin|True|False|Extends|Abstract|Final|Select|Case|Default|Const|Local|Global|Field|Method|Function|Class|End|If|Then|Else|ElseIf|EndIf|While|Wend|Repeat|Until|Forever|For|To|Step|Next|Return|Module|Interface|Implements|Inline|Throw|Null)\b/i,
+ 'operator': /\.\.|<>|[<>]=?|:?=|(?:[+\-*\/&~|]|\b(?:Mod|Shl|Shr)\b)=?|\b(?:And|Not|Or)\b/i,
+ 'punctuation': /[.,:;()\[\]]/
+};
\ No newline at end of file
diff --git a/components/prism-monkey.min.js b/components/prism-monkey.min.js
new file mode 100644
index 0000000..4a89577
--- /dev/null
+++ b/components/prism-monkey.min.js
@@ -0,0 +1 @@
+Prism.languages.monkey={string:/"[^"\r\n]*"/,comment:[/^#Rem\s+[\s\S]*?^#End/im,/'.+/],preprocessor:{pattern:/^\s*#.+/,alias:"comment"},"function":/\w+(?=\()/,"type-char":{pattern:/(\w)[?%#$]/,lookbehind:!0,alias:"variable"},number:{pattern:/((?:\.\.)?)(?:(?:\b|\B-\.?|\B\.)\d+((?!\.\.)\.\d*)?|\$[\da-f]+)/i,lookbehind:!0},keyword:/\b(?:Void|Strict|Public|Private|Property|Bool|Int|Float|String|Array|Object|Continue|Exit|Import|Extern|New|Self|Super|Try|Catch|Eachin|True|False|Extends|Abstract|Final|Select|Case|Default|Const|Local|Global|Field|Method|Function|Class|End|If|Then|Else|ElseIf|EndIf|While|Wend|Repeat|Until|Forever|For|To|Step|Next|Return|Module|Interface|Implements|Inline|Throw|Null)\b/i,operator:/\.\.|<>|[<>]=?|:?=|(?:[+\-*\/&~|]|\b(?:Mod|Shl|Shr)\b)=?|\b(?:And|Not|Or)\b/i,punctuation:/[.,:;()\[\]]/};
\ No newline at end of file
diff --git a/examples/prism-monkey.html b/examples/prism-monkey.html
new file mode 100644
index 0000000..7a579f8
--- /dev/null
+++ b/examples/prism-monkey.html
@@ -0,0 +1,90 @@
+<h1>Monkey</h1>
+<p>To use this language, use the class "language-monkey".</p>
+
+<h2>Comments</h2>
+<pre><code>' This is a comment
+
+#Rem ' This is the start of a comment block
+Some comment ' We are inside the comment block
+#End</code></pre>
+
+<h2>Strings</h2>
+<pre><code>"Hello World"
+"~qHello World~q"
+"~tIndented~n"</code></pre>
+
+<h2>Numbers</h2>
+<pre><code>0
+1234
+$3D0DEAD
+$CAFEBABE
+
+.0
+0.0
+.5
+0.5
+1.0
+1.5
+1.00001
+3.14159265</code></pre>
+
+<h2>Variable types</h2>
+<pre><code>Local myVariable:Bool = True
+Local myVariable? = True
+Local myVariable:Int = 1024
+Local myVariable% = 1024
+Local myVariable:Float = 3.141516
+Local myVariable# = 3.141516
+Local myVariable:String = "Hello world"
+Local myVariable$ = "Hello world"</code></pre>
+
+<h2>Full example</h2>
+<pre><code>Import mojo
+
+Class MyApp Extends App
+
+ Method OnCreate()
+
+ SetUpdateRate 60
+
+ End
+
+ Method OnRender()
+
+ Local date:=GetDate()
+
+ Local months:=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]
+
+ Local day:=("0"+date[2])[-2..]
+ Local month:=months[date[1]-1]
+ Local year:=date[0]
+ Local hour:=("0"+date[3])[-2..]
+ Local min:=("0"+date[4])[-2..]
+ Local sec:=("0"+date[5])[-2..] + "." + ("00"+date[6])[-3..]
+
+ Local now:=hour+":"+min+":"+sec+" "+day+" "+month+" "+year
+
+ Cls
+ DrawText now,DeviceWidth/2,DeviceHeight/2,.5,.5
+ End
+
+End
+
+Function Main()
+
+ New MyApp
+
+End</code></pre>
+
+<h2>Known failures</h2>
+<p>There are certain edge cases where Prism will fail.
+ There are always such cases in every regex-based syntax highlighter.
+ However, Prism dares to be open and honest about them.
+ If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
+</p>
+
+<h2>Two double quotes inside a comment</h2>
+<pre><code>' This "comment" is broken
+#Rem
+This "comment" is broken
+#End</code></pre>
\ No newline at end of file