Changeset 210

Show
Ignore:
Timestamp:
04/06/07 20:38:08 (1 year ago)
Author:
ingy
Message:
 r3758@dhcp199:  ingy | 2007-04-05 11:40:18 +0900
 more parser refo
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/core/Spork/lib/Spork/Parser.pm

    r205 r210  
    11package Spork::Parser; 
    2 use strict; 
    3 use warnings; 
    42use base 'Document::Parser'; 
    5 use XXX; 
    63 
    74my $ALPHANUM = '\p{Letter}\p{Number}\pM'; 
     
    2421    { 
    2522        top => { 
    26             contains => $all_blocks, 
     23            blocks => $all_blocks, 
    2724        }, 
    2825        center => { 
    29             contains => $all_blocks, 
     26            blocks => $all_blocks, 
    3027            match => qr/^\.center\n(.*?\n)(?:.center\n|\z)\n?/s, 
    3128        }, 
    3229        indent => { 
    33             contains => $all_blocks, 
     30            blocks => $all_blocks, 
    3431            match => qr/^((?m:^>+.*\n)+\n?)/, 
    3532        }, 
     
    3835        }, 
    3936        p => { 
    40             contains => $all_phrases, 
     37            phrases => $all_phrases, 
    4138            match => qr/^(((?!>).*\S.*\n)+)(?m:^\s*\n)*/, 
    4239        }, 
    4340        ul => { 
    44             contains => [qw(ul li)], 
     41            blocks => [qw(ul li)], 
    4542            match => qr/^((?m:^\*+ .*\n)+)\n*/, 
    4643        }, 
    4744        li => { 
    48             contains => $all_phrases, 
     45            phrases => $all_phrases, 
    4946            match => qr/(.*)\n/, 
    5047        }, 
    5148        h2 => { 
    52             contains => $all_phrases, 
     49            phrases => $all_phrases, 
    5350            match => qr/^={2}\s+(.*?)\s*\n+/, 
    5451        }, 
    5552        b => { 
    56             contains => $all_phrases, 
    57             match => [ 
    58         qr/((?:^|(?<=[^${ALPHANUM}\*]))\*\S[^\*]*\*(?=[^{$ALPHANUM}\*]|\z))/, 
     53            phrases => $all_phrases, 
     54            match => [ 
     55                qr/( 
     56                    (?:^|(?<=[^${ALPHANUM}\*])) 
     57                    \*\S[^\*]*\* 
     58                    (?=[^{$ALPHANUM}\*]|\z) 
     59                   )/x, 
    5960                qr/(\{\*.*?\*\})/, 
    6061            ], 
     
    6263        i => { 
    6364            match => [ 
    64         qr/((?:^|(?<=[^${ALPHANUM}\/]))\/\S[^\/]*\/(?=[^{$ALPHANUM}\/]|\z))/, 
     65                qr/( 
     66                    (?:^|(?<=[^${ALPHANUM}\/])) 
     67                    \/\S[^\/]*\/ 
     68                    (?=[^{$ALPHANUM}\/]|\z) 
     69                   )/x, 
    6570                qr/(\{\/.*?\/\})/, 
    6671            ], 
     
    6873        tt => { 
    6974            match => [ 
    70         qr/((?:^|(?<=[^${ALPHANUM}`]))`\S[^`]*`(?=[^{$ALPHANUM}`]|\z))/, 
     75                qr/( 
     76                    (?:^|(?<=[^${ALPHANUM}`])) 
     77                    `\S[^`]*` 
     78                    (?=[^{$ALPHANUM}`]|\z) 
     79                   )/x, 
    7180                qr/(\{`.*?`\})/, 
    7281            ], 
     
    7483        hilite => { 
    7584            match => [ 
    76         qr/((?:^|(?<=[^${ALPHANUM}\|]))\|\S[^\|]*\|(?=[^{$ALPHANUM}\|]|\z))/, 
     85                qr/( 
     86                    (?:^|(?<=[^${ALPHANUM}\|])) 
     87                    \|\S[^\|]*\| 
     88                    (?=[^{$ALPHANUM}\|]|\z) 
     89                   )/x, 
    7790                qr/(\{\|.*?\|\})/, 
    7891            ], 
     
    168181package Spork::AST; 
    169182use base 'Document::AST'; 
    170 use XXX; 
    171183 
    172184sub insert { 
  • trunk/src/plugins/ingy/Document-Parser/lib/Document/Parser.pm

    r206 r210  
    22use strict; 
    33use warnings; 
    4 use XXX; 
    54 
    65#------------------------------------------------------------------------------- 
     
    3029    my $self = shift; 
    3130    my $container_type = shift; 
    32     my $types = $self->{grammar}{$container_type}{contains}; 
     31    my $types = $self->{grammar}{$container_type}{blocks}; 
    3332    while (my $length = length $self->{input}) { 
    3433        for my $type (@$types) { 
     
    5453    my $self = shift; 
    5554    my $container_type = shift; 
    56     my $types = $self->{grammar}{$container_type}{contains}; 
     55    my $types = $self->{grammar}{$container_type}{phrases}; 
    5756    while (length $self->{input}) { 
    5857        my $match; 
     
    197196 
    1981971; 
     198 
     199=head1 
  • trunk/test/spork-parser.t

    r204 r210  
    44use Spork::Parser; 
    55use Spork::Emitter::HTML; 
    6 use XXX; 
    76 
    87run_is spork => 'html';