From 97d43a39c455e7d084aabd70ca7dca4e40566613 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sun, 26 Jul 2020 00:12:11 -0700 Subject: [PATCH] Update Plang (can now optionally specify return type and parameter types for functions) --- Plang | 2 +- Plugins/Plang.pm | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Plang b/Plang index aa55ffbd..41c7c3c5 160000 --- a/Plang +++ b/Plang @@ -1 +1 @@ -Subproject commit aa55ffbddbba567570beb77b6917d168ee9f6ab6 +Subproject commit 41c7c3c5c801f7b440a8c90502c77777585d7274 diff --git a/Plugins/Plang.pm b/Plugins/Plang.pm index db191679..236a674e 100644 --- a/Plugins/Plang.pm +++ b/Plugins/Plang.pm @@ -40,24 +40,29 @@ sub initialize { # register some PBot-specific built-in functions $self->{plang}->{interpreter}->add_builtin_function('factset', # parameters are [['param1 name', default arg], ['param2 name', default arg], ...] - [['channel', undef], ['keyword', undef], ['text', undef]], + [['String', 'channel', undef], ['String', 'keyword', undef], ['String', 'text', undef]], + 'String', # return type sub { $self->plang_builtin_factset(@_) }); $self->{plang}->{interpreter}->add_builtin_function('factget', - [['channel', undef], ['keyword', undef], ['meta', ['STRING', 'action']]], + [['String', 'channel', undef], ['String', 'keyword', undef], ['String', 'meta', ['STRING', 'action']]], + 'String', sub { $self->plang_builtin_factget(@_) }); $self->{plang}->{interpreter}->add_builtin_function('factappend', - [['channel', undef], ['keyword', undef], ['text', undef]], + [['String', 'channel', undef], ['String', 'keyword', undef], ['String', 'text', undef]], + 'String', sub { $self->plang_builtin_factappend(@_) }); $self->{plang}->{interpreter}->add_builtin_function('userget', - [['name', undef]], + [['String', 'name', undef]], + 'Map', sub { $self->plang_builtin_userget(@_) }); # override the built-in `print` function to send to our output buffer instead $self->{plang}->{interpreter}->add_builtin_function('print', - [['expr', undef], ['end', ['STRING', "\n"]]], + [['Any', 'expr', undef], ['String', 'end', ['STRING', "\n"]]], + 'Null', sub { $self->plang_builtin_print(@_) }); # register the `plang` command