src/Tools/Haskell/Haskell.thy
changeset 78021 ce6e3bc34343
parent 77029 1046a69fabaa
child 78307 4c8b04679944
equal deleted inserted replaced
78020:1a829342a2d3 78021:ce6e3bc34343
   730 
   730 
   731   bindingN, binding, entityN, entity, defN, refN,
   731   bindingN, binding, entityN, entity, defN, refN,
   732 
   732 
   733   completionN, completion, no_completionN, no_completion,
   733   completionN, completion, no_completionN, no_completion,
   734 
   734 
   735   lineN, end_lineN, offsetN, end_offsetN, fileN, idN, positionN, position,
   735   lineN, end_lineN, offsetN, end_offsetN, labelN, fileN, idN, positionN, position,
   736   position_properties, def_name,
   736   position_properties, def_name,
   737 
   737 
   738   expressionN, expression,
   738   expressionN, expression,
   739 
   739 
   740   pathN, path, urlN, url, docN, doc,
   740   pathN, path, urlN, url, docN, doc,
   864 
   864 
   865 offsetN, end_offsetN :: Bytes
   865 offsetN, end_offsetN :: Bytes
   866 offsetN = \<open>Markup.offsetN\<close>
   866 offsetN = \<open>Markup.offsetN\<close>
   867 end_offsetN = \<open>Markup.end_offsetN\<close>
   867 end_offsetN = \<open>Markup.end_offsetN\<close>
   868 
   868 
   869 fileN, idN :: Bytes
   869 labelN, fileN, idN :: Bytes
       
   870 labelN = \<open>Markup.labelN\<close>
   870 fileN = \<open>Markup.fileN\<close>
   871 fileN = \<open>Markup.fileN\<close>
   871 idN = \<open>Markup.idN\<close>
   872 idN = \<open>Markup.idN\<close>
   872 
   873 
   873 positionN :: Bytes
   874 positionN :: Bytes
   874 positionN = \<open>Markup.positionN\<close>
   875 positionN = \<open>Markup.positionN\<close>
   875 position :: T
   876 position :: T
   876 position = markup_elem positionN
   877 position = markup_elem positionN
   877 
   878 
   878 position_properties :: [Bytes]
   879 position_properties :: [Bytes]
   879 position_properties = [lineN, offsetN, end_offsetN, fileN, idN]
   880 position_properties = [lineN, offsetN, end_offsetN, labelN, fileN, idN]
   880 
   881 
   881 
   882 
   882 {- position "def" names -}
   883 {- position "def" names -}
   883 
   884 
   884 make_def :: Bytes -> Bytes
   885 make_def :: Bytes -> Bytes
  1281   Position {
  1282   Position {
  1282     _line :: Int,
  1283     _line :: Int,
  1283     _column :: Int,
  1284     _column :: Int,
  1284     _offset :: Int,
  1285     _offset :: Int,
  1285     _end_offset :: Int,
  1286     _end_offset :: Int,
       
  1287     _label :: Bytes,
  1286     _file :: Bytes,
  1288     _file :: Bytes,
  1287     _id :: Bytes }
  1289     _id :: Bytes }
  1288   deriving (Eq, Ord)
  1290   deriving (Eq, Ord)
  1289 
  1291 
  1290 valid, invalid :: Int -> Bool
  1292 valid, invalid :: Int -> Bool
  1304 line_of = maybe_valid . _line
  1306 line_of = maybe_valid . _line
  1305 column_of = maybe_valid . _column
  1307 column_of = maybe_valid . _column
  1306 offset_of = maybe_valid . _offset
  1308 offset_of = maybe_valid . _offset
  1307 end_offset_of = maybe_valid . _end_offset
  1309 end_offset_of = maybe_valid . _end_offset
  1308 
  1310 
       
  1311 label_of :: T -> Maybe Bytes
       
  1312 label_of = proper_string . _label
       
  1313 
  1309 file_of :: T -> Maybe Bytes
  1314 file_of :: T -> Maybe Bytes
  1310 file_of = proper_string . _file
  1315 file_of = proper_string . _file
  1311 
  1316 
  1312 id_of :: T -> Maybe Bytes
  1317 id_of :: T -> Maybe Bytes
  1313 id_of = proper_string . _id
  1318 id_of = proper_string . _id
  1314 
  1319 
  1315 
  1320 
  1316 {- make position -}
  1321 {- make position -}
  1317 
  1322 
  1318 start :: T
  1323 start :: T
  1319 start = Position 1 1 1 0 Bytes.empty Bytes.empty
  1324 start = Position 1 1 1 0 Bytes.empty Bytes.empty Bytes.empty
  1320 
  1325 
  1321 none :: T
  1326 none :: T
  1322 none = Position 0 0 0 0 Bytes.empty Bytes.empty
  1327 none = Position 0 0 0 0 Bytes.empty Bytes.empty Bytes.empty
       
  1328 
       
  1329 label :: Bytes -> T -> T
       
  1330 label label pos = pos { _label = label }
  1323 
  1331 
  1324 put_file :: Bytes -> T -> T
  1332 put_file :: Bytes -> T -> T
  1325 put_file file pos = pos { _file = file }
  1333 put_file file pos = pos { _file = file }
  1326 
  1334 
  1327 file :: Bytes -> T
  1335 file :: Bytes -> T
  1390 of_properties props =
  1398 of_properties props =
  1391   none {
  1399   none {
  1392     _line = get_int props Markup.lineN,
  1400     _line = get_int props Markup.lineN,
  1393     _offset = get_int props Markup.offsetN,
  1401     _offset = get_int props Markup.offsetN,
  1394     _end_offset = get_int props Markup.end_offsetN,
  1402     _end_offset = get_int props Markup.end_offsetN,
       
  1403     _label = get_string props Markup.labelN,
  1395     _file = get_string props Markup.fileN,
  1404     _file = get_string props Markup.fileN,
  1396     _id = get_string props Markup.idN }
  1405     _id = get_string props Markup.idN }
  1397 
  1406 
  1398 string_entry :: Bytes -> Bytes -> Properties.T
  1407 string_entry :: Bytes -> Bytes -> Properties.T
  1399 string_entry k s = if Bytes.null s then [] else [(k, s)]
  1408 string_entry k s = if Bytes.null s then [] else [(k, s)]
  1404 properties_of :: T -> Properties.T
  1413 properties_of :: T -> Properties.T
  1405 properties_of pos =
  1414 properties_of pos =
  1406   int_entry Markup.lineN (_line pos) ++
  1415   int_entry Markup.lineN (_line pos) ++
  1407   int_entry Markup.offsetN (_offset pos) ++
  1416   int_entry Markup.offsetN (_offset pos) ++
  1408   int_entry Markup.end_offsetN (_end_offset pos) ++
  1417   int_entry Markup.end_offsetN (_end_offset pos) ++
       
  1418   string_entry Markup.labelN (_label pos) ++
  1409   string_entry Markup.fileN (_file pos) ++
  1419   string_entry Markup.fileN (_file pos) ++
  1410   string_entry Markup.idN (_id pos)
  1420   string_entry Markup.idN (_id pos)
  1411 
  1421 
  1412 def_properties_of :: T -> Properties.T
  1422 def_properties_of :: T -> Properties.T
  1413 def_properties_of = properties_of #> map (first Markup.def_name)
  1423 def_properties_of = properties_of #> map (first Markup.def_name)