update_syntax: add new productions only once, to allow repeated local notation, for example;
authorwenzelm
Mon, 19 Apr 2010 23:11:39 +0200
changeset 36208 74c5e6e3c1d3
parent 36207 a94bbede91c7
child 36211 27137425b102
update_syntax: add new productions only once, to allow repeated local notation, for example;
src/Pure/Syntax/syntax.ML
--- a/src/Pure/Syntax/syntax.ML	Mon Apr 19 17:57:07 2010 +0200
+++ b/src/Pure/Syntax/syntax.ML	Mon Apr 19 23:11:39 2010 +0200
@@ -290,15 +290,14 @@
     val SynExt.SynExt {xprods, consts = consts2, prmodes = prmodes2,
       parse_ast_translation, parse_rules, parse_translation, print_translation, print_rules,
       print_ast_translation, token_translation} = syn_ext;
-    val input' = if inout then fold (insert (op =)) xprods input else input;
-    val changed = length input <> length input';
+    val new_xprods =
+      if inout then distinct (op =) (filter_out (member (op =) input) xprods) else [];
     fun if_inout xs = if inout then xs else [];
   in
     Syntax
-    ({input = input',
-      lexicon =
-        if changed then fold Scan.extend_lexicon (SynExt.delims_of xprods) lexicon else lexicon,
-      gram = if changed then Parser.extend_gram gram xprods else gram,
+    ({input = new_xprods @ input,
+      lexicon = fold Scan.extend_lexicon (SynExt.delims_of new_xprods) lexicon,
+      gram = Parser.extend_gram gram new_xprods,
       consts = Library.merge (op =) (consts1, filter_out Lexicon.is_marked consts2),
       prmodes = insert (op =) mode (Library.merge (op =) (prmodes1, prmodes2)),
       parse_ast_trtab =