src/Pure/Isar/outer_parse.ML
changeset 7026 69724548fad1
parent 6983 7f28cd9cfe72
child 7171 2a245a80a2c5
equal deleted inserted replaced
7025:afbd8241797b 7026:69724548fad1
    10   type token
    10   type token
    11   val group: string -> (token list -> 'a) -> token list -> 'a
    11   val group: string -> (token list -> 'a) -> token list -> 'a
    12   val !!! : (token list -> 'a) -> token list -> 'a
    12   val !!! : (token list -> 'a) -> token list -> 'a
    13   val $$$ : string -> token list -> string * token list
    13   val $$$ : string -> token list -> string * token list
    14   val position: (token list -> 'a * 'b) -> token list -> ('a * Position.T) * 'b
    14   val position: (token list -> 'a * 'b) -> token list -> ('a * Position.T) * 'b
       
    15   val command: token list -> string * token list
    15   val keyword: token list -> string * token list
    16   val keyword: token list -> string * token list
    16   val short_ident: token list -> string * token list
    17   val short_ident: token list -> string * token list
    17   val long_ident: token list -> string * token list
    18   val long_ident: token list -> string * token list
    18   val sym_ident: token list -> string * token list
    19   val sym_ident: token list -> string * token list
    19   val term_var: token list -> string * token list
    20   val term_var: token list -> string * token list
   112 
   113 
   113 fun kind k =
   114 fun kind k =
   114   group (OuterLex.str_of_kind k)
   115   group (OuterLex.str_of_kind k)
   115     (Scan.one (OuterLex.is_kind k) >> OuterLex.val_of);
   116     (Scan.one (OuterLex.is_kind k) >> OuterLex.val_of);
   116 
   117 
       
   118 val command = kind OuterLex.Command;
   117 val keyword = kind OuterLex.Keyword;
   119 val keyword = kind OuterLex.Keyword;
   118 val short_ident = kind OuterLex.Ident;
   120 val short_ident = kind OuterLex.Ident;
   119 val long_ident = kind OuterLex.LongIdent;
   121 val long_ident = kind OuterLex.LongIdent;
   120 val sym_ident = kind OuterLex.SymIdent;
   122 val sym_ident = kind OuterLex.SymIdent;
   121 val term_var = kind OuterLex.Var;
   123 val term_var = kind OuterLex.Var;
   128 val sync = kind OuterLex.Sync;
   130 val sync = kind OuterLex.Sync;
   129 val eof = kind OuterLex.EOF;
   131 val eof = kind OuterLex.EOF;
   130 
   132 
   131 fun $$$ x =
   133 fun $$$ x =
   132   group (OuterLex.str_of_kind OuterLex.Keyword ^ " " ^ quote x)
   134   group (OuterLex.str_of_kind OuterLex.Keyword ^ " " ^ quote x)
   133     (Scan.one (OuterLex.is_kind OuterLex.Keyword andf (equal x o OuterLex.val_of))
   135     (Scan.one (OuterLex.keyword_with (equal x)) >> OuterLex.val_of);
   134       >> OuterLex.val_of);
       
   135 
   136 
   136 val nat = number >> (fst o Term.read_int o Symbol.explode);
   137 val nat = number >> (fst o Term.read_int o Symbol.explode);
   137 
   138 
   138 val not_eof = Scan.one OuterLex.not_eof;
   139 val not_eof = Scan.one OuterLex.not_eof;
   139 
   140 
   236 val termp = term -- Scan.optional ($$$ "(" |-- !!! (is_terms --| $$$ ")")) [];
   237 val termp = term -- Scan.optional ($$$ "(" |-- !!! (is_terms --| $$$ ")")) [];
   237 
   238 
   238 
   239 
   239 (* arguments *)
   240 (* arguments *)
   240 
   241 
   241 fun keyword_symid is_symid = Scan.one (OuterLex.keyword_pred is_symid) >> OuterLex.val_of;
   242 fun keyword_symid is_symid = Scan.one (OuterLex.keyword_with is_symid) >> OuterLex.val_of;
   242 
   243 
   243 fun atom_arg is_symid blk =
   244 fun atom_arg is_symid blk =
   244   group "argument"
   245   group "argument"
   245     (position (short_ident || long_ident || sym_ident || term_var || text_var ||
   246     (position (short_ident || long_ident || sym_ident || term_var || text_var ||
   246         type_ident || type_var || number) >> Args.ident ||
   247         type_ident || type_var || number) >> Args.ident ||