<commit_before>=head1 TITLE

P6Regex - compiler and parser for Perl 6 regex

=over 4

=item C<compile_p6regex(PMC source, PMC adverbs :slurpy :named)>

Return the result of compiling C<source> according to Perl 6
regex syntax and the associated C<adverbs>.  Normally this
function is obtained using C<compreg 'PGE::P6Regex'> instead
of calling it directly.

Returns the compiled regular expression.  If a C<target>
named parameter is supplied, then it will return the parse tree
(target='parse'), the expression tree (target='exp'),
or the resulting PIR code (target='PIR').

=cut

.namespace [ 'PGE::P6Regex' ]
 
.sub 'compile_p6regex'
    .param pmc source
    .param pmc args            :slurpy
    .param pmc adverbs         :slurpy :named

    unless null adverbs goto adverbs_1
    adverbs = new .Hash

  adverbs_1:
    $I0 = exists adverbs['grammar']
    if $I0 goto adverbs_2
    unless args goto adverbs_1a
    $S0 = shift args
    adverbs['grammar'] = $S0
    goto adverbs_2
  adverbs_1a:
    adverbs['grammar'] = 'PGE::Regex'
  adverbs_2:
    $I0 = exists adverbs['name']
    if $I0 goto adverbs_3
    unless args goto adverbs_2a
    $S0 = shift args
    adverbs['name'] = $S0
    goto adverbs_3
  adverbs_2a:
    adverbs['name'] = '_regex'
  adverbs_3:
    $I0 = exists adverbs['lang']
    if $I0 goto adverbs_3
    adverbs['lang'] = 'PIR'
  adverbs_4:
    $I0 = exists adverbs['ignorecase']
    if $I0 goto adverbs_4
    $I0 = adverbs['i']
    adverbs['ignorecase'] = $I0
  adverbs_5:
    $I0 = exists adverbs['words']
    if $I0 goto adverbs_5
    $I0 = adverbs['w']
    adverbs['words'] = $I0
  adverbs_6:

    .local string target
    target = adverbs['target']

    ##   If we're passed the results of a previous parse,  use it.
    .local pmc match, exp
    $I0 = isa source, 'PGE::Match'
    if $I0 == 0 goto parse<commit_msg>[PGE]: Fixed bug with handling :words adverb.  allison++<commit_after>=head1 TITLE

P6Regex - compiler and parser for Perl 6 regex

=over 4

=item C<compile_p6regex(PMC source, PMC adverbs :slurpy :named)>

Return the result of compiling C<source> according to Perl 6
regex syntax and the associated C<adverbs>.  Normally this
function is obtained using C<compreg 'PGE::P6Regex'> instead
of calling it directly.

Returns the compiled regular expression.  If a C<target>
named parameter is supplied, then it will return the parse tree
(target='parse'), the expression tree (target='exp'),
or the resulting PIR code (target='PIR').

=cut

.namespace [ 'PGE::P6Regex' ]
 
.sub 'compile_p6regex'
    .param pmc source
    .param pmc args            :slurpy
    .param pmc adverbs         :slurpy :named

    unless null adverbs goto set_adverbs
    adverbs = new .Hash

  set_adverbs:
    $I0 = exists adverbs['grammar']
    if $I0 goto with_grammar
    unless args goto adverb_grammar_1
    $S0 = shift args
    adverbs['grammar'] = $S0
    goto with_grammar
  adverb_grammar_1:
    adverbs['grammar'] = 'PGE::Regex'
  with_grammar:
    $I0 = exists adverbs['name']
    if $I0 goto with_name
    unless args goto adverb_name_1
    $S0 = shift args
    adverbs['name'] = $S0
    goto with_name
  adverb_name_1:
    adverbs['name'] = '_regex'
  with_name:
    $I0 = exists adverbs['lang']
    if $I0 goto with_lang
    adverbs['lang'] = 'PIR'
  with_lang:
    $I0 = exists adverbs['ignorecase']
    if $I0 goto with_ignorecase
    $I0 = adverbs['i']
    adverbs['ignorecase'] = $I0
  with_ignorecase:
    $I0 = exists adverbs['words']
    if $I0 goto with_words
    $I0 = adverbs['w']
    adverbs['words'] = $I0
  with_words:

    .local string target
    target = adverbs['target']

    ##   If we're passed the results of a previous parse,  use it.
    .local pmc match, exp
    $I0 = isa source, 'PGE::Match'
    if $I0 == 0 goto parse
{'fraction_non_alphanumeric': 0.10561143462149285, 'fraction_numerical': 0.02170460561143462, 'mean_word_length': 3.198888888888889, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3686226', 'n_tokens_mistral': 1401, 'n_tokens_neox': 1370, 'n_words': 428}