koka-lang / koka

Koka language compiler and interpreter
http://koka-lang.org
Other
3.26k stars 162 forks source link

For my syntax file, keywords lists #228

Closed Alexey-T closed 2 years ago

Alexey-T commented 2 years ago

I am making CudaText (free app) lexer for Koka. I found keyword list + special word list at https://koka-lang.github.io/koka/doc/book.html but they are not complete!

I found more words which seem like keywords. please correct me.

1) keywords list which my lexer colors in bold-black.

abstract
alias
as
con
control
ctl
effect
elif
else
exists
extern
fn
forall
foreach
fun
function
handle
handler
hiding
if
import
in
infix
infixl
infixr
interface
mask
match
module
named
override
prefix
private
pub
public
qualified
rcontrol
return
some
struct
then
type
unsafe
val
var
with
yield

2) std id words which my lexer colors in blue

behind
c
co
cs
extend
external
file
import
include
inline
js
linear
noinline
open
print
println
raw
rec
reference
use
using
value

3) type-like names, syntax colors in purple

bool
char
Cons
div
double
exn
False
float
int
int16
int32
int64
int8
io
Just
list
maybe
ndet
Nil
Nothing
pure
string
total
True
uint16
uint32
uint64
uint8

Screenshot from 2022-01-01 04-58-22

daanx commented 2 years ago

Very cool @Alexey-T :-)
Koka is still in flux so the docs can be behind (although I try to keep up). The grammar is developed from the flex&yacc grammar so the full list of keywords is there, see here. Make sure to look in the dev branch as I recently updated many things.

The lexer.lex contains the reserved word list. The words that have a token like ID_xxx are not reserved but have special meaning in a certain context, (like rec and inline).

Words like print etc are just standard functions from std/core.kk and std/core/types.kk. You may go through there to get a list of standard types and functions although it may or may not be a good idea to highlight those as it won't work with user defined types?

Great CudaText is in ObjectPascal -- my first programming language :-)

(also, in support/vscode/koka.language-koka/syntaxes/koka.json is the most advanced highlighter for vscode but it may be a bit overkill as it highlights types by tracking brace nesting which may not be possible in all syntax highlighters :-( )