tools/PascalParser.hs
changeset 6512 0df7f6697939
parent 6489 e1f0058cfedd
child 6618 2d3232069c4b
equal deleted inserted replaced
6511:bc6e67598dde 6512:0df7f6697939
    16     
    16     
    17 knownTypes = ["shortstring", "char", "byte"]
    17 knownTypes = ["shortstring", "char", "byte"]
    18 
    18 
    19 pascalUnit = do
    19 pascalUnit = do
    20     comments
    20     comments
    21     u <- choice [program, unit]
    21     u <- choice [program, unit, systemUnit]
    22     comments
    22     comments
    23     return u
    23     return u
    24 
    24 
    25 iD = do
    25 iD = do
    26     i <- liftM (flip Identifier Unknown) (identifier pas)
    26     i <- liftM (flip Identifier Unknown) (identifier pas)
   597     name <- choice $ map (\s -> try $ caseInsensitiveString s >>= \i -> notFollowedBy alphaNum >> return i) builtin
   597     name <- choice $ map (\s -> try $ caseInsensitiveString s >>= \i -> notFollowedBy alphaNum >> return i) builtin
   598     spaces
   598     spaces
   599     exprs <- parens pas $ commaSep1 pas $ e
   599     exprs <- parens pas $ commaSep1 pas $ e
   600     spaces
   600     spaces
   601     return (name, exprs)
   601     return (name, exprs)
   602         
   602 
       
   603 systemUnit = do
       
   604     string "system;"
       
   605     comments
       
   606     string "type"
       
   607     comments
       
   608     t <- typesDecl
       
   609     string "var"
       
   610     v <- varsDecl True
       
   611     return $ System (t ++ v)