src/Pure/Syntax/lexicon.ML
changeset 42046 6341c23baf10
parent 40525 14a2e686bdac
child 42048 afd11ca8e018
equal deleted inserted replaced
42045:fda09013c496 42046:6341c23baf10
    40     case_type: string -> 'a,
    40     case_type: string -> 'a,
    41     case_const: string -> 'a,
    41     case_const: string -> 'a,
    42     case_fixed: string -> 'a,
    42     case_fixed: string -> 'a,
    43     case_default: string -> 'a} -> string -> 'a
    43     case_default: string -> 'a} -> string -> 'a
    44   val is_marked: string -> bool
    44   val is_marked: string -> bool
       
    45   val encode_position: Position.T -> string
       
    46   val decode_position: string -> Position.T option
    45 end;
    47 end;
    46 
    48 
    47 signature LEXICON =
    49 signature LEXICON =
    48 sig
    50 sig
    49   include LEXICON0
    51   include LEXICON0
   447         (intpart, "." :: fracpart) => (intpart, fracpart)
   449         (intpart, "." :: fracpart) => (intpart, fracpart)
   448       | _ => raise Fail "read_float");
   450       | _ => raise Fail "read_float");
   449   in
   451   in
   450    {mant = sign * #1 (Library.read_int (intpart @ fracpart)),
   452    {mant = sign * #1 (Library.read_int (intpart @ fracpart)),
   451     exp = length fracpart}
   453     exp = length fracpart}
   452   end
   454   end;
   453 
   455 
   454 end;
   456 
       
   457 (* positions *)
       
   458 
       
   459 fun encode_position pos =
       
   460   op ^ (YXML.output_markup (Position.markup pos Markup.position));
       
   461 
       
   462 fun decode_position str =
       
   463   (case YXML.parse_body str handle Fail msg => error msg of
       
   464     [XML.Elem ((name, props), [])] =>
       
   465       if name = Markup.positionN then SOME (Position.of_properties props)
       
   466       else NONE
       
   467   | _ => NONE);
       
   468 
       
   469 end;