Changeset 0085604032fa0e94dcf0e8ea91a13bfec7506dc8

Show
Ignore:
Timestamp:
06/23/2008 01:03:45 PM (2 months ago)
Author:
mitchell <mitchell@frost.(none)>
git-committer:
mitchell <mitchell@frost.(none)> 1214251425 -0400
git-parent:

[5b7fcf9f301963803ed8fa27278591f685abf682]

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

Fixed parsers that could succomb to segfaulting.
It happens for parsers can cannot detect all language entities yet such as
HEREDOCs, or ones that have complicated entities.
I've ignored the other parsers that cover all of their language entities because
ohcount will only parser syntactically correct code.

Files:

Legend:

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

    rb34530c r0085604  
    5252 
    5353  lua_long_comment = 
    54     '--' @comment ('[' >lua_long_ec_res '='* $lua_long_ec_inc '[')
     54    '--' ('[' >lua_long_ec_res '='* $lua_long_ec_inc '[') @enqueue @comment
    5555      newline %{ entity = INTERNAL_NL; } %lua_ccallback 
    5656      | 
     
    5858      | 
    5959      (nonnewline - ws) @comment 
    60     )* :>> (']' '='* $lua_long_ec_dec ']' when { equal_count == 0 })
     60    )* :>> (']' '='* $lua_long_ec_dec ']' when { equal_count == 0 }) @commit
    6161  lua_line_comment = '--' @comment nonnewline*; 
    6262  lua_comment = lua_long_comment | lua_line_comment; 
  • ext/ohcount_native/ragel_parsers/perl.rl

    rb354c6b r0085604  
    4747  perl_line_comment = '#' @comment nonnewline*; 
    4848  perl_block_comment = 
    49     '=' when starts_line @comment nonnewline+ ( 
    50       '=' when starts_line 'cut' @comment @{ fgoto perl_line; } 
     49    '=' when starts_line @enqueue @comment nonnewline+ ( 
     50      '=' when starts_line 'cut' @commit @comment @{ fgoto perl_line; } 
    5151      | 
    5252      newline %{ entity = INTERNAL_NL; } %perl_ccallback 
     
    5959 
    6060  perl_sq_str = 
    61     '\'' @code ( 
     61    '\'' @enqueue @code ( 
    6262      newline %{ entity = INTERNAL_NL; } %perl_ccallback 
    6363      | 
     
    6767      | 
    6868      '\\' nonnewline @code 
    69     )* '\'' @code; 
     69    )* '\'' @commit @code; 
    7070  perl_dq_str = 
    71     '"' @code ( 
     71    '"' @enqueue @code ( 
    7272      newline %{ entity = INTERNAL_NL; } %perl_ccallback 
    7373      | 
     
    7777      | 
    7878      '\\' nonnewline @code 
    79     )* '"' @code; 
     79    )* '"' @commit @code; 
    8080  perl_cmd_str = 
    81     '`' @code ( 
     81    '`' @enqueue @code ( 
    8282      newline %{ entity = INTERNAL_NL; } %perl_ccallback 
    8383      | 
     
    8787      | 
    8888      '\\' nonnewline @code 
    89     )* '`' @code; 
     89    )* '`' @commit @code; 
    9090  perl_regex = '/' ([^\r\n\f/\\] | '\\' nonnewline)* '/' @code; 
    9191  # TODO: heredoc detection 
  • ext/ohcount_native/ragel_parsers/php.rl

    r95e8eb5 r0085604  
    5757 
    5858  php_sq_str = 
    59     '\'' @code ( 
     59    '\'' @enqueue @code ( 
    6060      newline %{ entity = INTERNAL_NL; } %php_ccallback 
    6161      | 
     
    6565      | 
    6666      '\\' nonnewline @code 
    67     )* '\'' @code; 
     67    )* '\'' @commit @code; 
    6868  php_dq_str = 
    69     '"' @code ( 
     69    '"' @enqueue @code ( 
    7070      newline %{ entity = INTERNAL_NL; } %php_ccallback 
    7171      | 
     
    7575      | 
    7676      '\\' nonnewline @code 
    77     )* '"' @code; 
     77    )* '"' @commit @code; 
    7878  # TODO: heredoc; see ruby.rl for details. 
    7979  php_string = php_sq_str | php_dq_str; 
  • ext/ohcount_native/ragel_parsers/shell.rl

    r0b4bd62 r0085604  
    4848 
    4949  shell_sq_str = 
    50     '\'' @code ( 
     50    '\'' @enqueue @code ( 
    5151      newline %{ entity = INTERNAL_NL; } %shell_ccallback 
    5252      | 
     
    5656      | 
    5757      '\\' nonnewline @code 
    58     )* '\''
     58    )* '\'' @commit
    5959  shell_dq_str = 
    60     '"' @code ( 
     60    '"' @enqueue @code ( 
    6161      newline %{ entity = INTERNAL_NL; } %shell_ccallback 
    6262      | 
     
    6666      | 
    6767      '\\' nonnewline @code 
    68     )* '"'
     68    )* '"' @commit
    6969  # TODO: heredocs; see ruby.rl for details 
    7070  shell_string = shell_sq_str | shell_dq_str;