Improve type declarations parsing
authorunc0rr
Tue, 08 Nov 2011 22:05:33 +0300
changeset 6310 31145a87811a
parent 6309 82e846e5d502
child 6311 1f7af64d5565
Improve type declarations parsing
tools/PascalParser.hs
--- a/tools/PascalParser.hs	Mon Nov 07 17:37:00 2011 -0500
+++ b/tools/PascalParser.hs	Tue Nov 08 22:05:33 2011 +0300
@@ -65,12 +65,12 @@
     | HexNumber String
     | Address Reference
     | Reference Reference
+    | Dereference Expression
+    | RecordField Expression Expression
     | Null
     deriving Show
 data Reference = ArrayElement Identifier Expression
     | SimpleReference Identifier
-    | RecordField Reference Reference
-    | Dereference Reference
     deriving Show
     
 pascalLanguageDef
@@ -152,8 +152,6 @@
         ] <?> "simple reference"
 
     table = [ 
-        [Postfix (char '^' >> return Dereference)]
-        , [Infix (char '.' >> return RecordField) AssocLeft]
         ]
     
 varsDecl1 = varsParser sepEndBy1    
@@ -211,7 +209,7 @@
     , arrayDecl
     , recordDecl
     , rangeDecl >>= return . RangeType
-    , seqenceDecl >>= return . Sequence
+    , sequenceDecl >>= return . Sequence
     , identifier pas >>= return . SimpleType . Identifier
     ] <?> "type declaration"
     where
@@ -233,7 +231,7 @@
         vs <- varsDecl True
         string "end"
         return $ RecordType vs
-    seqenceDecl = (parens pas) $ (commaSep pas) iD
+    sequenceDecl = (parens pas) $ (commaSep pas) iD
 
 typesDecl = many (aTypeDecl >>= \t -> comments >> return t)
     where
@@ -403,6 +401,8 @@
            , Infix (try $ string "shr" >> return (BinOp "or")) AssocNone
           ]
         , [Prefix (try (string "not") >> return (PrefixOp "not"))]
+        , [Postfix (char '^' >> return Dereference)]
+        , [Infix (try (char '.' >> notFollowedBy (char '.')) >> return RecordField) AssocLeft]
         ]
     
 phrasesBlock = do