mirror of
https://github.com/flynx/Slang.git
synced 2025-10-29 10:40:07 +00:00
added comment highlighting...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
858fab4d56
commit
145967ce8f
@ -72,6 +72,25 @@
|
|||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* syntax... */
|
||||||
|
|
||||||
|
pre .comment {
|
||||||
|
font-style: italic;
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
|
pre :not(.comment) {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
pre :not(.comment) .string {
|
||||||
|
font-style: italic;
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
pre :not(.comment) .word {
|
||||||
|
font-weight: bold;
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<script src="slang.js"></script>
|
<script src="slang.js"></script>
|
||||||
|
|
||||||
@ -210,10 +229,28 @@ function showAvailableWords(){
|
|||||||
<div id="stack"></div>
|
<div id="stack"></div>
|
||||||
</body>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
document.getElementById('bootstrap').innerHTML='<pre>'+BOOTSTRAP
|
var bootstrap = BOOTSTRAP
|
||||||
.replace(/&/g, '&')
|
// basic HTML compatibility stuff...
|
||||||
.replace(/>/g, '>')
|
.replace(/&/g, '&')
|
||||||
.replace(/</g, '<')+'</pre>'
|
.replace(/>/g, '>')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
// very basic syntax highlighting...
|
||||||
|
// comments...
|
||||||
|
.replace(/(\(.*)-(.*\))/g, '<span class="comment">$1−$2</span>')
|
||||||
|
.replace(/(\([^\)]*\))/g, '<span class="comment">$1</span>')
|
||||||
|
.replace(/(\s*--.*\n)/g, '<span class="comment">$1</span>')
|
||||||
|
/*
|
||||||
|
Object.keys(NAMESPACE).forEach(function(k){
|
||||||
|
bootstrap = bootstrap.replace(
|
||||||
|
RegExp('('+k
|
||||||
|
.replace('&', '&')
|
||||||
|
.replace('<', '<')
|
||||||
|
.replace('>', '>')
|
||||||
|
.replace(/([\|\[\]\.\*\/\\\?\+\-])/g, '\\$1')+')', 'g'),
|
||||||
|
'<span class="word">$1</span>')
|
||||||
|
})
|
||||||
|
*/
|
||||||
|
document.getElementById('bootstrap').innerHTML='<pre>'+bootstrap+'</pre>'
|
||||||
|
|
||||||
document.getElementById('console')
|
document.getElementById('console')
|
||||||
.addEventListener("keyup", function(e) {
|
.addEventListener("keyup", function(e) {
|
||||||
|
|||||||
@ -396,7 +396,7 @@ var NAMESPACE = {
|
|||||||
|
|
||||||
// NOTE: hate how JS handles multi-line strings...
|
// NOTE: hate how JS handles multi-line strings...
|
||||||
var BOOTSTRAP = [
|
var BOOTSTRAP = [
|
||||||
'(------------------------------------------------------------------------------',
|
'-------------------------------------------------------------------------------',
|
||||||
'',
|
'',
|
||||||
' Slang is a simple and complete [S]tack [lang]uage.',
|
' Slang is a simple and complete [S]tack [lang]uage.',
|
||||||
'',
|
'',
|
||||||
@ -500,7 +500,7 @@ var BOOTSTRAP = [
|
|||||||
' NOTE: this notation is currently used as a means to documenting words and is',
|
' NOTE: this notation is currently used as a means to documenting words and is',
|
||||||
' not interpreted in any way.',
|
' not interpreted in any way.',
|
||||||
'',
|
'',
|
||||||
'------------------------------------------------------------------------------)',
|
'-------------------------------------------------------------------------------',
|
||||||
'--',
|
'--',
|
||||||
'-- With that out of the way, let\'s start with the bootstrap...',
|
'-- With that out of the way, let\'s start with the bootstrap...',
|
||||||
'--',
|
'--',
|
||||||
@ -570,9 +570,10 @@ var BOOTSTRAP = [
|
|||||||
'-- Here is an infix operator example...',
|
'-- Here is an infix operator example...',
|
||||||
'-- :: + ( a | b -- c | ) [ \\ exec 2 0 _swapN \\ exec \\ add 2 1 _swapN ]',
|
'-- :: + ( a | b -- c | ) [ \\ exec 2 0 _swapN \\ exec \\ add 2 1 _swapN ]',
|
||||||
'-- now let\'s make a meta function to make things shorter...',
|
'-- now let\'s make a meta function to make things shorter...',
|
||||||
'-- first the helper...',
|
':: infix: ( | op word -- | ) [',
|
||||||
':: _infix ( op word -- ) [',
|
' [',
|
||||||
' -- format the word definition...',
|
' -- format the word definition...',
|
||||||
|
' -- NAME WORD -> :: NAME WORD',
|
||||||
' s2b \\ :: -3 before b2s',
|
' s2b \\ :: -3 before b2s',
|
||||||
'',
|
'',
|
||||||
' -- our template...',
|
' -- our template...',
|
||||||
@ -580,14 +581,13 @@ var BOOTSTRAP = [
|
|||||||
' [ \\ exec 2 0 _swapN',
|
' [ \\ exec 2 0 _swapN',
|
||||||
' -- exec the right side and arragne the args for WORD...',
|
' -- exec the right side and arragne the args for WORD...',
|
||||||
' \\ exec \\ WORD 2 1 _swapN ] clone',
|
' \\ exec \\ WORD 2 1 _swapN ] clone',
|
||||||
' -- replace WORD with the actual target word...',
|
' -- get the WORD and insert it into the template above (opsition 8)...',
|
||||||
' swap 8 to',
|
' swap 8 to',
|
||||||
'',
|
'',
|
||||||
' -- push to code / run',
|
' -- push to code / run',
|
||||||
' 3 0 _swapN ]',
|
' 3 0 _swapN ',
|
||||||
'',
|
' -- swap the arguments and the code to be executed...',
|
||||||
'-- formatter for the _infix word...',
|
' ] \\ exec 2 2 _swapN ]',
|
||||||
':: infix: ( | op word -- | ) [ \\ _infix 1 2 _swapN ]',
|
|
||||||
'',
|
'',
|
||||||
'-- Now making a word/2 an infix operator is trivial...',
|
'-- Now making a word/2 an infix operator is trivial...',
|
||||||
'-- NOTE: these are at this point stupid and do not support priorities...',
|
'-- NOTE: these are at this point stupid and do not support priorities...',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user