src/Pure/Syntax/syntax.ML
changeset 27803 c08f4ea29b83
parent 27786 4525c6f5d753
child 27808 4dd3d5efcc7f
equal deleted inserted replaced
27802:1eddcd7dda2d 27803:c08f4ea29b83
   459 
   459 
   460 (* read token -- with optional YXML encoding of position *)
   460 (* read token -- with optional YXML encoding of position *)
   461 
   461 
   462 fun read_token str =
   462 fun read_token str =
   463   let val (text, pos) =
   463   let val (text, pos) =
   464     if YXML.detect str then
   464     (case YXML.parse str handle Fail msg => error msg of
   465       (case YXML.parse str of
   465       XML.Elem ("token", props, [XML.Text text]) => (text, Position.of_properties props)
   466         XML.Elem ("token", props, [XML.Text text]) =>
   466     | XML.Elem ("token", props, []) => ("", Position.of_properties props)
   467           let val pos = Position.of_properties props;
   467     | XML.Text text => (text, Position.none)
   468           in (text, pos) end
   468     | _ => (str, Position.none))
   469       | _ => (str, Position.none))
       
   470     else (str, Position.none)
       
   471   in (SymbolPos.explode (text, pos), pos) end;
   469   in (SymbolPos.explode (text, pos), pos) end;
   472 
   470 
   473 
   471 
   474 (* read_ast *)
   472 (* read_ast *)
   475 
   473