mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-23 04:19:27 +01:00
Plugins/Plang: fix parse errors not showing up
This commit is contained in:
parent
c8a1b2b886
commit
0dedbed2d7
@ -70,11 +70,21 @@ sub cmd_plang {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# run an embedded plang program
|
# run an embedded plang program
|
||||||
|
# TODO this is just a proof-of-concept at this stage; 90% of this stuff will be moved into Plang::Interpreter
|
||||||
sub run {
|
sub run {
|
||||||
my ($self, $code) = @_;
|
my ($self, $code) = @_;
|
||||||
|
|
||||||
|
# reset output buffer
|
||||||
|
$self->{output} = ""; # collect output of the embedded Plang program
|
||||||
|
|
||||||
# parse the code into an ast
|
# parse the code into an ast
|
||||||
my $ast = $self->{plang}->parse_string($code);
|
my $ast = $self->{plang}->parse_string($code);
|
||||||
|
|
||||||
|
# check for parse errors
|
||||||
|
my $errors = $self->{plang}->handle_parse_errors;
|
||||||
|
return ['ERROR', $errors] if defined $errors;
|
||||||
|
|
||||||
|
# return if no program
|
||||||
return if not defined $ast;
|
return if not defined $ast;
|
||||||
|
|
||||||
# create a new environment for a Plang program
|
# create a new environment for a Plang program
|
||||||
@ -84,7 +94,6 @@ sub run {
|
|||||||
my $program = $ast->[0];
|
my $program = $ast->[0];
|
||||||
my $statements = $program->[1];
|
my $statements = $program->[1];
|
||||||
|
|
||||||
$self->{output} = ""; # collect output of the embedded Plang program
|
|
||||||
my $result; # result of the final statement
|
my $result; # result of the final statement
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
|
Loading…
Reference in New Issue
Block a user