Changeset 688ba8c5433984a45e6144f635295ac22207ba70

Show
Ignore:
Timestamp:
06/03/2008 01:26:29 PM (7 months ago)
Author:
mitchell <mitchell@frost.(none)>
git-committer:
mitchell <mitchell@frost.(none)> 1212524789 -0400
git-parent:

[02072fd3d017dbdad33892cc37d0be22c0446ca1]

git-author:
mitchell <mitchell@frost.(none)> 1212524789 -0400
Message:

Cleaned up HTML and RHML parsers.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ext/ohcount_native/ragel_parsers/html.rl

    r42afa2b r688ba8c  
    8989 
    9090  html_css_entry = '<' /style/i [^>]+ :>> 'text/css' [^>]+ '>' @code; 
    91   html_css_outry = '</' /style/i ws_or_inl* '>' @code; 
     91  html_css_outry = '</' /style/i ws_or_inl* '>' @check_blank_outry @code; 
    9292  html_css_line := |* 
    93     html_css_outry @{ p = ts; fgoto html_line; }; 
     93    html_css_outry @{ p = ts; fret; }; 
    9494    # unmodified CSS patterns 
    9595    spaces      ${ entity = CSS_SPACE; } => css_ccallback; 
     
    101101 
    102102  html_js_entry = '<' /script/i [^>]+ :>> 'text/javascript' [^>]+ '>' @code; 
    103   html_js_outry = '</' /script/i ws_or_inl* '>' @code; 
     103  html_js_outry = '</' /script/i ws_or_inl* '>' @check_blank_outry @code; 
    104104  html_js_line := |* 
    105     html_js_outry @{ p = ts; fgoto html_line; }; 
     105    html_js_outry @{ p = ts; fret; }; 
    106106    # unmodified Javascript patterns 
    107107    spaces     ${ entity = JS_SPACE; } => js_ccallback; 
     
    114114  html_line := |* 
    115115    html_css_entry @{ entity = CHECK_BLANK_ENTRY; } @html_ccallback 
    116       @{ fgoto html_css_line; }; 
     116      @{ saw(CSS_LANG); } => { fcall html_css_line; }; 
    117117    html_js_entry @{ entity = CHECK_BLANK_ENTRY; } @html_ccallback 
    118       @{ fgoto html_js_line; }; 
     118      @{ saw(JS_LANG); } => { fcall html_js_line; }; 
    119119    # standard HTML patterns 
    120120    spaces       ${ entity = HTML_SPACE; } => html_ccallback; 
  • ext/ohcount_native/ragel_parsers/rhtml.rl

    re92c8a6 r688ba8c  
    5858 
    5959  rhtml_comment := ( 
    60     #'<!--' @comment ( 
    61       newline %{ entity = INTERNAL_NL; } %rhtml_ccallback 
    62       | 
    63       ws 
    64       | 
    65       ^(space | [\-<]) @comment 
    66       | 
    67       '<' '%' @{ saw(RUBY_LANG); fcall rhtml_ruby_line; } 
    68       | 
    69       '<' !'%' 
    70     )* :>> '-->' @comment @{ fgoto rhtml_line; }; 
     60    newline %{ entity = INTERNAL_NL; } %rhtml_ccallback 
     61    | 
     62    ws 
     63    | 
     64    ^(space | [\-<]) @comment 
     65    | 
     66    '<' '%' @{ saw(RUBY_LANG); fcall rhtml_ruby_line; } 
     67    | 
     68    '<' !'%' 
     69  )* :>> '-->' @comment @{ fgoto rhtml_line; }; 
    7170 
    7271  rhtml_sq_str := ( 
    73     #'\'' @code ( 
    74       newline %{ entity = INTERNAL_NL; } %rhtml_ccallback 
    75       | 
    76       ws 
    77       | 
    78       [^\r\n\f\t '\\<] @code 
    79       | 
    80       '\\' nonnewline @code 
    81       | 
    82       '<' '%' @{ saw(RUBY_LANG); fcall rhtml_ruby_line; } 
    83       | 
    84       '<' !'%' 
    85     )* '\'' @{ fgoto rhtml_line; }; 
     72    newline %{ entity = INTERNAL_NL; } %rhtml_ccallback 
     73    | 
     74    ws 
     75    | 
     76    [^\r\n\f\t '\\<] @code 
     77    | 
     78    '\\' nonnewline @code 
     79    | 
     80    '<' '%' @{ saw(RUBY_LANG); fcall rhtml_ruby_line; } 
     81    | 
     82    '<' !'%' 
     83  )* '\'' @{ fgoto rhtml_line; }; 
    8684  rhtml_dq_str := ( 
    87     #'"' @code ( 
    88       newline %{ entity = INTERNAL_NL; } %rhtml_ccallback 
    89       | 
    90       ws 
    91       | 
    92       [^\r\n\f\t "\\<] @code 
    93       | 
    94       '\\' nonnewline @code 
    95       | 
    96       '<' '%' @{ saw(RUBY_LANG); fcall rhtml_ruby_line; } 
    97       | 
    98       '<' !'%' 
    99     )* '"' @{ fgoto rhtml_line; }; 
    100   #rhtml_string = rhtml_sq_str | rhtml_dq_str; 
     85    newline %{ entity = INTERNAL_NL; } %rhtml_ccallback 
     86    | 
     87    ws 
     88    | 
     89    [^\r\n\f\t "\\<] @code 
     90    | 
     91    '\\' nonnewline @code 
     92    | 
     93    '<' '%' @{ saw(RUBY_LANG); fcall rhtml_ruby_line; } 
     94    | 
     95    '<' !'%' 
     96  )* '"' @{ fgoto rhtml_line; }; 
    10197 
    10298  ws_or_inl = (ws | newline @{ entity = INTERNAL_NL; } %rhtml_ccallback); 
    10399 
    104100  rhtml_css_entry = '<' /style/i [^>]+ :>> 'text/css' [^>]+ '>' @code; 
    105   rhtml_css_outry = '</' /style/i ws_or_inl* '>' @code; 
     101  rhtml_css_outry = '</' /style/i ws_or_inl* '>' @check_blank_outry @code; 
    106102  rhtml_css_line := |* 
    107     rhtml_css_outry @{ p = ts; fgoto rhtml_line; }; 
     103    rhtml_css_outry @{ p = ts; fret; }; 
    108104    # unmodified CSS patterns 
    109105    spaces      ${ entity = CSS_SPACE; } => css_ccallback; 
     
    115111 
    116112  rhtml_js_entry = '<' /script/i [^>]+ :>> 'text/javascript' [^>]+ '>' @code; 
    117   rhtml_js_outry = '</' /script/i ws_or_inl* '>' @code; 
     113  rhtml_js_outry = '</' /script/i ws_or_inl* '>' @check_blank_outry @code; 
    118114  rhtml_js_line := |* 
    119     rhtml_js_outry @{ p = ts; fgoto rhtml_line; }; 
     115    rhtml_js_outry @{ p = ts; fret; }; 
    120116    # unmodified Javascript patterns 
    121117    spaces     ${ entity = JS_SPACE; } => js_ccallback; 
     
    127123 
    128124  rhtml_ruby_entry = '<%' @code; 
    129   rhtml_ruby_outry = '%>' @reset_seen @code; 
     125  rhtml_ruby_outry = '%>' @check_blank_outry @code; 
    130126  rhtml_ruby_line := |* 
    131127    rhtml_ruby_outry @{ p = ts; fret; }; 
     
    140136  rhtml_line := |* 
    141137    rhtml_css_entry @{ entity = CHECK_BLANK_ENTRY; } @rhtml_ccallback 
    142       @{ fgoto rhtml_css_line; }; 
     138      @{ saw(CSS_LANG); } => { fcall rhtml_css_line; }; 
    143139    rhtml_js_entry @{ entity = CHECK_BLANK_ENTRY; } @rhtml_ccallback 
    144       @{ fgoto rhtml_js_line; }; 
     140      @{ saw(JS_LANG); } => { fcall rhtml_js_line; }; 
    145141    rhtml_ruby_entry @{ entity = CHECK_BLANK_ENTRY; } @rhtml_ccallback 
    146142      @{ saw(RUBY_LANG); } => { fcall rhtml_ruby_line; };