summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <thierry.vignaud@gmail.com>2016-10-11 10:48:02 +0200
committerThierry Vignaud <thierry.vignaud@gmail.com>2016-10-11 11:11:06 +0200
commit712f0891d18e6230c2f53f4d1ff9231d95e3c3cd (patch)
tree33fd1c1313e739bf69520bb188523d64b526eec8
parent67c46ecfebf9af723b56e41c8ebdee375f43df68 (diff)
downloadperl_checker-712f0891d18e6230c2f53f4d1ff9231d95e3c3cd.tar
perl_checker-712f0891d18e6230c2f53f4d1ff9231d95e3c3cd.tar.gz
perl_checker-712f0891d18e6230c2f53f4d1ff9231d95e3c3cd.tar.bz2
perl_checker-712f0891d18e6230c2f53f4d1ff9231d95e3c3cd.tar.xz
perl_checker-712f0891d18e6230c2f53f4d1ff9231d95e3c3cd.zip
recognize ~~ (smartmatch)
-rw-r--r--NEWS1
-rw-r--r--src/lexer.mll3
-rw-r--r--src/parser.mly5
3 files changed, 7 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 0a16534..2c11409 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
- blacklist File::Spec::Unix & Test::Builder for iurt
- list more Gtk3 methods, thus increasing SNR
+- recognize ~~ (smartmatch)
Version 1.2.29 - 16 September 2016, by Thierry Vignaud
diff --git a/src/lexer.mll b/src/lexer.mll
index ee58a7d..fd3eef0 100644
--- a/src/lexer.mll
+++ b/src/lexer.mll
@@ -51,6 +51,7 @@ type raw_token =
| CONCAT of raw_pos | POWER of raw_pos | TIGHT_NOT of raw_pos | BIT_NEG of raw_pos | REF of raw_pos | ONE_SCALAR_PARA of (string * raw_pos) | PATTERN_MATCH of raw_pos | PATTERN_MATCH_NOT of raw_pos | MULT of (string * raw_pos) | MULT_L_STR of raw_pos
| PLUS of (string * raw_pos) | BIT_SHIFT of (string * raw_pos)
| LT of raw_pos | GT of raw_pos | COMPARE_OP of (string * raw_pos) | COMPARE_OP_STR of (string * raw_pos) | EQ_OP of (string * raw_pos) | EQ_OP_STR of (string * raw_pos)
+ | SMART_OP of (string * raw_pos)
| BIT_AND of raw_pos | BIT_OR of raw_pos | BIT_XOR of raw_pos | AND_TIGHT of raw_pos | OR_TIGHT of raw_pos | DOTDOT of (string * raw_pos)
| QUESTION_MARK of raw_pos | COLON of raw_pos | ASSIGN of (string * raw_pos) | COMMA of raw_pos | RIGHT_ARROW of raw_pos | NOT of raw_pos | AND of raw_pos | OR of raw_pos | XOR of raw_pos
@@ -136,6 +137,7 @@ let rec raw_token_to_pos_and_token spaces = function
| COMPARE_OP_STR(s, pos) -> pos, Parser.COMPARE_OP_STR(new_any M_special s spaces pos)
| EQ_OP(s, pos) -> pos, Parser.EQ_OP(new_any M_special s spaces pos)
| EQ_OP_STR(s, pos) -> pos, Parser.EQ_OP_STR(new_any M_special s spaces pos)
+ | SMART_OP(s, pos) -> pos, Parser.SMART_OP(new_any M_special s spaces pos)
| ASSIGN(s, pos) -> pos, Parser.ASSIGN(new_any M_special s spaces pos)
| FOR(s, pos) -> pos, Parser.FOR(new_any M_special s spaces pos)
@@ -492,6 +494,7 @@ rule token = parse
| ">" { GT(pos lexbuf) }
| "<=" | ">=" { COMPARE_OP(lexeme lexbuf, pos lexbuf) }
| "lt" | "gt" | "le" | "ge" { COMPARE_OP_STR(lexeme lexbuf, pos lexbuf) }
+| "~~" { SMART_OP(lexeme lexbuf, pos lexbuf) }
| "==" | "!=" | "<=>" { EQ_OP(lexeme lexbuf, pos lexbuf) }
| "eq" | "ne" | "cmp" { EQ_OP_STR(lexeme lexbuf, pos lexbuf) }
| "&" { BIT_AND(pos lexbuf) }
diff --git a/src/parser.mly b/src/parser.mly
index 62309be..a6f20f1 100644
--- a/src/parser.mly
+++ b/src/parser.mly
@@ -28,7 +28,7 @@
%token <string Types.any_spaces_pos> FOR PRINT
%token <unit Types.any_spaces_pos> NEW
-%token <string Types.any_spaces_pos> COMPARE_OP COMPARE_OP_STR EQ_OP EQ_OP_STR
+%token <string Types.any_spaces_pos> COMPARE_OP COMPARE_OP_STR EQ_OP EQ_OP_STR SMART_OP
%token <string Types.any_spaces_pos> ASSIGN MY_OUR
%token <unit Types.any_spaces_pos> IF ELSIF ELSE UNLESS DO WHILE UNTIL CONTINUE SUB LOCAL
@@ -75,7 +75,7 @@
%left AND_TIGHT
%left BIT_OR BIT_XOR
%left BIT_AND
-%nonassoc EQ_OP EQ_OP_STR
+%nonassoc EQ_OP EQ_OP_STR SMART_OP
%nonassoc LT GT COMPARE_OP COMPARE_OP_STR
%nonassoc UNIOP ONE_SCALAR_PARA
%left BIT_SHIFT
@@ -212,6 +212,7 @@ term:
| term GT term {sp_p $2; symops P_cmp M_float M_bool ">" $1 $2 $3}
| term EQ_OP term {sp_p $2; symops P_eq M_float M_bool $2.any $1 $2 $3}
| term EQ_OP_STR term {sp_p $2; symops P_eq M_string M_bool $2.any $1 $2 $3}
+| term SMART_OP term {sp_p $2; symops P_eq M_unknown_scalar M_bool $2.any $1 $2 $3}
| term BIT_AND term {sp_p $2; symops P_bit M_int M_int "&" $1 $2 $3}
| term BIT_OR term { symops P_bit M_int M_int "|" $1 $2 $3}