Parse_AS_Structured.hs revision 49cd3b8ca4968757bb21874f06de801d2a4764ac
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maeder Author: Till Mossakowski, Christian Maeder
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maeder Year: 2002/2003
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maeder Parsing the Structured part of hetrogenous specifications.
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maeder http://www.cofi.info/Documents/CASL/Summary/
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maeder from 25 March 2001
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maeder C.2.2 Structured Specifications
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maeder fixing of details concerning annos
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maeder logic translations
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maedermodule Parse_AS_Structured where
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maederimport Grothendieck
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maederimport Logic_CASL -- we need the default logic
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maederimport AS_Structured
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maederimport AS_Library
c9b52747a3b65bdf60f47a842a767eb58d7c2b09Klaus Luettichimport AS_Annotation
6588ecc93db54073b171dfa13fdb1edabaad326bChristian Maederimport Anno_Parser
6588ecc93db54073b171dfa13fdb1edabaad326bChristian Maederimport Id(tokPos)
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maederimport Keywords
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maederimport ParsecChar (digit)
6588ecc93db54073b171dfa13fdb1edabaad326bChristian Maederimport Maybe(maybeToList)
d6db74366285d5a0ffec71ac252cfa29800c4855Klaus Luettichimport Print_AS_Structured -- for test purposes
6588ecc93db54073b171dfa13fdb1edabaad326bChristian Maederimport Print_HetCASL
6588ecc93db54073b171dfa13fdb1edabaad326bChristian Maeder------------------------------------------------------------------------
6588ecc93db54073b171dfa13fdb1edabaad326bChristian Maeder-- annotation adapter
6588ecc93db54073b171dfa13fdb1edabaad326bChristian Maeder------------------------------------------------------------------------
6588ecc93db54073b171dfa13fdb1edabaad326bChristian MaederasKey = pToken . toKey
6588ecc93db54073b171dfa13fdb1edabaad326bChristian Maeder-- skip to leading annotation and read many
6588ecc93db54073b171dfa13fdb1edabaad326bChristian Maederannos :: GenParser Char st [Annotation]
6588ecc93db54073b171dfa13fdb1edabaad326bChristian Maederannos = skip >> many (annotationL << skip)
c5e74fe76415b43abbed77f869f7d8e24de817e8Christian MaederannoParser parser = bind (\x y -> Annoted y [] x []) annos parser
c5e74fe76415b43abbed77f869f7d8e24de817e8Christian MaederannoParser2 parser = bind (\x (Annoted y pos l r) -> Annoted y pos (x++l) r) annos parser
c5e74fe76415b43abbed77f869f7d8e24de817e8Christian MaederemptyAnno :: a -> Annoted a
c5e74fe76415b43abbed77f869f7d8e24de817e8Christian MaederemptyAnno x = Annoted x [] [] []
c5e74fe76415b43abbed77f869f7d8e24de817e8Christian Maeder------------------------------------------------------------------------
6588ecc93db54073b171dfa13fdb1edabaad326bChristian Maeder-- simpleIds for spec- and view-name
6588ecc93db54073b171dfa13fdb1edabaad326bChristian Maeder------------------------------------------------------------------------
6588ecc93db54073b171dfa13fdb1edabaad326bChristian MaederlogicS = "logic" -- new keyword
6588ecc93db54073b171dfa13fdb1edabaad326bChristian MaedersimpleId = pToken (reserved (logicS:casl_reserved_words) scanAnyWords)
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maeder------------------------------------------------------------------------
6588ecc93db54073b171dfa13fdb1edabaad326bChristian Maeder-- logic and encoding names
6588ecc93db54073b171dfa13fdb1edabaad326bChristian Maeder------------------------------------------------------------------------
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maeder-- exclude colon (because encoding must be recognized)
6588ecc93db54073b171dfa13fdb1edabaad326bChristian Maeder-- ecclude dot to recognize optional sublogic name
d6db74366285d5a0ffec71ac252cfa29800c4855Klaus LuettichotherChars = "_`"
ea608ca1c00ddcee3d3605b96767b9a116c697fdHeng Jiang-- better list what is allowed rather than exclude what is forbidden
d6db74366285d5a0ffec71ac252cfa29800c4855Klaus Luettich-- white spaces und non-printables should be not allowed!
c9b52747a3b65bdf60f47a842a767eb58d7c2b09Klaus LuettichencodingName = pToken(reserved (funS:casl_reserved_words) (many1
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maeder (oneOf (otherChars ++ (signChars \\ ":."))
5fe1c87d7201d2e97d4ef280c9af0c6eb026e575Christian Maeder <|> scanLPD)))
6588ecc93db54073b171dfa13fdb1edabaad326bChristian Maeder-- keep these identical in order to
f7ef12bb40487f5f910c267aa6c1bf186a8d2752Christian Maeder-- decide after seeing ".", ":" or "->" what was meant
f7ef12bb40487f5f910c267aa6c1bf186a8d2752Christian MaederlogicName = do e <- encodingName
f7ef12bb40487f5f910c267aa6c1bf186a8d2752Christian Maeder do string dotS
f7ef12bb40487f5f910c267aa6c1bf186a8d2752Christian Maeder s <- encodingName
f7ef12bb40487f5f910c267aa6c1bf186a8d2752Christian Maeder return (Logic_name e (Just s))
f7ef12bb40487f5f910c267aa6c1bf186a8d2752Christian Maeder <|> return (Logic_name e Nothing)
f7ef12bb40487f5f910c267aa6c1bf186a8d2752Christian Maeder------------------------------------------------------------------------
f7ef12bb40487f5f910c267aa6c1bf186a8d2752Christian Maeder-- parse Logic_code
f7ef12bb40487f5f910c267aa6c1bf186a8d2752Christian Maeder------------------------------------------------------------------------
f7ef12bb40487f5f910c267aa6c1bf186a8d2752Christian MaederparseLogic :: GenParser Char AnyLogic Logic_code
-- ParsecCombinator.notFollowedBy only allows to check for a single "tok"
return (AS_Library.View_defn vn g vt symbMap
(map tokPos ([s1,s2] ++ ps ++ Maybe.maybeToList q)))
(map tokPos ([s1,s2]++ps++ Maybe.maybeToList q)))