source: haskell/trunk/ADLParser.hs@ 2

Last change on this file since 2 was 2, checked in by KOBAYASHI, Shinji, 14 years ago

restructure project tree

File size: 1.5 KB
Line 
1module ADLParser where
2
3import Text.ParserCombinators.Parsec
4import Text.ParserCombinators.Parsec.Expr
5import Text.ParserCombinators.Parsec.Char
6import Archetype
7
8adl :: Parser Archetype
9adl = many block
10 where
11 block = do version <- try(adlVersion)
12 return version
13 <|> do name <- try(adlName)
14 return name
15 <|> do concept <- try(adlConcept)
16 return concept
17 <|> do language <- try(adlLanguage)
18 return language
19 <|> do description <- try(adlDescription)
20 return description
21 <|> do definition <- try(adlDefinition)
22 return definition
23 <|> do ontology <- try(adlOntology)
24 return ontology
25
26
27adlVersion :: Parser String
28adlVersion = do dec1 <- string "archetype (adl_version="
29 ver <- many anyChar
30 end <- char ')'
31 return ver
32
33adlName :: Parser String
34adlName = do spaces
35 name <- many anyChar
36 spaces
37 return name
38
39adlConcept :: Parser Concept
40adlConcept = do spaces
41 head <- string "concept"
42 spaces
43 c1 <- char '['
44 at <- many anyChar
45 c2 <- char ']'
46 spaces
47 c3 <- string "--"
48 desc <- many anyChar
49 end <- char '\r'
50
51 return Concept {at, desc]
52
53adlLanguage :: Parser Language
54
Note: See TracBrowser for help on using the repository browser.