src/Pure/General/ml_syntax.ML
changeset 21723 88661e47147d
parent 21494 a29412af6aa3
child 21758 6e08004d0476
equal deleted inserted replaced
21722:25239591e732 21723:88661e47147d
     5 Basic ML syntax operations.
     5 Basic ML syntax operations.
     6 *)
     6 *)
     7 
     7 
     8 signature ML_SYNTAX =
     8 signature ML_SYNTAX =
     9 sig
     9 sig
    10   val reserved: string list
    10   val reserved_names: string list
       
    11   val reserved: Name.context
    11   val is_reserved: string -> bool
    12   val is_reserved: string -> bool
    12   val is_identifier: string -> bool
    13   val is_identifier: string -> bool
    13   val str_of_pair: ('a -> string) -> ('b -> string) -> 'a * 'b -> string
    14   val str_of_pair: ('a -> string) -> ('b -> string) -> 'a * 'b -> string
    14   val str_of_list: ('a -> string) -> 'a list -> string
    15   val str_of_list: ('a -> string) -> 'a list -> string
    15   val str_of_option: ('a -> string) -> 'a option -> string
    16   val str_of_option: ('a -> string) -> 'a option -> string
    19 structure ML_Syntax: ML_SYNTAX =
    20 structure ML_Syntax: ML_SYNTAX =
    20 struct
    21 struct
    21 
    22 
    22 (* reserved words *)
    23 (* reserved words *)
    23 
    24 
    24 val reserved =
    25 val reserved_names =
    25  ["abstype", "and", "andalso", "as", "case", "do", "datatype", "else",
    26  ["abstype", "and", "andalso", "as", "case", "do", "datatype", "else",
    26   "end", "exception", "fn", "fun", "handle", "if", "in", "infix",
    27   "end", "exception", "fn", "fun", "handle", "if", "in", "infix",
    27   "infixr", "let", "local", "nonfix", "of", "op", "open", "orelse",
    28   "infixr", "let", "local", "nonfix", "of", "op", "open", "orelse",
    28   "raise", "rec", "then", "type", "val", "with", "withtype", "while",
    29   "raise", "rec", "then", "type", "val", "with", "withtype", "while",
    29   "eqtype", "functor", "include", "sharing", "sig", "signature",
    30   "eqtype", "functor", "include", "sharing", "sig", "signature",
    30   "struct", "structure", "where"];
    31   "struct", "structure", "where"];
    31 
    32 
    32 val is_reserved = member (op =) reserved;
    33 val reserved = Name.make_context reserved_names;
       
    34 val is_reserved = Name.is_declared reserved;
    33 
    35 
    34 
    36 
    35 (* identifiers *)
    37 (* identifiers *)
    36 
    38 
    37 fun is_identifier name =
    39 fun is_identifier name =