diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2003-04-13 10:33:18 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2003-04-13 10:33:18 +0000 |
commit | c7e1843b482a90760ecb167a571916e74b90f526 (patch) | |
tree | b8a242b0b9b41dc2c3424285f942d2059fff5cea /perl_checker.src/lexer.mll | |
parent | 08643b9b36be4d94d44097bce9436abf6dccdf85 (diff) | |
download | perl-MDK-Common-c7e1843b482a90760ecb167a571916e74b90f526.tar perl-MDK-Common-c7e1843b482a90760ecb167a571916e74b90f526.tar.gz perl-MDK-Common-c7e1843b482a90760ecb167a571916e74b90f526.tar.bz2 perl-MDK-Common-c7e1843b482a90760ecb167a571916e74b90f526.tar.xz perl-MDK-Common-c7e1843b482a90760ecb167a571916e74b90f526.zip |
use new types to have stricter type checking (prior to adding maybe_context)
Diffstat (limited to 'perl_checker.src/lexer.mll')
-rw-r--r-- | perl_checker.src/lexer.mll | 200 |
1 files changed, 101 insertions, 99 deletions
diff --git a/perl_checker.src/lexer.mll b/perl_checker.src/lexer.mll index d011ef1..47e0f7a 100644 --- a/perl_checker.src/lexer.mll +++ b/perl_checker.src/lexer.mll @@ -53,6 +53,8 @@ type raw_token = and raw_interpolated_string = (string * raw_token list) list +let new_any any spaces pos = { any = any ; spaces = spaces ; pos = pos } + let rec concat_bareword_paren accu = function | PRINT(s, pos1) :: PAREN(pos2) :: l | BAREWORD(s, pos1) :: PAREN(pos2) :: l -> @@ -63,105 +65,105 @@ let rec concat_bareword_paren accu = function | e :: l -> concat_bareword_paren (e :: accu) l let rec raw_token_to_pos_and_token spaces = function - | NUM(s, pos) -> pos, Parser.NUM(s, (spaces, pos)) - | RAW_STRING(s, pos) -> pos, Parser.RAW_STRING(s, (spaces, pos)) - | RAW_HERE_DOC(r, pos) -> pos, Parser.RAW_HERE_DOC(!r, (spaces, pos)) - | STRING(l, pos) -> pos, Parser.STRING(raw_interpolated_string_to_tokens l, (spaces, pos)) - | COMMAND_STRING(l, pos) -> pos, Parser.COMMAND_STRING(raw_interpolated_string_to_tokens l, (spaces, pos)) - | QR_PATTERN(s, opts, pos) -> pos, Parser.QR_PATTERN((raw_interpolated_string_to_tokens s, opts), (spaces, pos)) - | PATTERN(s, opts, pos) -> pos, Parser.PATTERN((raw_interpolated_string_to_tokens s, opts), (spaces, pos)) - | PATTERN_SUBST(from, to_, opts, pos) -> pos, Parser.PATTERN_SUBST((raw_interpolated_string_to_tokens from, raw_interpolated_string_to_tokens to_, opts), (spaces, pos)) - | HERE_DOC(l, pos) -> pos, Parser.HERE_DOC((raw_interpolated_string_to_tokens (fst !l), snd !l), (spaces, pos)) - | BAREWORD(s, pos) -> pos, Parser.BAREWORD(s, (spaces, pos)) - | BAREWORD_PAREN(s, pos) -> pos, Parser.BAREWORD_PAREN(s, (spaces, pos)) - | REVISION(s, pos) -> pos, Parser.REVISION(s, (spaces, pos)) - | PERL_CHECKER_COMMENT(s, pos) -> pos, Parser.PERL_CHECKER_COMMENT(s, (spaces, pos)) - | PO_COMMENT(s, pos) -> pos, Parser.PO_COMMENT(s, (spaces, pos)) - | POD(s, pos) -> pos, Parser.POD(s, (spaces, pos)) - | LABEL(s, pos) -> pos, Parser.LABEL(s, (spaces, pos)) - | PRINT(s, pos) -> pos, Parser.PRINT(s, (spaces, pos)) - | PRINT_TO_STAR(s, pos) -> pos, Parser.PRINT_TO_STAR(s, (spaces, pos)) - | PRINT_TO_SCALAR(s, pos) -> pos, Parser.PRINT_TO_SCALAR(s, (spaces, pos)) - | QUOTEWORDS(s, pos) -> pos, Parser.QUOTEWORDS(s, (spaces, pos)) - | COMPACT_HASH_SUBSCRIPT(s, pos) -> pos, Parser.COMPACT_HASH_SUBSCRIPT(s, (spaces, pos)) - | SCALAR_IDENT(kind, name, pos) -> pos, Parser.SCALAR_IDENT((kind, name), (spaces, pos)) - | ARRAY_IDENT(kind, name, pos) -> pos, Parser.ARRAY_IDENT((kind, name), (spaces, pos)) - | HASH_IDENT(kind, name, pos) -> pos, Parser.HASH_IDENT((kind, name), (spaces, pos)) - | FUNC_IDENT(kind, name, pos) -> pos, Parser.FUNC_IDENT((kind, name), (spaces, pos)) - | STAR_IDENT(kind, name, pos) -> pos, Parser.STAR_IDENT((kind, name), (spaces, pos)) - | RAW_IDENT(kind, name, pos) -> pos, Parser.RAW_IDENT((kind, name), (spaces, pos)) - | RAW_IDENT_PAREN(kind, name, pos) -> pos, Parser.RAW_IDENT_PAREN((kind, name), (spaces, pos)) - | ARRAYLEN_IDENT(kind, name, pos) -> pos, Parser.ARRAYLEN_IDENT((kind, name), (spaces, pos)) - | FUNC_DECL_WITH_PROTO(name, proto, pos) -> pos, Parser.FUNC_DECL_WITH_PROTO((name, proto), (spaces, pos)) - - | NEW(pos) -> pos, Parser.NEW((), (spaces, pos)) - | FORMAT(pos) -> pos, Parser.FORMAT((), (spaces, pos)) - | COMPARE_OP(s, pos) -> pos, Parser.COMPARE_OP(s, (spaces, pos)) - | EQ_OP(s, pos) -> pos, Parser.EQ_OP(s, (spaces, pos)) - | ASSIGN(s, pos) -> pos, Parser.ASSIGN(s, (spaces, pos)) - | FOR(s, pos) -> pos, Parser.FOR(s, (spaces, pos)) - - | DOTDOT(s, pos) -> pos, Parser.DOTDOT(s, (spaces, pos)) - | MULT(s, pos) -> pos, Parser.MULT(s, (spaces, pos)) - | BIT_SHIFT(s, pos) -> pos, Parser.BIT_SHIFT(s, (spaces, pos)) - | PLUS(s, pos) -> pos, Parser.PLUS(s, (spaces, pos)) - | ONE_SCALAR_PARA(s, pos) -> pos, Parser.ONE_SCALAR_PARA(s, (spaces, pos)) - | MY_OUR(s, pos) -> pos, Parser.MY_OUR(s, (spaces, pos)) - - | EOF (pos) -> pos, Parser.EOF ((), (spaces, pos)) - | IF (pos) -> pos, Parser.IF ((), (spaces, pos)) - | ELSIF (pos) -> pos, Parser.ELSIF ((), (spaces, pos)) - | ELSE (pos) -> pos, Parser.ELSE ((), (spaces, pos)) - | UNLESS (pos) -> pos, Parser.UNLESS ((), (spaces, pos)) - | DO (pos) -> pos, Parser.DO ((), (spaces, pos)) - | WHILE (pos) -> pos, Parser.WHILE ((), (spaces, pos)) - | UNTIL (pos) -> pos, Parser.UNTIL ((), (spaces, pos)) - | CONTINUE (pos) -> pos, Parser.CONTINUE ((), (spaces, pos)) - | SUB (pos) -> pos, Parser.SUB ((), (spaces, pos)) - | LOCAL (pos) -> pos, Parser.LOCAL ((), (spaces, pos)) - | USE (pos) -> pos, Parser.USE ((), (spaces, pos)) - | PACKAGE (pos) -> pos, Parser.PACKAGE ((), (spaces, pos)) - | BEGIN (pos) -> pos, Parser.BEGIN ((), (spaces, pos)) - | END (pos) -> pos, Parser.END ((), (spaces, pos)) - | AT (pos) -> pos, Parser.AT ((), (spaces, pos)) - | DOLLAR (pos) -> pos, Parser.DOLLAR ((), (spaces, pos)) - | PERCENT (pos) -> pos, Parser.PERCENT ((), (spaces, pos)) - | AMPERSAND (pos) -> pos, Parser.AMPERSAND ((), (spaces, pos)) - | STAR (pos) -> pos, Parser.STAR ((), (spaces, pos)) - | ARRAYLEN (pos) -> pos, Parser.ARRAYLEN ((), (spaces, pos)) - | SEMI_COLON (pos) -> pos, Parser.SEMI_COLON ((), (spaces, pos)) - | PKG_SCOPE (pos) -> pos, Parser.PKG_SCOPE ((), (spaces, pos)) - | PAREN (pos) -> pos, Parser.PAREN ((), (spaces, pos)) - | PAREN_END (pos) -> pos, Parser.PAREN_END ((), (spaces, pos)) - | BRACKET (pos) -> pos, Parser.BRACKET ((), (spaces, pos)) - | BRACKET_END (pos) -> pos, Parser.BRACKET_END ((), (spaces, pos)) - | BRACKET_HASHREF (pos) -> pos, Parser.BRACKET_HASHREF ((), (spaces, pos)) - | ARRAYREF (pos) -> pos, Parser.ARRAYREF ((), (spaces, pos)) - | ARRAYREF_END (pos) -> pos, Parser.ARRAYREF_END ((), (spaces, pos)) - | ARROW (pos) -> pos, Parser.ARROW ((), (spaces, pos)) - | INCR (pos) -> pos, Parser.INCR ((), (spaces, pos)) - | DECR (pos) -> pos, Parser.DECR ((), (spaces, pos)) - | POWER (pos) -> pos, Parser.POWER ((), (spaces, pos)) - | TIGHT_NOT (pos) -> pos, Parser.TIGHT_NOT ((), (spaces, pos)) - | BIT_NEG (pos) -> pos, Parser.BIT_NEG ((), (spaces, pos)) - | REF (pos) -> pos, Parser.REF ((), (spaces, pos)) - | PATTERN_MATCH (pos) -> pos, Parser.PATTERN_MATCH ((), (spaces, pos)) - | PATTERN_MATCH_NOT(pos) -> pos, Parser.PATTERN_MATCH_NOT((), (spaces, pos)) - | LT (pos) -> pos, Parser.LT ((), (spaces, pos)) - | GT (pos) -> pos, Parser.GT ((), (spaces, pos)) - | BIT_AND (pos) -> pos, Parser.BIT_AND ((), (spaces, pos)) - | BIT_OR (pos) -> pos, Parser.BIT_OR ((), (spaces, pos)) - | BIT_XOR (pos) -> pos, Parser.BIT_XOR ((), (spaces, pos)) - | AND_TIGHT (pos) -> pos, Parser.AND_TIGHT ((), (spaces, pos)) - | OR_TIGHT (pos) -> pos, Parser.OR_TIGHT ((), (spaces, pos)) - | QUESTION_MARK (pos) -> pos, Parser.QUESTION_MARK ((), (spaces, pos)) - | COLON (pos) -> pos, Parser.COLON ((), (spaces, pos)) - | COMMA (pos) -> pos, Parser.COMMA ((), (spaces, pos)) - | RIGHT_ARROW (pos) -> pos, Parser.RIGHT_ARROW ((), (spaces, pos)) - | NOT (pos) -> pos, Parser.NOT ((), (spaces, pos)) - | AND (pos) -> pos, Parser.AND ((), (spaces, pos)) - | OR (pos) -> pos, Parser.OR ((), (spaces, pos)) - | XOR (pos) -> pos, Parser.XOR ((), (spaces, pos)) + | NUM(s, pos) -> pos, Parser.NUM(new_any s spaces pos) + | RAW_STRING(s, pos) -> pos, Parser.RAW_STRING(new_any s spaces pos) + | RAW_HERE_DOC(r, pos) -> pos, Parser.RAW_HERE_DOC(new_any !r spaces pos) + | STRING(l, pos) -> pos, Parser.STRING(new_any (raw_interpolated_string_to_tokens l) spaces pos) + | COMMAND_STRING(l, pos) -> pos, Parser.COMMAND_STRING(new_any (raw_interpolated_string_to_tokens l) spaces pos) + | QR_PATTERN(s, opts, pos) -> pos, Parser.QR_PATTERN(new_any (raw_interpolated_string_to_tokens s, opts) spaces pos) + | PATTERN(s, opts, pos) -> pos, Parser.PATTERN(new_any (raw_interpolated_string_to_tokens s, opts) spaces pos) + | PATTERN_SUBST(from, to_, opts, pos) -> pos, Parser.PATTERN_SUBST(new_any (raw_interpolated_string_to_tokens from, raw_interpolated_string_to_tokens to_, opts) spaces pos) + | HERE_DOC(l, pos) -> pos, Parser.HERE_DOC(new_any (raw_interpolated_string_to_tokens (fst !l), snd !l) spaces pos) + | BAREWORD(s, pos) -> pos, Parser.BAREWORD(new_any s spaces pos) + | BAREWORD_PAREN(s, pos) -> pos, Parser.BAREWORD_PAREN(new_any s spaces pos) + | REVISION(s, pos) -> pos, Parser.REVISION(new_any s spaces pos) + | PERL_CHECKER_COMMENT(s, pos) -> pos, Parser.PERL_CHECKER_COMMENT(new_any s spaces pos) + | PO_COMMENT(s, pos) -> pos, Parser.PO_COMMENT(new_any s spaces pos) + | POD(s, pos) -> pos, Parser.POD(new_any s spaces pos) + | LABEL(s, pos) -> pos, Parser.LABEL(new_any s spaces pos) + | PRINT(s, pos) -> pos, Parser.PRINT(new_any s spaces pos) + | PRINT_TO_STAR(s, pos) -> pos, Parser.PRINT_TO_STAR(new_any s spaces pos) + | PRINT_TO_SCALAR(s, pos) -> pos, Parser.PRINT_TO_SCALAR(new_any s spaces pos) + | QUOTEWORDS(s, pos) -> pos, Parser.QUOTEWORDS(new_any s spaces pos) + | COMPACT_HASH_SUBSCRIPT(s, pos) -> pos, Parser.COMPACT_HASH_SUBSCRIPT(new_any s spaces pos) + | SCALAR_IDENT(kind, name, pos) -> pos, Parser.SCALAR_IDENT(new_any (kind, name) spaces pos) + | ARRAY_IDENT(kind, name, pos) -> pos, Parser.ARRAY_IDENT(new_any (kind, name) spaces pos) + | HASH_IDENT(kind, name, pos) -> pos, Parser.HASH_IDENT(new_any (kind, name) spaces pos) + | FUNC_IDENT(kind, name, pos) -> pos, Parser.FUNC_IDENT(new_any (kind, name) spaces pos) + | STAR_IDENT(kind, name, pos) -> pos, Parser.STAR_IDENT(new_any (kind, name) spaces pos) + | RAW_IDENT(kind, name, pos) -> pos, Parser.RAW_IDENT(new_any (kind, name) spaces pos) + | RAW_IDENT_PAREN(kind, name, pos) -> pos, Parser.RAW_IDENT_PAREN(new_any (kind, name) spaces pos) + | ARRAYLEN_IDENT(kind, name, pos) -> pos, Parser.ARRAYLEN_IDENT(new_any (kind, name) spaces pos) + | FUNC_DECL_WITH_PROTO(name, proto, pos) -> pos, Parser.FUNC_DECL_WITH_PROTO(new_any (name, proto) spaces pos) + + | NEW(pos) -> pos, Parser.NEW(new_any () spaces pos) + | FORMAT(pos) -> pos, Parser.FORMAT(new_any () spaces pos) + | COMPARE_OP(s, pos) -> pos, Parser.COMPARE_OP(new_any s spaces pos) + | EQ_OP(s, pos) -> pos, Parser.EQ_OP(new_any s spaces pos) + | ASSIGN(s, pos) -> pos, Parser.ASSIGN(new_any s spaces pos) + | FOR(s, pos) -> pos, Parser.FOR(new_any s spaces pos) + + | DOTDOT(s, pos) -> pos, Parser.DOTDOT(new_any s spaces pos) + | MULT(s, pos) -> pos, Parser.MULT(new_any s spaces pos) + | BIT_SHIFT(s, pos) -> pos, Parser.BIT_SHIFT(new_any s spaces pos) + | PLUS(s, pos) -> pos, Parser.PLUS(new_any s spaces pos) + | ONE_SCALAR_PARA(s, pos) -> pos, Parser.ONE_SCALAR_PARA(new_any s spaces pos) + | MY_OUR(s, pos) -> pos, Parser.MY_OUR(new_any s spaces pos) + + | EOF (pos) -> pos, Parser.EOF (new_any () spaces pos) + | IF (pos) -> pos, Parser.IF (new_any () spaces pos) + | ELSIF (pos) -> pos, Parser.ELSIF (new_any () spaces pos) + | ELSE (pos) -> pos, Parser.ELSE (new_any () spaces pos) + | UNLESS (pos) -> pos, Parser.UNLESS (new_any () spaces pos) + | DO (pos) -> pos, Parser.DO (new_any () spaces pos) + | WHILE (pos) -> pos, Parser.WHILE (new_any () spaces pos) + | UNTIL (pos) -> pos, Parser.UNTIL (new_any () spaces pos) + | CONTINUE (pos) -> pos, Parser.CONTINUE (new_any () spaces pos) + | SUB (pos) -> pos, Parser.SUB (new_any () spaces pos) + | LOCAL (pos) -> pos, Parser.LOCAL (new_any () spaces pos) + | USE (pos) -> pos, Parser.USE (new_any () spaces pos) + | PACKAGE (pos) -> pos, Parser.PACKAGE (new_any () spaces pos) + | BEGIN (pos) -> pos, Parser.BEGIN (new_any () spaces pos) + | END (pos) -> pos, Parser.END (new_any () spaces pos) + | AT (pos) -> pos, Parser.AT (new_any () spaces pos) + | DOLLAR (pos) -> pos, Parser.DOLLAR (new_any () spaces pos) + | PERCENT (pos) -> pos, Parser.PERCENT (new_any () spaces pos) + | AMPERSAND (pos) -> pos, Parser.AMPERSAND (new_any () spaces pos) + | STAR (pos) -> pos, Parser.STAR (new_any () spaces pos) + | ARRAYLEN (pos) -> pos, Parser.ARRAYLEN (new_any () spaces pos) + | SEMI_COLON (pos) -> pos, Parser.SEMI_COLON (new_any () spaces pos) + | PKG_SCOPE (pos) -> pos, Parser.PKG_SCOPE (new_any () spaces pos) + | PAREN (pos) -> pos, Parser.PAREN (new_any () spaces pos) + | PAREN_END (pos) -> pos, Parser.PAREN_END (new_any () spaces pos) + | BRACKET (pos) -> pos, Parser.BRACKET (new_any () spaces pos) + | BRACKET_END (pos) -> pos, Parser.BRACKET_END (new_any () spaces pos) + | BRACKET_HASHREF (pos) -> pos, Parser.BRACKET_HASHREF (new_any () spaces pos) + | ARRAYREF (pos) -> pos, Parser.ARRAYREF (new_any () spaces pos) + | ARRAYREF_END (pos) -> pos, Parser.ARRAYREF_END (new_any () spaces pos) + | ARROW (pos) -> pos, Parser.ARROW (new_any () spaces pos) + | INCR (pos) -> pos, Parser.INCR (new_any () spaces pos) + | DECR (pos) -> pos, Parser.DECR (new_any () spaces pos) + | POWER (pos) -> pos, Parser.POWER (new_any () spaces pos) + | TIGHT_NOT (pos) -> pos, Parser.TIGHT_NOT (new_any () spaces pos) + | BIT_NEG (pos) -> pos, Parser.BIT_NEG (new_any () spaces pos) + | REF (pos) -> pos, Parser.REF (new_any () spaces pos) + | PATTERN_MATCH (pos) -> pos, Parser.PATTERN_MATCH (new_any () spaces pos) + | PATTERN_MATCH_NOT(pos) -> pos, Parser.PATTERN_MATCH_NOT(new_any () spaces pos) + | LT (pos) -> pos, Parser.LT (new_any () spaces pos) + | GT (pos) -> pos, Parser.GT (new_any () spaces pos) + | BIT_AND (pos) -> pos, Parser.BIT_AND (new_any () spaces pos) + | BIT_OR (pos) -> pos, Parser.BIT_OR (new_any () spaces pos) + | BIT_XOR (pos) -> pos, Parser.BIT_XOR (new_any () spaces pos) + | AND_TIGHT (pos) -> pos, Parser.AND_TIGHT (new_any () spaces pos) + | OR_TIGHT (pos) -> pos, Parser.OR_TIGHT (new_any () spaces pos) + | QUESTION_MARK (pos) -> pos, Parser.QUESTION_MARK (new_any () spaces pos) + | COLON (pos) -> pos, Parser.COLON (new_any () spaces pos) + | COMMA (pos) -> pos, Parser.COMMA (new_any () spaces pos) + | RIGHT_ARROW (pos) -> pos, Parser.RIGHT_ARROW (new_any () spaces pos) + | NOT (pos) -> pos, Parser.NOT (new_any () spaces pos) + | AND (pos) -> pos, Parser.AND (new_any () spaces pos) + | OR (pos) -> pos, Parser.OR (new_any () spaces pos) + | XOR (pos) -> pos, Parser.XOR (new_any () spaces pos) | SPACE _ | CR -> internal_error "raw_token_to_token" |