Skip to content

Commit

Permalink
For [GH #161] - extract_statement_list
Browse files Browse the repository at this point in the history
  • Loading branch information
hkoba committed Mar 21, 2019
1 parent ec304af commit c111555
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Lite/LanguageServer/SpecParser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ use warnings qw(FATAL all NONFATAL misc);
use File::AddInc;
use MOP4Import::Base::CLI_JSON -as_base;

sub extract_statement_list {
(my MY $self, my ($codeList)) = @_;
local $_;
my $wordRe = qr{[^\s{}]};
my $groupRe = qr{( \{ (?: (?> [^{}]+) | (?-1) )* \} )}x;
my $commentRe = qr{/\*\*\n(?:.*?)\*/\n?}sx;
my @result;
foreach (@$codeList) {
while (m{
\G(?<comment>$commentRe)?
(?<decl>(?:$wordRe+\s+)+)
(?<body> $groupRe )
}sgx) {
push @result, [$+{decl}, $+{comment}, $+{body}];
}
}
@result;
}

# Lite/LanguageServer/SpecParser.pm --flatten --output=raw extract_codeblock typescript specification.md
sub extract_codeblock {
(my MY $self, my $langId, local @ARGV) = @_;
Expand Down

0 comments on commit c111555

Please sign in to comment.