BenHanson / parsertl14

C++14 version of parsertl
32 stars 4 forks source link

Strange conflict output change, when adding unused tokens #12

Open mingodad opened 9 months ago

mingodad commented 9 months ago

Trying to convert Haskell GHC grammar to use with parsertl I found a strange behavior when adding new unused token declarations, the output of the conflicts found changes as we add then.

See attached grammar and bellow is the diff from the output of:

./gram_grep -f ghc.g anything.txt

In one run this unused tokens are commented:

%token SHIFT_HERE
%token SHIFT_THERE
--- <unnamed>
+++ <unnamed>
@@ -75,7 +75,7 @@
 SHIFT (aexp2 -> . "(#" texp "#)") (aexp2 -> . "(#" tup_exprs "#)") (sysdcon_nolist -> . "(#" "#)") (sysdcon_nolist -> . "(#" commas "#)")/REDUCE (exp10 -> fexp) conflict.
 SHIFT (aexp -> . "\\" apats "->" exp)/REDUCE (exp10 -> fexp) conflict.
 SHIFT (aexp -> . "let" binds "in" exp)/REDUCE (exp10 -> fexp) conflict.
-SHIFT (aexp -> . "if" exp optSemi "then" exp optSemi "else" exp) (aexp -> . "if" ifgdpats)/REDUCE (exp10 -> fexp) conflict.
+SHIFT (aexp -> . "if" exp optSemi "then" exp optSemi "else" exp) (aexp -> . "if" ifgdpats) (qvarid -> . varid)/REDUCE (exp10 -> fexp) conflict.
 SHIFT (aexp -> . "proc" aexp "->" exp)/REDUCE (exp10 -> fexp) conflict.
 SHIFT (aexp2 -> . "[|" exp "|]")/REDUCE (exp10 -> fexp) conflict.
 SHIFT (aexp2 -> . "[||" exp "||]")/REDUCE (exp10 -> fexp) conflict.
@@ -90,8 +90,8 @@
 SHIFT (tyvarid -> . special_id) (special_id -> . special_id "as") (qtycon -> . QCONID)/REDUCE (aexp2 -> TH_TY_QUOTE) conflict.
 SHIFT (tyvarid -> . VARID)/REDUCE (aexp2 -> TH_TY_QUOTE) conflict.
 SHIFT (gtycon -> . '(' ')') (ntgtycon -> . '(' commas ')') (ntgtycon -> . '(' "->" ')') (oqtycon -> . '(' qtyconsym ')')/REDUCE (aexp2 -> TH_TY_QUOTE) conflict.
-SHIFT (special_id -> . "unit")/REDUCE (aexp2 -> TH_TY_QUOTE) conflict.
-SHIFT (ntgtycon -> . oqtycon) (ntgtycon -> . '[' ']')/REDUCE (aexp2 -> TH_TY_QUOTE) conflict.
+SHIFT (ntgtycon -> . oqtycon) (special_id -> . "unit")/REDUCE (aexp2 -> TH_TY_QUOTE) conflict.
+SHIFT (ntgtycon -> . '[' ']')/REDUCE (aexp2 -> TH_TY_QUOTE) conflict.
 SHIFT (special_id -> . "signature")/REDUCE (aexp2 -> TH_TY_QUOTE) conflict.
 SHIFT (special_id -> . "dependency")/REDUCE (aexp2 -> TH_TY_QUOTE) conflict.
 SHIFT (tyvarid -> . "safe")/REDUCE (aexp2 -> TH_TY_QUOTE) conflict.
@@ -106,7 +106,7 @@
 SHIFT (special_id -> . "capi")/REDUCE (aexp2 -> TH_TY_QUOTE) conflict.
 SHIFT (special_id -> . "prim")/REDUCE (aexp2 -> TH_TY_QUOTE) conflict.
 SHIFT (special_id -> . "javascript")/REDUCE (aexp2 -> TH_TY_QUOTE) conflict.
-SHIFT (tyvarid -> . "unsafe")/REDUCE (aexp2 -> TH_TY_QUOTE) conflict.
+SHIFT (tyvar -> . tyvarid) (tyvarid -> . "unsafe")/REDUCE (aexp2 -> TH_TY_QUOTE) conflict.
 SHIFT (tyvarid -> . "interruptible")/REDUCE (aexp2 -> TH_TY_QUOTE) conflict.
 SHIFT (gtycon -> . "(#" "#)") (ntgtycon -> . "(#" commas "#)") (ntgtycon -> . "(#" bars "#)")/REDUCE (aexp2 -> TH_TY_QUOTE) conflict.
 SHIFT (special_id -> . "group")/REDUCE (aexp2 -> TH_TY_QUOTE) conflict.
