Skip to content

Commit

Permalink
provisionally implement Novox syntax highlighting engine
Browse files Browse the repository at this point in the history
  • Loading branch information
Sup2point0 committed Feb 22, 2024
1 parent 6079560 commit dea7183
Show file tree
Hide file tree
Showing 10 changed files with 401 additions and 97 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__/
84 changes: 84 additions & 0 deletions resources/Nova/novox/code.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<sup ver="6" sty="utinax-vis" ind=3>
\\
DISCLAIMER –
This code is only a peek at what supcode can do.
It is not by any means functional, optimised or perfect.
Enjoy ^v^
\\

<sec 'structs'>
create struct 'profile' {
\\
Represents a user profile.
\\

evolve action create self(ctx) [
| int 'id'
| str 'user', 'name'
| str, list(str) 'alts' = none
| list(str) 'langs' = list()
| list(str) 'apts' = list()
| (par)s 'pars'
] {
\\
Creates a new profile.
\\

auto set id, name, alt-name, langs, apts

set self.'render-keywords' = dict(
"id" = "User ID",
"name" = "Username",
"alts" = "Alternative Usernames",
"langs" = "Programming Languages",
"apts" = "Aptitudes",
)

loop for key, val in pars {
set self.(shard(key)) = val
}
}

create func self.render-text() to str {
set 'text' = "Profile[" + "\n"

loop for 'var' in self._vars_ {
if var in self.render-keywords {
alt text + "`render-keywords # var`: "
} else {
alt text + str(var) + ": "
}

alt text + { if var is iterable then {
str.join(
{ for each in var out str(each) }
) [sep = ", "]
} else str(var) }
}

out text
}
}
</sec>

<sec "core">
evolve sys.run(ctx) [(par)s]
{
set 'sup' = profile() [
| id = 2.0
| name = "Sup#2.0"
| alt-name = "Sup2point0"
| langs = "supcode", "Scratch", "Python", "C#", "HTML", "CSS", "JavaScript",
| apts = (
"creating", "designing", "coding", "procrastinating",
)
]

sys.out(sup.render-text())
sys.in()
sys.quit()
}
</sec>

\ how’d you like that?
</sup>
74 changes: 38 additions & 36 deletions resources/Nova/novox/colours.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
{
"comment": "grey.nova",
"comment.single": "grey.nova",
"comment.double": "grey.nova",
"comment.triple": "grey.nova",
"comment.single.bounded": "grey.nova",
"comment.double.bounded": "grey.nova",
"comment.triple.bounded": "grey.nova",
"keyword": "blue.nova",
"action": "blue.nova", // TODO
"logic": "orange.solar",
"function": "pink.electric",
"struct": "lilac.nova",
"shard": "#fff", // TODO
"string": "#fff", // TODO
"number": "blue.crescent",
"bool": "lilac.crescent",
"none": "lilac.crescent",
"class": "lilac.nova", // TODO
"object": "#fff",
"object.constant": "#fff", // TODO
"object.ephemeral": ["#fff", "italic"], // TODO
"object.argument": "pink.spirit",
"object.parameter": "pink.spirit",
"object.special": ["lilac.crescent", "italic"],
"extension": "teal.electric",
"ixtension": "teal.electric",
"particle": "#fff", // TODO
"secator": "purple.spirit",
"operator": "orange.solar",
"dot": "grey.nova",
"colon": "orange.spirit",
"semicolon": "blue.deep",
"pipe": "#fff",
"bracket.round": "#fff",
"bracket.square": "#fff",
"brace": "#fff",
"blue-nova": "#4090f1",
"blue-crescent": "#c0f0ff",
"blue-spirit": "#70c7ff",
"blue-sky": "#45c7f1",
"blue-ocean": "#2070c1",
"blue-deep": "#145090",
"blue-electric": "#40e0ff",
"blue-accent": "#0064f1",
"blue-midnight": "#00172a",
"grey-nova": "#a9b0b8",
"grey-swallow": "#dfe7f1",
"grey-spirit": "#c7d0d9",
"grey-ocean": "#90969e",
"grey-storm": "#70767c",
"lilac-nova": "#9090f1",
"lilac-crescent": "#c7c7ff",
"pink-electric": "#ff0090",
"pink-spirit": "#f190f1",
"purple-spirit": "#9040f1",
"purple-nova": "#6040f1",
"purple-accent": "#7000ff",
"red-nova": "#ff0040",
"red-spirit": "#ff2000",
"red-crescent": "#ffc0a9",
"orange-spirit": "#ff7000",
"orange-solar": "#ff9020",
"yellow-solar": "#ffa920",
"yellow-nova": "#ffc720",
"mellow-crescent": "#fff0c0",
"green-solar": "#70c720",
"green-spirit": "#40c740",
"green-nova": "#00c745",
"aquamarine-accent": "#33c070",
"teal-electric": "#40f190",
"teal-lightning": "#c1fff1",
"teal-spirit": "#60c7c7",
"teal-nova": "#409090"
}

