tokay 0.6.13

Tokay is a programming language designed for ad-hoc parsing.
Documentation
#testmode:repl

# Tests for calling parselet without arguments
f : @{ 3 || 2 }

f
f()
f(1)
f(1, 2)
f(x = 2)
f(1, y=3)

# Tests for calling single argument parselet

f : @x { x * x }

f
f()
f(4)
f(1, 2)
f(x=7)
f(1, y=2)
f(x=8, y=9)

# Tests for calling mutli-argument parselet with wrong arguments counts

f : @a, b=2, c { a b c }

f
f()
f(1)
f(1, 2)
f(1, 2, 3)
f(1, c=2, 3)
f(1, c=2, b=3)
f(1, 2, 3, 4)
f(c=10, d=3, e=10)
f(1, c=10, d=3)
f(1, c=10, d=3, e=7)

#---

#3
#3
#ERR:Line 1, column 1: f() doesn't accept any arguments (1 given)
#ERR:Line 1, column 1: f() doesn't accept any arguments (2 given)
#ERR:Line 1, column 1: f() doesn't accept named argument 'x'
#ERR:Line 1, column 1: f() doesn't accept any arguments (1 given)

#<parselet f>
#ERR:Line 1, column 1: f() expected argument 'x'
#16
#ERR:Line 1, column 1: f() takes exactly one argument (2 given)
#49
#ERR:Line 1, column 1: f() doesn't accept named argument 'y'
#ERR:Line 1, column 1: f() doesn't accept named argument 'y'

#<parselet f>
#ERR:Line 1, column 1: f() expected argument 'a'
#ERR:Line 1, column 1: f() expected argument 'c'
#ERR:Line 1, column 1: f() expected argument 'c'
#(1, 2, 3)
#ERR:Line 1, column 1: Sequencial arguments need to be specified before named arguments.
#(1, 3, 2)
#ERR:Line 1, column 1: f() expected at most 3 arguments (4 given)
#ERR:Line 1, column 1: f() expected argument 'a'
#ERR:Line 1, column 1: f() doesn't accept named argument 'd'
#ERR:Line 1, column 1: f() doesn't accept named arguments (2 given)