@@ -133,8 +133,8 @@
 SHIFT (tyvarid -> . VARID)/REDUCE (infixtype -> ftype) conflict.
 SHIFT (tyconsym -> . VARSYM)/REDUCE (infixtype -> ftype) conflict.
 SHIFT (atype -> . '(' ')') (atype -> . '(' ktype ',' comma_types1 ')') (atype -> . '(' ktype ')') (ntgtycon -> . '(' commas ')') (ntgtycon -> . '(' "->" ')') (oqtycon -> . '(' qtyconsym ')')/REDUCE (infixtype -> ftype) conflict.
-SHIFT (special_id -> . "unit")/REDUCE (infixtype -> ftype) conflict.
-SHIFT (atype -> . '[' ktype ']') (atype -> . '[' ktype ',' comma_types1 ']') (ntgtycon -> . oqtycon) (ntgtycon -> . '[' ']')/REDUCE (infixtype -> ftype) conflict.
+SHIFT (ntgtycon -> . oqtycon) (special_id -> . "unit")/REDUCE (infixtype -> ftype) conflict.
+SHIFT (atype -> . '[' ktype ']') (atype -> . '[' ktype ',' comma_types1 ']') (ntgtycon -> . '[' ']')/REDUCE (infixtype -> ftype) conflict.
 SHIFT (tyconsym -> . ':')/REDUCE (infixtype -> ftype) conflict.
 SHIFT (tyconsym -> . '-')/REDUCE (infixtype -> ftype) conflict.
 SHIFT (special_id -> . "signature")/REDUCE (infixtype -> ftype) conflict.
@@ -153,7 +153,7 @@
 SHIFT (special_id -> . "capi")/REDUCE (infixtype -> ftype) conflict.
 SHIFT (special_id -> . "prim")/REDUCE (infixtype -> ftype) conflict.
 SHIFT (special_id -> . "javascript")/REDUCE (infixtype -> ftype) conflict.
-SHIFT (tyvarid -> . "unsafe")/REDUCE (infixtype -> ftype) conflict.
+SHIFT (tyvar -> . tyvarid) (tyvarid -> . "unsafe")/REDUCE (infixtype -> ftype) conflict.
 SHIFT (tyvarid -> . "interruptible")/REDUCE (infixtype -> ftype) conflict.
 SHIFT (atype -> . '*')/REDUCE (infixtype -> ftype) conflict.
 SHIFT (atype -> . "(#" "#)") (atype -> . "(#" comma_types1 "#)") (atype -> . "(#" bar_types2 "#)") (ntgtycon -> . "(#" commas "#)") (ntgtycon -> . "(#" bars "#)")/REDUCE (infixtype -> ftype) conflict.
@@ -223,7 +223,7 @@
 SHIFT (aexp2 -> . "(#" texp "#)") (aexp2 -> . "(#" tup_exprs "#)") (sysdcon_nolist -> . "(#" "#)") (sysdcon_nolist -> . "(#" commas "#)")/REDUCE (exp10 -> '-' fexp) conflict.
 SHIFT (aexp -> . "\\" apats "->" exp)/REDUCE (exp10 -> '-' fexp) conflict.
 SHIFT (aexp -> . "let" binds "in" exp)/REDUCE (exp10 -> '-' fexp) conflict.
-SHIFT (aexp -> . "if" exp optSemi "then" exp optSemi "else" exp) (aexp -> . "if" ifgdpats)/REDUCE (exp10 -> '-' fexp) conflict.
+SHIFT (aexp -> . "if" exp optSemi "then" exp optSemi "else" exp) (aexp -> . "if" ifgdpats) (qvarid -> . varid)/REDUCE (exp10 -> '-' fexp) conflict.
 SHIFT (aexp -> . "proc" aexp "->" exp)/REDUCE (exp10 -> '-' fexp) conflict.
 SHIFT (aexp2 -> . "[|" exp "|]")/REDUCE (exp10 -> '-' fexp) conflict.
 SHIFT (aexp2 -> . "[||" exp "||]")/REDUCE (exp10 -> '-' fexp) conflict.
@@ -245,4 +245,6 @@
 SHIFT (transformqual -> "then" "group" . "by" exp "using" exp)/REDUCE (special_id -> "group") conflict.
 SHIFT (rule_foralls -> "forall" rule_vars '.' . "forall" rule_vars '.')/REDUCE (rule_foralls -> "forall" rule_vars '.') conflict.
 SHIFT (tv_bndr_no_braces -> '(' tyvar . "::" kind ')')/REDUCE (atype -> tyvar) conflict.
+Warning: Token "SHIFT_HERE" does not have a lexer definiton.
+Warning: Token "SHIFT_THERE" does not have a lexer definiton.
 Matches: 0    Matching files: 0    Total files searched: 1

ghc.g.zip