25 deriving Show |
25 deriving Show |
26 data TypesAndVars = TypesAndVars [TypeVarDeclaration] |
26 data TypesAndVars = TypesAndVars [TypeVarDeclaration] |
27 deriving Show |
27 deriving Show |
28 data TypeVarDeclaration = TypeDeclaration Identifier TypeDecl |
28 data TypeVarDeclaration = TypeDeclaration Identifier TypeDecl |
29 | VarDeclaration Bool ([Identifier], TypeDecl) (Maybe InitExpression) |
29 | VarDeclaration Bool ([Identifier], TypeDecl) (Maybe InitExpression) |
30 | FunctionDeclaration Identifier TypeDecl (Maybe (TypesAndVars,Phrase)) |
30 | FunctionDeclaration Identifier TypeDecl (Maybe (TypesAndVars, Phrase)) |
31 deriving Show |
31 deriving Show |
32 data TypeDecl = SimpleType Identifier |
32 data TypeDecl = SimpleType Identifier |
33 | RangeType Range |
33 | RangeType Range |
34 | Sequence [Identifier] |
34 | Sequence [Identifier] |
35 | ArrayDecl Range TypeDecl |
35 | ArrayDecl Range TypeDecl |
52 | WhileCycle Expression Phrase |
52 | WhileCycle Expression Phrase |
53 | RepeatCycle Expression [Phrase] |
53 | RepeatCycle Expression [Phrase] |
54 | ForCycle Identifier Expression Expression Phrase |
54 | ForCycle Identifier Expression Expression Phrase |
55 | WithBlock Reference Phrase |
55 | WithBlock Reference Phrase |
56 | Phrases [Phrase] |
56 | Phrases [Phrase] |
57 | SwitchCase Expression [(Expression, Phrase)] (Maybe Phrase) |
57 | SwitchCase Expression [([Expression], Phrase)] (Maybe Phrase) |
58 | Assignment Reference Expression |
58 | Assignment Reference Expression |
59 deriving Show |
59 deriving Show |
60 data Expression = Expression String |
60 data Expression = Expression String |
61 | BuiltInFunCall [Expression] Reference |
61 | BuiltInFunCall [Expression] Reference |
62 | PrefixOp String Expression |
62 | PrefixOp String Expression |
276 i <- iD |
276 i <- iD |
277 optional $ parens pas $ varsDecl False |
277 optional $ parens pas $ varsDecl False |
278 comments |
278 comments |
279 char ';' |
279 char ';' |
280 comments |
280 comments |
281 b <- if isImpl then |
281 forward <- liftM isJust $ optionMaybe ((try $ string "forward;") >> comments) |
|
282 b <- if isImpl && (not forward) then |
282 liftM Just functionBody |
283 liftM Just functionBody |
283 else |
284 else |
284 return Nothing |
285 return Nothing |
285 comments |
286 -- comments |
286 return $ [FunctionDeclaration i UnknownType b] |
287 return $ [FunctionDeclaration i UnknownType b] |
287 |
288 |
288 funcDecl = do |
289 funcDecl = do |
289 try $ string "function" |
290 try $ string "function" |
290 comments |
291 comments |
339 , parens pas $ expression |
348 , parens pas $ expression |
340 , try $ natural pas >>= \i -> notFollowedBy (char '.') >> (return . NumberLiteral . show) i |
349 , try $ natural pas >>= \i -> notFollowedBy (char '.') >> (return . NumberLiteral . show) i |
341 , try $ float pas >>= return . FloatLiteral . show |
350 , try $ float pas >>= return . FloatLiteral . show |
342 , try $ natural pas >>= return . NumberLiteral . show |
351 , try $ natural pas >>= return . NumberLiteral . show |
343 , stringLiteral pas >>= return . StringLiteral |
352 , stringLiteral pas >>= return . StringLiteral |
344 , char '#' >> many digit >>= return . CharCode |
353 , char '#' >> many digit >>= \c -> comments >> return (CharCode c) |
345 , char '$' >> many hexDigit >>= return . HexNumber |
354 , char '$' >> many hexDigit >>= \h -> comments >> return (HexNumber h) |
346 , char '-' >> expression >>= return . PrefixOp "-" |
355 , char '-' >> expression >>= return . PrefixOp "-" |
347 , try $ string "nil" >> return Null |
356 , try $ string "nil" >> return Null |
348 , reference >>= return . Reference |
357 , reference >>= return . Reference |
349 ] <?> "simple expression" |
358 ] <?> "simple expression" |
350 |
359 |