Kind/book/Kind.Oper.parser.kind2
Victor Taelin 85ad65b026 use-notation
Now, there are two local binders:

let x = ...
use x = ...

The 'let' binder will create a local definition, type-check it, and
assign a name to it. When compiled, it will create 'dup' nodes.

The 'use' binder is just an alias. It will not bind a new variable, and,
when compiled, will create inline copies. Also, for type-checking, it
allows creating aliases that are definitionaly equal for the checker.
2024-03-08 17:39:37 -03:00

66 lines
1.8 KiB
Plaintext

Kind.Oper.parser
: (Parser Kind.Oper)
= use TRY = (List.cons (Parser.Guard Kind.Oper))
use END = (List.nil (Parser.Guard Kind.Oper))
use OP2 = {λsym λoper
(Parser.Guard.text
Kind.Oper
sym
(Parser.bind
Unit
Kind.Oper
(Parser.text sym)
λx (Parser.pure Kind.Oper oper)
)
)
:∀(sym: String) ∀(oper: Kind.Oper)
(Parser.Guard Kind.Oper)}
(Parser.variant
Kind.Oper
(TRY
(OP2 "+" Kind.Oper.add)
(TRY
(OP2 "*" Kind.Oper.mul)
(TRY
(OP2 "-" Kind.Oper.sub)
(TRY
(OP2 "/" Kind.Oper.div)
(TRY
(OP2 "%" Kind.Oper.mod)
(TRY
(OP2 "==" Kind.Oper.eq)
(TRY
(OP2 "!=" Kind.Oper.ne)
(TRY
(OP2 "<=" Kind.Oper.lte)
(TRY
(OP2 ">=" Kind.Oper.gte)
(TRY
(OP2 "<<" Kind.Oper.lsh)
(TRY
(OP2 ">>" Kind.Oper.rsh)
(TRY
(OP2 "<" Kind.Oper.lt)
(TRY
(OP2 ">" Kind.Oper.gt)
(TRY
(OP2 "&" Kind.Oper.and)
(TRY
(OP2 "|" Kind.Oper.or)
(TRY (OP2 "^" Kind.Oper.xor) END)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)