Id.hs revision 6f3198a56c02c18d02d19b4aaad1c395686aec07
c797f343be2f3619bb1f5569753166ec49d27bdbChristian Maedermodule Id where
c797f343be2f3619bb1f5569753166ec49d27bdbChristian Maeder
81d182b21020b815887e9057959228546cf61b6bChristian Maeder-- identifiers, fixed for all logics
10397bcc134edbcfbe3ae2c7ea4c6080036aae22Christian Maeder{-
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian Maederdata ID = Simple_Id String
c797f343be2f3619bb1f5569753166ec49d27bdbChristian Maeder | Compound_Id (String,[ID])
3f69b6948966979163bdfe8331c38833d5d90ecdChristian Maeder
c797f343be2f3619bb1f5569753166ec49d27bdbChristian Maeder-}
e95bbf384f5cbcb7eb23286d5f15dffbd471db17Christian Maedertype Pos = (Int, Int) -- line, column
f3a94a197960e548ecd6520bb768cb0d547457bbChristian Maeder
f3a94a197960e548ecd6520bb768cb0d547457bbChristian MaedernullPos :: Pos
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian MaedernullPos = (0,0) -- dummy position
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian Maeder
f454c20b6c126bea7d31d400cc8824b9ee8cc6eaChristian Maedertype Region = (Pos,Pos)
f454c20b6c126bea7d31d400cc8824b9ee8cc6eaChristian Maeder
9659c509ce5e78adc51d7b02a76274eddcba9338Christian Maeder
f454c20b6c126bea7d31d400cc8824b9ee8cc6eaChristian Maeder-- tokens as supplied by the scanner
0a320bc4cdbf38f480b75ac15a54db1c4885b497Christian Maederdata Token = Token(String, Pos)
f454c20b6c126bea7d31d400cc8824b9ee8cc6eaChristian Maeder
f454c20b6c126bea7d31d400cc8824b9ee8cc6eaChristian Maederinstance Eq Token where
59c301c268f79cfde0a4c30a2c572a368db98da5Christian Maeder Token(s1, _) == Token(s2, _) = s1 == s2
f454c20b6c126bea7d31d400cc8824b9ee8cc6eaChristian Maeder
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian Maederinstance Ord Token where
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian Maeder Token(s1, _) <= Token(s2, _) = s1 <= s2
23a00c966f2aa8da525d7a7c51933c99964426c0Christian Maeder
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maederinstance Show Token where
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder showsPrec _ (Token(t, _)) = showString t
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian Maeder
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian Maeder-- spezial tokens
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian Maedertype Keyword = Token
59c301c268f79cfde0a4c30a2c572a368db98da5Christian Maedertype TokenOrPlace = Token
f454c20b6c126bea7d31d400cc8824b9ee8cc6eaChristian Maeder
10397bcc134edbcfbe3ae2c7ea4c6080036aae22Christian Maeder-- move to scanner
04dada28736b4a237745e92063d8bdd49a362debChristian MaedersetPos(Token(t, _), p) = Token(t, p)
b984ff0ba75221f64451c1e69b3977967d4e99a1Christian Maeder
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maederplace = "__"
ad270004874ce1d0697fb30d7309f180553bb315Christian Maeder
ad270004874ce1d0697fb30d7309f180553bb315Christian MaederisPlace(Token(t, _)) = t == place
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder
89054b2b95a3f92e78324dc852f3d34704e2ca49Christian Maeder-- an identifier may be mixfix (though not for a sort) and compound
b984ff0ba75221f64451c1e69b3977967d4e99a1Christian Maederdata Id = Id([TokenOrPlace], [Id]) deriving (Eq, Ord)
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maederinstance Show Id where
32a7cc7177ecf70e35ec831ff86887b9acc40dcaChristian Maeder showsPrec _ (Id(ts, is)) = showString ((foldl (++) "" (map show ts)) ++
32a7cc7177ecf70e35ec831ff86887b9acc40dcaChristian Maeder (show is))