180 changes: 180 additions & 0 deletions resources/Nova/novox/export.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
<!DOCTYPE html>
<html>
<head>
<title> supcode Render </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
</head>
<body>
<p><pre><span class="operator">&lt;</span>sup ver<span class="operator">=</span>"6" sty<span class="operator">=</span>"utinax-vis" ind<span class="operator">=</span>3<span class="operator">&gt;</span>

\\

DISCLAIMER –

This code <span class="logic">is</span> only a peek at what supcode can do.

It <span class="logic">is</span> <span class="logic">not</span> by any means functional, optimised <span class="logic">or</span> perfect.

Enjoy <span class="operator">^</span>v<span class="operator">^</span>

\\



<span class="operator">&lt;</span>sec 'structs'<span class="operator">&gt;</span>

<span class="action">create</span> <span class="struct">struct</span> 'profile' {

\\

Represents a user profile.

\\



<span class="action">evolve</span> <span class="struct">action</span> <span class="action">create</span> self(ctx) [

| <span class="struct">int</span> 'id'

| <span class="struct">str</span> 'user', 'name'

| <span class="struct">str</span>, <span class="struct">list</span>(<span class="struct">str</span>) 'alts' <span class="operator">=</span> none

| <span class="struct">list</span>(<span class="struct">str</span>) 'langs' <span class="operator">=</span> <span class="struct">list</span>()

| <span class="struct">list</span>(<span class="struct">str</span>) 'apts' <span class="operator">=</span> <span class="struct">list</span>()

| (par)s 'pars'

] {

\\

Creates a new profile.

\\



<span class="keyword">auto</span> <span class="action">set</span> id, name, <span class="action">alt</span>-name, langs, apts



<span class="action">set</span> self.'render-keywords' <span class="operator">=</span> <span class="struct">dict</span>(

"id" <span class="operator">=</span> "User ID",

"name" <span class="operator">=</span> "Username",

"alts" <span class="operator">=</span> "Alternative Usernames",

"langs" <span class="operator">=</span> "Programming Languages",

"apts" <span class="operator">=</span> "Aptitudes",

)



<span class="action">loop</span> for key, val <span class="logic">in</span> pars {

<span class="action">set</span> self.(shard(key)) <span class="operator">=</span> val

}

}



<span class="action">create</span> <span class="struct">func</span> self.render-text() <span class="action">to</span> <span class="struct">str</span> {

<span class="action">set</span> 'text' <span class="operator">=</span> "Profile[" <span class="operator">+</span> "\n"



<span class="action">loop</span> for 'var' <span class="logic">in</span> self._vars_ {

<span class="keyword">if</span> var <span class="logic">in</span> self.render-keywords {

<span class="action">alt</span> text <span class="operator">+</span> "`render-keywords <span class="operator">#</span> var`: "

} <span class="keyword">else</span> {

<span class="action">alt</span> text <span class="operator">+</span> <span class="struct">str</span>(var) <span class="operator">+</span> ": "

}



<span class="action">alt</span> text <span class="operator">+</span> { <span class="keyword">if</span> var <span class="logic">is</span> iterable then {

<span class="struct">str</span>.join(

{ for each <span class="logic">in</span> var <span class="action">out</span> <span class="struct">str</span>(each) }

) [sep <span class="operator">=</span> ", "]

} <span class="keyword">else</span> <span class="struct">str</span>(var) }

}



<span class="action">out</span> text

}

}

<span class="operator">&lt;</span><span class="operator">/</span>sec<span class="operator">&gt;</span>



<span class="operator">&lt;</span>sec "core"<span class="operator">&gt;</span>

<span class="action">evolve</span> sys.run(ctx) [(par)s]

{

<span class="action">set</span> 'sup' <span class="operator">=</span> profile() [

| id <span class="operator">=</span> 2.0

| name <span class="operator">=</span> "Sup<span class="operator">#</span>2.0"

| <span class="action">alt</span>-name <span class="operator">=</span> "Sup2point0"

| langs <span class="operator">=</span> "supcode", "Scratch", "Python", "C<span class="operator">#</span>", "HTML", "CSS", "JavaScript",

| apts <span class="operator">=</span> (

"creating", "designing", "coding", "procrastinating",

)

]



sys.<span class="action">out</span>(sup.render-text())

sys.<span class="logic">in</span>()

sys.quit()

}

<span class="operator">&lt;</span><span class="operator">/</span>sec<span class="operator">&gt;</span>



\ how’d you like that?

<span class="operator">&lt;</span><span class="operator">/</span>sup<span class="operator">&gt;</span>

</pre></p>
</body>
</html>
Loading

0 comments on commit dea7183

Please sign in to comment.