-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Concurnas is an open-source JVM programming language designed for building reliable, scalable, high performance concurrent, distributed and parallel systems. For more information please see: https://concurnas.com/
- Loading branch information
1 parent
238f116
commit b24f734
Showing
16 changed files
with
471 additions
and
9 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
Prism.languages.concurnas = { | ||
'comment': [ | ||
{ | ||
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, | ||
lookbehind: true | ||
}, | ||
{ | ||
pattern: /(^|[^\\:])\/\/.*/, | ||
lookbehind: true, | ||
greedy: true | ||
} | ||
], | ||
'langext': { | ||
pattern: /\w+\s*\|\|[\s\S]+?\|\|/, | ||
greedy: true, | ||
alias: 'string' | ||
}, | ||
'function': { | ||
pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/, | ||
lookbehind: true | ||
}, | ||
'keyword': /\b(?:abstract|actor|also|annotation|assert|async|await|bool|boolean|break|byte|case|catch|changed|char|class|closed|constant|continue|def|default|del|double|elif|else|enum|every|extends|false|finally|float|for|from|global|gpudef|gpukernel|if|import|in|init|inject|int|lambda|local|long|loop|match|new|nodefault|null|of|onchange|open|out|override|package|parfor|parforsync|post|pre|private|protected|provide|provider|public|return|shared|short|single|size_t|sizeof|super|sync|this|throw|trait|trans|transient|true|try|typedef|unchecked|using|val|var|void|while|with)\b/, | ||
'boolean': /\b(?:false|true)\b/, | ||
'number': /\b0b[01][01_]*L?\b|\b0x[\da-f_]*\.?[\da-f_p+-]+\b|(?:\b\d[\d_]*\.?[\d_]*|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfls]?/i, | ||
'punctuation': /[{}[\];(),.:]/, | ||
'operator': /<==|>==|=>|->|<-|<>|\^|&==|&<>|!|\?|\?:|\.\?|\+\+|--|[-+*/=<>]=?|\b(?:and|as|band|bor|bxor|comp|is|isnot|mod|or)\b=?/, | ||
'annotation': { | ||
pattern: /@(?:\w+:)?(?:\w*|\[[^\]]+\])/, | ||
alias: 'builtin' | ||
} | ||
}; | ||
|
||
Prism.languages.insertBefore('concurnas', 'langext', { | ||
'string': { | ||
pattern: /[rs]?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/, | ||
greedy: true, | ||
inside: { | ||
'interpolation': { | ||
pattern: /((?:^|[^\\])(?:\\{2})*){(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}/, | ||
lookbehind: true, | ||
inside: Prism.languages.concurnas | ||
}, | ||
'string': /[\s\S]+/ | ||
} | ||
} | ||
}); | ||
|
||
Prism.languages.conc = Prism.languages.concurnas; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<h2>Comments</h2> | ||
<pre><code>// This is a comment | ||
/* This is a comment | ||
on multiple lines */</code></pre> | ||
|
||
<h2>Numbers</h2> | ||
<pre><code>12 | ||
12e5 | ||
12.f | ||
12f | ||
12d | ||
12.d | ||
12.0 | ||
12.0f | ||
12.0d</code></pre> | ||
|
||
<h2>strings and language extensions</h2> | ||
<pre><code>"hi" | ||
'hi' | ||
'c' | ||
'what "yach"' | ||
s'c' | ||
"c" | ||
r"[a-z|A-Z]+"</code></pre> | ||
|
||
<h2>Functions</h2> | ||
<pre><code>def add(a int, b int) => a + b</code></pre> | ||
|
||
<h2>Language Extensions</h2> | ||
<pre><code>dcalc = mylisp||(+ 1 2 (* 2 3))|| // == 9 | ||
|
||
myFortran || program hello | ||
print *, "Hello World!" | ||
end program hello|| //prints "Hello World!" | ||
|
||
lotto = myAPL || x[⍋x←6?40] || //6 unique random numbers from 1 to 40</code></pre> | ||
|
||
<h2>Full example</h2> | ||
<pre><code>//an overloaded function | ||
def adder(a int, b int) => a + b | ||
def adder(a int, b float) => adder(a, b as int) | ||
def adder(a int) => adder(a, 10) | ||
|
||
//a default value | ||
def powerPlus(a int, raiseTo = 2, c int) => a ** raiseTo + c | ||
|
||
//call our function with a default value | ||
res1 = powerPlus(4, 10)//second argument defaults to '2' | ||
res2 = powerPlus(4, 3, 10)//second argument provided | ||
|
||
//calling a function with named parameters: | ||
def powerAdder(a int, raiseATo = 2, b int, raiseBTo = 2) => a**raiseATo + b**raiseBTo | ||
res3 = powerAdder(2, 4, raiseATo=3)//equivalent to: powerAdder(2, 3, 4, 2) | ||
|
||
//varargs: | ||
def sum(elms int...) int { | ||
res = 0 | ||
for(elm in elms){ | ||
res += elm | ||
} | ||
res | ||
} | ||
|
||
//call our function with a vararg | ||
thesum = sum(1, 2, 3, 4, 5) | ||
|
||
//partially defined typedef | ||
typedef NameMap<X> = java.util.ArrayList<java.util.HashMap<String, java.util.HashSet<X>>> | ||
|
||
//using typedefs... | ||
nm NameMap<String>= new NameMap<String>() | ||
|
||
@Annotation | ||
class MyClass(a int, b int, c String){ | ||
override toString() => 'MyClass({a}, {b}, "{c}")' | ||
} | ||
|
||
mc1 = MyClass(12, 14, "hi there") | ||
mc2 = mc1@ //copy mc1 | ||
|
||
assert mc1 == mc2//same values! | ||
assert mc1 &<> mc2//different objects! | ||
|
||
mc3 = mc1@(a = 100)//copy mc1 but overwrite value of a | ||
assert 'MyClass(100, 14, "hi there")' == mc3.toString() | ||
|
||
mc4 = mc1@(<a, b>)//copy mc1 but exclude a and b | ||
assert 'MyClass(0, 0, "hi there")' == mc3.toString() | ||
</code></pre> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.