Skip to content

Commit

Permalink
Factor out file/line pos parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Oct 11, 2012
1 parent 9bec898 commit e2daca3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/Debugger/UI/CommandLine.pm
Expand Up @@ -195,6 +195,11 @@ my class SourceFile {
}
}

# File and line position.
my regex flpos {
[$<file>=[<-[:]>+] ':']? $<line>=[\d+]
}

# Holds the current state of the debugger.
my class DebugState {
my enum RunMode <Step StepOver StepOut RunToThrowOrBreakpoint RunToUnhandledOrBreakpoint>;
Expand Down Expand Up @@ -330,7 +335,7 @@ my class DebugState {
take $c unless $c eq "\r";
}
}

method issue_prompt($ctx, $cur_file, $from = 0, $to = 0) {
ENTER $in_prompt = True;
LEAVE $in_prompt = False;
Expand Down Expand Up @@ -427,8 +432,8 @@ my class DebugState {
say colored('No current exception', 'red');
}
}
when /^ 'bp' <.ws> 'add' <.ws> [$<file>=[<-[:]>+] ':']? $<line>=[\d+] $/ {
self.add_breakpoint($<file> ?? ~$<file> !! $cur_file, +$<line>);
when /^ 'bp' <.ws> 'add' <.ws> <p=&flpos> $/ {
self.add_breakpoint($<p><file> ?? ~$<p><file> !! $cur_file, +$<p><line>);
}
when /^ 'bp' <.ws> 'list' $/ {
for %breakpoints.kv -> $file, @lines {
Expand All @@ -438,8 +443,8 @@ my class DebugState {
}
}
}
when /^ 'bp' <.ws> 'rm' <.ws> [$<file>=[<-[:]>+] ':']? $<line>=[\d+] $/ {
self.remove_breakpoint($<file> ?? ~$<file> !! $cur_file, +$<line>);
when /^ 'bp' <.ws> 'rm' <.ws> <p=&flpos> $/ {
self.remove_breakpoint($<p><file> ?? ~$<p><file> !! $cur_file, +$<p><line>);
}
when /^ 'bp' <.ws> 'rm' <.ws> 'all' $/ {
%breakpoints = ();
Expand Down

0 comments on commit e2daca3

Please sign in to comment.