101 , "implementation", "and", "or", "xor", "shl" |
101 , "implementation", "and", "or", "xor", "shl" |
102 , "shr", "while", "do", "repeat", "until", "case", "of" |
102 , "shr", "while", "do", "repeat", "until", "case", "of" |
103 , "type", "var", "const", "out", "array", "packed" |
103 , "type", "var", "const", "out", "array", "packed" |
104 , "procedure", "function", "with", "for", "to" |
104 , "procedure", "function", "with", "for", "to" |
105 , "downto", "div", "mod", "record", "set", "nil" |
105 , "downto", "div", "mod", "record", "set", "nil" |
106 , "string", "shortstring", "succ", "pred", "low" |
106 , "string", "shortstring"--, "succ", "pred", "low" |
107 , "high" |
107 --, "high" |
108 ] |
108 ] |
109 , reservedOpNames= [] |
109 , reservedOpNames= [] |
110 , caseSensitive = False |
110 , caseSensitive = False |
111 } |
111 } |
112 |
112 |
160 |
160 |
161 |
161 |
162 reference = buildExpressionParser table term <?> "reference" |
162 reference = buildExpressionParser table term <?> "reference" |
163 where |
163 where |
164 term = comments >> choice [ |
164 term = comments >> choice [ |
165 parens pas reference |
165 parens pas (reference >>= postfixes) >>= postfixes |
166 , char '@' >> reference >>= return . Address |
166 , char '@' >> reference >>= postfixes >>= return . Address |
167 , iD >>= return . SimpleReference |
167 , liftM SimpleReference iD >>= postfixes |
168 ] <?> "simple reference" |
168 ] <?> "simple reference" |
169 |
169 |
170 table = [ |
170 table = [ |
171 [Postfix $ (parens pas) (option [] parameters) >>= return . FunCall] |
171 [Infix (try (char '.' >> notFollowedBy (char '.')) >> return RecordField) AssocLeft] |
172 , [Postfix (char '^' >> return Dereference)] |
|
173 , [Postfix $ (brackets pas) (commaSep1 pas $ expression) >>= return . ArrayElement] |
|
174 , [Infix (try (char '.' >> notFollowedBy (char '.')) >> return RecordField) AssocLeft] |
|
175 ] |
172 ] |
|
173 |
|
174 postfixes r = many postfix >>= return . foldl fp r |
|
175 postfix = choice [ |
|
176 parens pas (option [] parameters) >>= return . FunCall |
|
177 , char '^' >> return Dereference |
|
178 , (brackets pas) (commaSep1 pas $ expression) >>= return . ArrayElement |
|
179 ] |
|
180 fp r f = f r |
176 |
181 |
177 |
182 |
178 varsDecl1 = varsParser sepEndBy1 |
183 varsDecl1 = varsParser sepEndBy1 |
179 varsDecl = varsParser sepEndBy |
184 varsDecl = varsParser sepEndBy |
180 varsParser m endsWithSemi = do |
185 varsParser m endsWithSemi = do |