Skip to content

Commit

Permalink
Added support for False (#2802)
Browse files Browse the repository at this point in the history
  • Loading branch information
edukisto authored Mar 13, 2021
1 parent a68f1fb commit 99a21dc
Show file tree
Hide file tree
Showing 13 changed files with 307 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@
"title": "Factor",
"owner": "catb0t"
},
"false": {
"title": "False",
"owner": "edukisto"
},
"firestore-security-rules": {
"title": "Firestore security rules",
"require": "clike",
Expand Down
32 changes: 32 additions & 0 deletions components/prism-false.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
(function (Prism) {
/**
* Based on the manual by Wouter van Oortmerssen.
*
* @see {@link https://github.com/PrismJS/prism/issues/2801#issue-829717504}
*/
Prism.languages['false'] = {
'comment': {
pattern: /\{[^}]*\}/
},
'string': {
pattern: /"[^"]*"/,
greedy: true
},
'character-code': {
pattern: /'[\S\s]/,
alias: 'number'
},
'assembler-code': {
pattern: /\d+`/,
alias: 'important'
},
'number': /\d+/,
'operator': /[-!#$%&'*+,./:;=>?@\\^_`|~ßø]/,
'punctuation': /\[|\]/,
'variable': /[a-z]/,
'non-standard': {
pattern: /[()<BDO®]/,
alias: 'bold'
}
};
}(Prism));
1 change: 1 addition & 0 deletions components/prism-false.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions examples/prism-false.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<h2>Hello, world!</h2>

<pre><code>"Hello, world!"</code></pre>

<h2>Lambda functions</h2>

<h3>Increment</h3>

<pre><code>5 [7+]! . {Outputs 12.}</code></pre>

<h3>Square numbers</h3>

<pre><code>[$*] s: 7s;! . {Outputs 49.}</code></pre>

<h2>Conditions</h2>

<h3>Equal, less, or greater than</h3>

<pre><code>5x:
7y:
x;y;=
$
x;
.
[" equals "]?
~[
x;y;>
$
[" is greater than "]?
~[" is less than "]?
]?
y;
.</code></pre>

<h2>Loops</h2>

<h3>English alphabet</h3>

<pre><code>'Ai: 'Zm: 1m;+ m: [m;i;>][i;, 1i;+ i:]#</code></pre>

<h3>Ten Green Bottles</h3>

<pre><code>[$ . " green bottle" 1> ["s"]? ".
"] f:
10n: [n;0>][n;f;! n;1- n:]#</code></pre>

<h2>User input</h2>

<h3>Reverse a string</h3>

<pre><code>"Enter the string character by character (or a space to finish):
"0i: [ß ^ $ 32=~][i;1+ i:]# % "Reverse: " [i;0>][, i;1- i:]#</code></pre>
5 changes: 5 additions & 0 deletions tests/identifier-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ const testOptions = {
template: false
},

'false': {
word: false,
template: false
},

// LilyPond doesn't tokenize based on words
'lilypond': {
word: false,
Expand Down
13 changes: 13 additions & 0 deletions tests/languages/false/assembler_code_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
0`
65535`

----------------------------------------------------

[
["assembler-code", "0`"],
["assembler-code", "65535`"]
]

----------------------------------------------------

Checks for assembler codes.
16 changes: 16 additions & 0 deletions tests/languages/false/character_code_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'
'
'
''

----------------------------------------------------

[
["character-code", "'\n"], ["character-code", "'\t"],
["character-code", "' "],
["character-code", "''"]
]

----------------------------------------------------

Checks for character codes.
26 changes: 26 additions & 0 deletions tests/languages/false/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
}
{!#$%&'*+,-./:;=>?@[\]^_`|~ßø}
{""}
{foo}
{{}
{}
{}{}
{}}

----------------------------------------------------

[
["comment", "{\n}"],
["comment", "{!#$%&'*+,-./:;=>?@[\\]^_`|~ßø}"],
["comment", "{\"\"}"],
["comment", "{foo}"],
["comment", "{{}"],
["comment", "{}"],
["comment", "{}"], ["comment", "{}"],
["comment", "{}"], "}"
]

----------------------------------------------------

Checks for comments.
59 changes: 59 additions & 0 deletions tests/languages/false/operator_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
!
#
$
%
&
*
+
,
-
.
/
:
;
=
>
?
@
\
^
_
`
|
~
ß
ø

----------------------------------------------------

[
["operator", "!"],
["operator", "#"],
["operator", "$"],
["operator", "%"],
["operator", "&"],
["operator", "*"],
["operator", "+"],
["operator", ","],
["operator", "-"],
["operator", "."],
["operator", "/"],
["operator", ":"],
["operator", ";"],
["operator", "="],
["operator", ">"],
["operator", "?"],
["operator", "@"],
["operator", "\\"],
["operator", "^"],
["operator", "_"],
["operator", "`"],
["operator", "|"],
["operator", "~"],
["operator", "ß"],
["operator", "ø"]
]

----------------------------------------------------

Checks for operators.
13 changes: 13 additions & 0 deletions tests/languages/false/punctuation_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
]

----------------------------------------------------

[
["punctuation", "["],
["punctuation", "]"]
]

----------------------------------------------------

Checks for punctuation marks.
22 changes: 22 additions & 0 deletions tests/languages/false/string_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"
"
"!#$%&'*+,-./:;=>?@[\]^_`|~ßø"
""
""""
"foo"
"{}"

----------------------------------------------------

[
["string", "\"\n\""],
["string", "\"!#$%&'*+,-./:;=>?@[\\]^_`|~ßø\""],
["string", "\"\""],
["string", "\"\""], ["string", "\"\""],
["string", "\"foo\""],
["string", "\"{}\""]
]

----------------------------------------------------

Checks for strings.
63 changes: 63 additions & 0 deletions tests/languages/false/variable_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
zzz

----------------------------------------------------

[
["variable", "a"],
["variable", "b"],
["variable", "c"],
["variable", "d"],
["variable", "e"],
["variable", "f"],
["variable", "g"],
["variable", "h"],
["variable", "i"],
["variable", "j"],
["variable", "k"],
["variable", "l"],
["variable", "m"],
["variable", "n"],
["variable", "o"],
["variable", "p"],
["variable", "q"],
["variable", "r"],
["variable", "s"],
["variable", "t"],
["variable", "u"],
["variable", "v"],
["variable", "w"],
["variable", "x"],
["variable", "y"],
["variable", "z"],
["variable", "z"], ["variable", "z"], ["variable", "z"]
]

----------------------------------------------------

Checks for variables.

0 comments on commit 99a21dc

Please sign in to comment.