diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2003-04-24 19:17:03 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2003-04-24 19:17:03 +0000 |
commit | 662cfb91ccb8a61683790b76b643e966ac005e8d (patch) | |
tree | 1686343a0aabb0b12c8ccd510b7c81103995f203 /perl_checker.src/lexer.mll | |
parent | a8c17fafaed296f970c218cec4ffe3ba72a9cb7d (diff) | |
download | perl-MDK-Common-662cfb91ccb8a61683790b76b643e966ac005e8d.tar perl-MDK-Common-662cfb91ccb8a61683790b76b643e966ac005e8d.tar.gz perl-MDK-Common-662cfb91ccb8a61683790b76b643e966ac005e8d.tar.bz2 perl-MDK-Common-662cfb91ccb8a61683790b76b643e966ac005e8d.tar.xz perl-MDK-Common-662cfb91ccb8a61683790b76b643e966ac005e8d.zip |
- handle empty prototypes
- check number of parameters in method calls
(ignoring empty overloaded methods)
- allow non-empty prototypes for methods not using @_
Diffstat (limited to 'perl_checker.src/lexer.mll')
-rw-r--r-- | perl_checker.src/lexer.mll | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/perl_checker.src/lexer.mll b/perl_checker.src/lexer.mll index 59e348e..044c562 100644 --- a/perl_checker.src/lexer.mll +++ b/perl_checker.src/lexer.mll @@ -39,6 +39,7 @@ type raw_token = | RAW_IDENT of (string option * string * raw_pos) | RAW_IDENT_PAREN of (string option * string * raw_pos) | ARRAYLEN_IDENT of (string option * string * raw_pos) + | SUB_WITH_PROTO of (string * raw_pos) | FUNC_DECL_WITH_PROTO of (string * string * raw_pos) | IF of raw_pos | ELSIF of raw_pos | ELSE of raw_pos | UNLESS of raw_pos | DO of raw_pos | WHILE of raw_pos | UNTIL of raw_pos | MY_OUR of (string * raw_pos) | CONTINUE of raw_pos | SUB of raw_pos @@ -96,6 +97,7 @@ let rec raw_token_to_pos_and_token spaces = function | RAW_IDENT(kind, name, pos) -> pos, Parser.RAW_IDENT(new_any M_special (kind, name) spaces pos) | RAW_IDENT_PAREN(kind, name, pos) -> pos, Parser.RAW_IDENT_PAREN(new_any M_special (kind, name) spaces pos) | ARRAYLEN_IDENT(kind, name, pos) -> pos, Parser.ARRAYLEN_IDENT(new_any M_special (kind, name) spaces pos) + | SUB_WITH_PROTO(proto, pos) -> pos, Parser.SUB_WITH_PROTO(new_any M_special proto spaces pos) | FUNC_DECL_WITH_PROTO(name, proto, pos) -> pos, Parser.FUNC_DECL_WITH_PROTO(new_any M_special (name, proto) spaces pos) | NEW(pos) -> pos, Parser.NEW(new_any M_special () spaces pos) @@ -584,12 +586,16 @@ rule token = parse | "\\" ' '* '(' { putback lexbuf 1; REF(pos lexbuf) } +| "sub(" [ '$' '@' '\\' '&' ';' '%' ]* ')' { + SUB_WITH_PROTO(skip_n_char_ 4 1 (lexeme lexbuf), pos lexbuf) + } + | "sub" ' '+ ident ' '* '(' [ '$' '@' '\\' '&' ';' '%' ]* ')' { (* bloody prototypes, must be caught especially otherwise "($)" is badly tokenized *) (* and alas "($@)" is both valid as an expression and a prototype *) let s = lexeme lexbuf in let ident_start = non_index_from s 3 ' ' in - + let proto_start = String.index_from s ident_start '(' in let ident_end = non_rindex_from s (proto_start-1) ' ' in let ident = String.sub s ident_start (ident_end - ident_start + 1) in |