3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-20 02:49:49 +01:00

Update Plang (can now optionally specify return type and parameter types for functions)

This commit is contained in:
Pragmatic Software 2020-07-26 00:12:11 -07:00
parent 7441f42967
commit 97d43a39c4
2 changed files with 11 additions and 6 deletions

2
Plang

@ -1 +1 @@
Subproject commit aa55ffbddbba567570beb77b6917d168ee9f6ab6 Subproject commit 41c7c3c5c801f7b440a8c90502c77777585d7274

View File

@ -40,24 +40,29 @@ sub initialize {
# register some PBot-specific built-in functions # register some PBot-specific built-in functions
$self->{plang}->{interpreter}->add_builtin_function('factset', $self->{plang}->{interpreter}->add_builtin_function('factset',
# parameters are [['param1 name', default arg], ['param2 name', default arg], ...] # 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(@_) }); sub { $self->plang_builtin_factset(@_) });
$self->{plang}->{interpreter}->add_builtin_function('factget', $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(@_) }); sub { $self->plang_builtin_factget(@_) });
$self->{plang}->{interpreter}->add_builtin_function('factappend', $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(@_) }); sub { $self->plang_builtin_factappend(@_) });
$self->{plang}->{interpreter}->add_builtin_function('userget', $self->{plang}->{interpreter}->add_builtin_function('userget',
[['name', undef]], [['String', 'name', undef]],
'Map',
sub { $self->plang_builtin_userget(@_) }); sub { $self->plang_builtin_userget(@_) });
# override the built-in `print` function to send to our output buffer instead # override the built-in `print` function to send to our output buffer instead
$self->{plang}->{interpreter}->add_builtin_function('print', $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(@_) }); sub { $self->plang_builtin_print(@_) });
# register the `plang` command # register the `plang` command