src/Pure/Syntax/syntax.ML
author wenzelm
Sat Dec 17 01:00:40 2005 +0100 (2005-12-17)
changeset 18428 4059413acbc1
parent 17496 26535df536ae
child 18678 dd0c569fa43d
permissions -rw-r--r--
sort_distinct;
     1 (*  Title:      Pure/Syntax/syntax.ML
     2     ID:         $Id$
     3     Author:     Tobias Nipkow and Markus Wenzel, TU Muenchen
     4 
     5 Root of Isabelle's syntax module.
     6 *)
     7 
     8 signature BASIC_SYNTAX =
     9 sig
    10   include AST0
    11   include SYN_TRANS0
    12   include MIXFIX0
    13   include PRINTER0
    14 end;
    15 
    16 signature SYNTAX =
    17 sig
    18   include AST1
    19   include LEXICON0
    20   include SYN_EXT0
    21   include TYPE_EXT0
    22   include SYN_TRANS1
    23   include MIXFIX1
    24   include PRINTER0
    25   val extend_trtab: string -> (string * ('a * stamp)) list ->
    26     ('a * stamp) Symtab.table -> ('a * stamp) Symtab.table
    27   val merge_trtabs: string -> ('a * stamp) Symtab.table -> ('a * stamp) Symtab.table ->
    28     ('a * stamp) Symtab.table
    29   val merge_tr'tabs: ('a * stamp) list Symtab.table -> ('a * stamp) list Symtab.table
    30     -> ('a * stamp) list Symtab.table
    31   val extend_tr'tab: (string * ('a * stamp)) list ->
    32     ('a * stamp) list Symtab.table -> ('a * stamp) list Symtab.table
    33   datatype 'a trrule =
    34     ParseRule of 'a * 'a |
    35     PrintRule of 'a * 'a |
    36     ParsePrintRule of 'a * 'a
    37   type syntax
    38   val eq_syntax: syntax * syntax -> bool
    39   val is_keyword: syntax -> string -> bool
    40   val default_mode: string * bool
    41   val extend_type_gram: (string * int * mixfix) list -> syntax -> syntax
    42   val extend_const_gram: (string -> bool) ->
    43     string * bool -> (string * typ * mixfix) list -> syntax -> syntax
    44   val extend_consts: string list -> syntax -> syntax
    45   val extend_trfuns:
    46     (string * ((ast list -> ast) * stamp)) list *
    47     (string * ((term list -> term) * stamp)) list *
    48     (string * ((bool -> typ -> term list -> term) * stamp)) list *
    49     (string * ((ast list -> ast) * stamp)) list -> syntax -> syntax
    50   val extend_advanced_trfuns:
    51     (string * ((theory -> ast list -> ast) * stamp)) list *
    52     (string * ((theory -> term list -> term) * stamp)) list *
    53     (string * ((theory -> bool -> typ -> term list -> term) * stamp)) list *
    54     (string * ((theory -> ast list -> ast) * stamp)) list -> syntax -> syntax
    55   val extend_tokentrfuns: (string * string * (string -> string * real)) list -> syntax -> syntax
    56   val extend_trrules_i: ast trrule list -> syntax -> syntax
    57   val extend_trrules: theory -> (string -> bool) -> syntax ->
    58     (string * string) trrule list -> syntax -> syntax
    59   val remove_const_gram: (string -> bool) ->
    60     string * bool -> (string * typ * mixfix) list -> syntax -> syntax
    61   val map_trrule: ('a -> 'b) -> 'a trrule -> 'b trrule
    62   val merge_syntaxes: syntax -> syntax -> syntax
    63   val pure_syn: syntax
    64   val print_gram: syntax -> unit
    65   val print_trans: syntax -> unit
    66   val print_syntax: syntax -> unit
    67   val read: theory -> (string -> bool) -> syntax -> typ -> string -> term list
    68   val read_typ: theory -> syntax -> ((indexname * sort) list -> indexname -> sort) ->
    69     (sort -> sort) -> string -> typ
    70   val read_sort: theory -> syntax -> string -> sort
    71   val pretty_term: theory -> syntax -> bool -> term -> Pretty.T
    72   val pretty_typ: theory -> syntax -> typ -> Pretty.T
    73   val pretty_sort: theory -> syntax -> sort -> Pretty.T
    74   val ambiguity_level: int ref
    75   val ambiguity_is_error: bool ref
    76 end;
    77 
    78 structure Syntax: SYNTAX =
    79 struct
    80 
    81 (** tables of translation functions **)
    82 
    83 (* parse (ast) translations *)
    84 
    85 fun lookup_tr tab c = Option.map fst (Symtab.lookup tab c);
    86 
    87 fun err_dup_trfuns name cs =
    88   error ("More than one " ^ name ^ " for " ^ commas_quote cs);
    89 
    90 fun extend_trtab name trfuns tab = Symtab.extend (tab, trfuns)
    91   handle Symtab.DUPS cs => err_dup_trfuns name cs;
    92 
    93 fun remove_trtab trfuns = fold (Symtab.remove SynExt.eq_trfun) trfuns;
    94 
    95 fun merge_trtabs name tab1 tab2 = Symtab.merge SynExt.eq_trfun (tab1, tab2)
    96   handle Symtab.DUPS cs => err_dup_trfuns name cs;
    97 
    98 
    99 (* print (ast) translations *)
   100 
   101 fun lookup_tr' tab c = map fst (Symtab.lookup_multi tab c);
   102 fun extend_tr'tab trfuns = fold_rev Symtab.update_multi trfuns;
   103 fun remove_tr'tab trfuns = fold (Symtab.remove_multi SynExt.eq_trfun) trfuns;
   104 fun merge_tr'tabs tab1 tab2 = Symtab.merge_multi' SynExt.eq_trfun (tab1, tab2);
   105 
   106 
   107 
   108 (** tables of token translation functions **)
   109 
   110 fun lookup_tokentr tabs modes =
   111   let val trs = gen_distinct (eq_fst (op =))
   112     (List.concat (map (these o AList.lookup (op =) tabs) (modes @ [""])))
   113   in fn c => Option.map fst (AList.lookup (op =) trs c) end;
   114 
   115 fun merge_tokentrtabs tabs1 tabs2 =
   116   let
   117     fun eq_tr ((c1, (_, s1)), (c2, (_, s2))) = c1 = c2 andalso s1 = s2;
   118 
   119     fun name (s, _) = implode (tl (Symbol.explode s));
   120 
   121     fun merge mode =
   122       let
   123         val trs1 = these (AList.lookup (op =) tabs1 mode);
   124         val trs2 = these (AList.lookup (op =) tabs2 mode);
   125         val trs = gen_distinct eq_tr (trs1 @ trs2);
   126       in
   127         (case gen_duplicates (eq_fst (op =)) trs of
   128           [] => (mode, trs)
   129         | dups => error ("More than one token translation function in mode " ^
   130             quote mode ^ " for " ^ commas_quote (map name dups)))
   131       end;
   132   in
   133     map merge (distinct (map fst (tabs1 @ tabs2)))
   134   end;
   135 
   136 fun extend_tokentrtab tokentrs tabs =
   137   let
   138     fun ins_tokentr (m, c, f) =
   139       AList.default (op =) (m, [])
   140       #> AList.map_entry (op =) m (cons ("_" ^ c, (f, stamp ())));
   141   in merge_tokentrtabs tabs (fold ins_tokentr tokentrs []) end;
   142 
   143 
   144 
   145 (** tables of translation rules **)
   146 
   147 type ruletab = (Ast.ast * Ast.ast) list Symtab.table;
   148 
   149 fun dest_ruletab tab = List.concat (map snd (Symtab.dest tab));
   150 
   151 
   152 (* empty, extend, merge ruletabs *)
   153 
   154 val extend_ruletab = fold_rev (fn r => Symtab.update_multi (Ast.head_of_rule r, r));
   155 val remove_ruletab = fold (fn r => Symtab.remove_multi (op =) (Ast.head_of_rule r, r));
   156 fun merge_ruletabs tab1 tab2 = Symtab.merge_multi' (op =) (tab1, tab2);
   157 
   158 
   159 
   160 (** datatype syntax **)
   161 
   162 datatype syntax =
   163   Syntax of {
   164     input: SynExt.xprod list,
   165     lexicon: Scan.lexicon,
   166     gram: Parser.gram,
   167     consts: string list,
   168     prmodes: string list,
   169     parse_ast_trtab: ((theory -> Ast.ast list -> Ast.ast) * stamp) Symtab.table,
   170     parse_ruletab: ruletab,
   171     parse_trtab: ((theory -> term list -> term) * stamp) Symtab.table,
   172     print_trtab: ((theory -> bool -> typ -> term list -> term) * stamp) list Symtab.table,
   173     print_ruletab: ruletab,
   174     print_ast_trtab: ((theory -> Ast.ast list -> Ast.ast) * stamp) list Symtab.table,
   175     tokentrtab: (string * (string * ((string -> string * real) * stamp)) list) list,
   176     prtabs: Printer.prtabs} * stamp;
   177 
   178 fun eq_syntax (Syntax (_, s1), Syntax (_, s2)) = s1 = s2;
   179 
   180 fun is_keyword (Syntax ({lexicon, ...}, _)) = Scan.is_literal lexicon o Symbol.explode;
   181 
   182 val default_mode = ("", true);
   183 
   184 
   185 (* empty_syntax *)
   186 
   187 val empty_syntax = Syntax
   188   ({input = [],
   189     lexicon = Scan.empty_lexicon,
   190     gram = Parser.empty_gram,
   191     consts = [],
   192     prmodes = [],
   193     parse_ast_trtab = Symtab.empty,
   194     parse_ruletab = Symtab.empty,
   195     parse_trtab = Symtab.empty,
   196     print_trtab = Symtab.empty,
   197     print_ruletab = Symtab.empty,
   198     print_ast_trtab = Symtab.empty,
   199     tokentrtab = [],
   200     prtabs = Printer.empty_prtabs}, stamp ());
   201 
   202 
   203 (* extend_syntax *)
   204 
   205 fun extend_syntax (mode, inout) syn_ext (Syntax (tabs, _)) =
   206   let
   207     val {input, lexicon, gram, consts = consts1, prmodes = prmodes1,
   208       parse_ast_trtab, parse_ruletab, parse_trtab, print_trtab, print_ruletab,
   209       print_ast_trtab, tokentrtab, prtabs} = tabs;
   210     val SynExt.SynExt {xprods, consts = consts2, prmodes = prmodes2,
   211       parse_ast_translation, parse_rules, parse_translation, print_translation, print_rules,
   212       print_ast_translation, token_translation} = syn_ext;
   213   in
   214     Syntax
   215     ({input = if inout then xprods @ input else input,
   216       lexicon = if inout then Scan.extend_lexicon lexicon (SynExt.delims_of xprods) else lexicon,
   217       gram = if inout then Parser.extend_gram gram xprods else gram,
   218       consts = merge_lists' consts1 consts2,
   219       prmodes = mode ins_string (merge_lists' prmodes1 prmodes2),
   220       parse_ast_trtab =
   221         extend_trtab "parse ast translation" parse_ast_translation parse_ast_trtab,
   222       parse_ruletab = extend_ruletab parse_rules parse_ruletab,
   223       parse_trtab = extend_trtab "parse translation" parse_translation parse_trtab,
   224       print_trtab = extend_tr'tab print_translation print_trtab,
   225       print_ruletab = extend_ruletab print_rules print_ruletab,
   226       print_ast_trtab = extend_tr'tab print_ast_translation print_ast_trtab,
   227       tokentrtab = extend_tokentrtab token_translation tokentrtab,
   228       prtabs = Printer.extend_prtabs mode xprods prtabs}, stamp ())
   229   end;
   230 
   231 
   232 (* remove_syntax *)
   233 
   234 fun remove_syntax (mode, inout) syn_ext (Syntax (tabs, _)) =
   235   let
   236     val SynExt.SynExt {xprods, consts = _, prmodes = _,
   237       parse_ast_translation, parse_rules, parse_translation, print_translation, print_rules,
   238       print_ast_translation, token_translation = _} = syn_ext;
   239     val {input, lexicon, gram, consts, prmodes,
   240       parse_ast_trtab, parse_ruletab, parse_trtab, print_trtab, print_ruletab,
   241       print_ast_trtab, tokentrtab, prtabs} = tabs;
   242     val input' = if inout then fold (remove (op =)) xprods input else input;
   243   in
   244     Syntax
   245     ({input = input',
   246       lexicon = if inout then Scan.make_lexicon (SynExt.delims_of input') else lexicon,
   247       gram = if inout then Parser.make_gram input' else gram,
   248       consts = consts,
   249       prmodes = prmodes,
   250       parse_ast_trtab = remove_trtab parse_ast_translation parse_ast_trtab,
   251       parse_ruletab = remove_ruletab parse_rules parse_ruletab,
   252       parse_trtab = remove_trtab parse_translation parse_trtab,
   253       print_trtab = remove_tr'tab print_translation print_trtab,
   254       print_ruletab = remove_ruletab print_rules print_ruletab,
   255       print_ast_trtab = remove_tr'tab print_ast_translation print_ast_trtab,
   256       tokentrtab = tokentrtab,
   257       prtabs = Printer.remove_prtabs mode xprods prtabs}, stamp ())
   258   end;
   259 
   260 
   261 (* merge_syntaxes *)
   262 
   263 fun merge_syntaxes (Syntax (tabs1, _)) (Syntax (tabs2, _)) =
   264   let
   265     val {input = input1, lexicon = lexicon1, gram = gram1, consts = consts1,
   266       prmodes = prmodes1, parse_ast_trtab = parse_ast_trtab1,
   267       parse_ruletab = parse_ruletab1, parse_trtab = parse_trtab1,
   268       print_trtab = print_trtab1, print_ruletab = print_ruletab1,
   269       print_ast_trtab = print_ast_trtab1, tokentrtab = tokentrtab1, prtabs = prtabs1} = tabs1;
   270 
   271     val {input = input2, lexicon = lexicon2, gram = gram2, consts = consts2,
   272       prmodes = prmodes2, parse_ast_trtab = parse_ast_trtab2,
   273       parse_ruletab = parse_ruletab2, parse_trtab = parse_trtab2,
   274       print_trtab = print_trtab2, print_ruletab = print_ruletab2,
   275       print_ast_trtab = print_ast_trtab2, tokentrtab = tokentrtab2, prtabs = prtabs2} = tabs2;
   276   in
   277     Syntax
   278     ({input = merge_lists' input1 input2,
   279       lexicon = Scan.merge_lexicons lexicon1 lexicon2,
   280       gram = Parser.merge_grams gram1 gram2,
   281       consts = sort_distinct string_ord (consts1 @ consts2),
   282       prmodes = merge_lists prmodes1 prmodes2,
   283       parse_ast_trtab =
   284         merge_trtabs "parse ast translation" parse_ast_trtab1 parse_ast_trtab2,
   285       parse_ruletab = merge_ruletabs parse_ruletab1 parse_ruletab2,
   286       parse_trtab = merge_trtabs "parse translation" parse_trtab1 parse_trtab2,
   287       print_trtab = merge_tr'tabs print_trtab1 print_trtab2,
   288       print_ruletab = merge_ruletabs print_ruletab1 print_ruletab2,
   289       print_ast_trtab = merge_tr'tabs print_ast_trtab1 print_ast_trtab2,
   290       tokentrtab = merge_tokentrtabs tokentrtab1 tokentrtab2,
   291       prtabs = Printer.merge_prtabs prtabs1 prtabs2}, stamp ())
   292   end;
   293 
   294 
   295 (* pure_syn *)
   296 
   297 val pure_syn =
   298   empty_syntax
   299   |> extend_syntax default_mode TypeExt.type_ext
   300   |> extend_syntax default_mode SynExt.pure_ext;
   301 
   302 
   303 
   304 (** print syntax **)
   305 
   306 local
   307 
   308 fun pretty_strs_qs name strs =
   309   Pretty.strs (name :: map Library.quote (sort_strings strs));
   310 
   311 fun pretty_gram (Syntax (tabs, _)) =
   312   let
   313     val {lexicon, prmodes, gram, prtabs, ...} = tabs;
   314     val prmodes' = sort_strings (filter_out (equal "") prmodes);
   315   in
   316     [pretty_strs_qs "lexicon:" (Scan.dest_lexicon lexicon),
   317       Pretty.big_list "prods:" (Parser.pretty_gram gram),
   318       pretty_strs_qs "print modes:" prmodes']
   319   end;
   320 
   321 fun pretty_trans (Syntax (tabs, _)) =
   322   let
   323     fun pretty_trtab name tab =
   324       pretty_strs_qs name (Symtab.keys tab);
   325 
   326     fun pretty_ruletab name tab =
   327       Pretty.big_list name (map Ast.pretty_rule (dest_ruletab tab));
   328 
   329     fun pretty_tokentr (mode, trs) = Pretty.strs (Library.quote mode ^ ":" :: map fst trs);
   330 
   331     val {consts, parse_ast_trtab, parse_ruletab, parse_trtab, print_trtab,
   332       print_ruletab, print_ast_trtab, tokentrtab, ...} = tabs;
   333   in
   334     [pretty_strs_qs "consts:" consts,
   335       pretty_trtab "parse_ast_translation:" parse_ast_trtab,
   336       pretty_ruletab "parse_rules:" parse_ruletab,
   337       pretty_trtab "parse_translation:" parse_trtab,
   338       pretty_trtab "print_translation:" print_trtab,
   339       pretty_ruletab "print_rules:" print_ruletab,
   340       pretty_trtab "print_ast_translation:" print_ast_trtab,
   341       Pretty.big_list "token_translation:" (map pretty_tokentr tokentrtab)]
   342   end;
   343 
   344 in
   345 
   346 fun print_gram syn = Pretty.writeln (Pretty.chunks (pretty_gram syn));
   347 fun print_trans syn = Pretty.writeln (Pretty.chunks (pretty_trans syn));
   348 fun print_syntax syn = Pretty.writeln (Pretty.chunks (pretty_gram syn @ pretty_trans syn));
   349 
   350 end;
   351 
   352 
   353 
   354 (** read **)
   355 
   356 (* read_ast *)
   357 
   358 val ambiguity_level = ref 1;
   359 val ambiguity_is_error = ref false
   360 
   361 fun read_asts thy is_logtype (Syntax (tabs, _)) xids root str =
   362   let
   363     val {lexicon, gram, parse_ast_trtab, ...} = tabs;
   364     val root' = if root <> "prop" andalso is_logtype root then SynExt.logic else root;
   365     val chars = Symbol.explode str;
   366     val pts = Parser.parse gram root' (Lexicon.tokenize lexicon xids chars);
   367 
   368     fun show_pt pt =
   369       Pretty.string_of (Ast.pretty_ast (hd (SynTrans.pts_to_asts thy (K NONE) [pt])));
   370   in
   371     conditional (length pts > ! ambiguity_level) (fn () =>
   372       if ! ambiguity_is_error then error ("Ambiguous input " ^ quote str)
   373       else (warning ("Ambiguous input " ^ quote str ^ "\n" ^
   374           "produces " ^ string_of_int (length pts) ^ " parse trees.");
   375          List.app (warning o show_pt) pts));
   376     SynTrans.pts_to_asts thy (lookup_tr parse_ast_trtab) pts
   377   end;
   378 
   379 
   380 (* read *)
   381 
   382 fun read thy is_logtype (syn as Syntax (tabs, _)) ty str =
   383   let
   384     val {parse_ruletab, parse_trtab, ...} = tabs;
   385     val asts = read_asts thy is_logtype syn false (SynExt.typ_to_nonterm ty) str;
   386   in
   387     SynTrans.asts_to_terms thy (lookup_tr parse_trtab)
   388       (map (Ast.normalize_ast (Symtab.lookup_multi parse_ruletab)) asts)
   389   end;
   390 
   391 
   392 (* read types *)
   393 
   394 fun read_typ thy syn get_sort map_sort str =
   395   (case read thy (K false) syn SynExt.typeT str of
   396     [t] => TypeExt.typ_of_term (get_sort (TypeExt.raw_term_sorts t)) map_sort t
   397   | _ => error "read_typ: ambiguous syntax");
   398 
   399 
   400 (* read sorts *)
   401 
   402 fun read_sort thy syn str =
   403   (case read thy (K false) syn TypeExt.sortT str of
   404     [t] => TypeExt.sort_of_term t
   405   | _ => error "read_sort: ambiguous syntax");
   406 
   407 
   408 
   409 (** prepare translation rules **)
   410 
   411 datatype 'a trrule =
   412   ParseRule of 'a * 'a |
   413   PrintRule of 'a * 'a |
   414   ParsePrintRule of 'a * 'a;
   415 
   416 fun map_trrule f (ParseRule (x, y)) = ParseRule (f x, f y)
   417   | map_trrule f (PrintRule (x, y)) = PrintRule (f x, f y)
   418   | map_trrule f (ParsePrintRule (x, y)) = ParsePrintRule (f x, f y);
   419 
   420 fun parse_rule (ParseRule pats) = SOME pats
   421   | parse_rule (PrintRule _) = NONE
   422   | parse_rule (ParsePrintRule pats) = SOME pats;
   423 
   424 fun print_rule (ParseRule _) = NONE
   425   | print_rule (PrintRule pats) = SOME (swap pats)
   426   | print_rule (ParsePrintRule pats) = SOME (swap pats);
   427 
   428 
   429 fun check_rule (rule as (lhs, rhs)) =
   430   (case Ast.rule_error rule of
   431     SOME msg =>
   432       error ("Error in syntax translation rule: " ^ msg ^ "\n" ^
   433         Ast.str_of_ast lhs ^ "  ->  " ^ Ast.str_of_ast rhs)
   434   | NONE => rule);
   435 
   436 
   437 fun read_pattern thy is_logtype syn (root, str) =
   438   let
   439     val Syntax ({consts, ...}, _) = syn;
   440 
   441     fun constify (ast as Ast.Constant _) = ast
   442       | constify (ast as Ast.Variable x) =
   443           if x mem consts orelse NameSpace.is_qualified x then Ast.Constant x
   444           else ast
   445       | constify (Ast.Appl asts) = Ast.Appl (map constify asts);
   446   in
   447     (case read_asts thy is_logtype syn true root str of
   448       [ast] => constify ast
   449     | _ => error ("Syntactically ambiguous input: " ^ quote str))
   450   end handle ERROR =>
   451     error ("The error(s) above occurred in translation pattern " ^
   452       quote str);
   453 
   454 
   455 fun prep_rules rd_pat raw_rules =
   456   let val rules = map (map_trrule rd_pat) raw_rules in
   457     (map check_rule (List.mapPartial parse_rule rules),
   458       map check_rule (List.mapPartial print_rule rules))
   459   end
   460 
   461 
   462 
   463 (** pretty terms, typs, sorts **)
   464 
   465 fun pretty_t t_to_ast prt_t thy (syn as Syntax (tabs, _)) curried t =
   466   let
   467     val {print_trtab, print_ruletab, print_ast_trtab, tokentrtab, prtabs, ...} = tabs;
   468     val ast = t_to_ast thy (lookup_tr' print_trtab) t;
   469   in
   470     prt_t thy curried prtabs (lookup_tr' print_ast_trtab)
   471       (lookup_tokentr tokentrtab (! print_mode))
   472       (Ast.normalize_ast (Symtab.lookup_multi print_ruletab) ast)
   473   end;
   474 
   475 val pretty_term = pretty_t Printer.term_to_ast Printer.pretty_term_ast;
   476 fun pretty_typ thy syn = pretty_t Printer.typ_to_ast Printer.pretty_typ_ast thy syn false;
   477 fun pretty_sort thy syn = pretty_t Printer.sort_to_ast Printer.pretty_typ_ast thy syn false;
   478 
   479 
   480 
   481 (** extend syntax **)
   482 
   483 fun ext_syntax' f is_logtype prmode decls = extend_syntax prmode (f is_logtype decls);
   484 fun ext_syntax f = ext_syntax' (K f) (K false) default_mode;
   485 
   486 val extend_type_gram       = ext_syntax Mixfix.syn_ext_types;
   487 val extend_const_gram      = ext_syntax' Mixfix.syn_ext_consts;
   488 val extend_consts          = ext_syntax SynExt.syn_ext_const_names;
   489 val extend_trfuns          = ext_syntax SynExt.syn_ext_trfuns;
   490 val extend_advanced_trfuns = ext_syntax SynExt.syn_ext_advanced_trfuns;
   491 val extend_tokentrfuns     = ext_syntax SynExt.syn_ext_tokentrfuns;
   492 val extend_trrules_i       = ext_syntax SynExt.syn_ext_rules o prep_rules I;
   493 
   494 fun extend_trrules thy is_logtype syn rules =
   495   ext_syntax' (K SynExt.syn_ext_rules) (K false) default_mode
   496     (prep_rules (read_pattern thy is_logtype syn) rules);
   497 
   498 fun remove_const_gram is_logtype prmode decls =
   499   remove_syntax prmode (Mixfix.syn_ext_consts is_logtype decls);
   500 
   501 
   502 
   503 (*export parts of internal Syntax structures*)
   504 open Lexicon SynExt Ast Parser TypeExt SynTrans Mixfix Printer;
   505 
   506 end;
   507 
   508 structure BasicSyntax: BASIC_SYNTAX = Syntax;
   509 open BasicSyntax;