|
1 module PascalUnitSyntaxTree where |
|
2 |
|
3 import Data.Traversable |
|
4 |
|
5 data PascalUnit = |
|
6 Program Identifier Implementation Phrase |
|
7 | Unit Identifier Interface Implementation (Maybe Initialize) (Maybe Finalize) |
|
8 | System |
|
9 deriving Show |
|
10 data Interface = Interface Uses TypesAndVars |
|
11 deriving Show |
|
12 data Implementation = Implementation Uses TypesAndVars |
|
13 deriving Show |
|
14 data Identifier = Identifier String |
|
15 deriving Show |
|
16 data TypesAndVars = TypesAndVars [TypeVarDeclaration] |
|
17 deriving Show |
|
18 data TypeVarDeclaration = TypeDeclaration Identifier TypeDecl |
|
19 | VarDeclaration Bool ([Identifier], TypeDecl) (Maybe InitExpression) |
|
20 | FunctionDeclaration Identifier TypeDecl [TypeVarDeclaration] (Maybe (TypesAndVars, Phrase)) |
|
21 | OperatorDeclaration String Identifier TypeDecl [TypeVarDeclaration] (Maybe (TypesAndVars, Phrase)) |
|
22 deriving Show |
|
23 data TypeDecl = SimpleType Identifier |
|
24 | RangeType Range |
|
25 | Sequence [Identifier] |
|
26 | ArrayDecl (Maybe Range) TypeDecl |
|
27 | RecordType [TypeVarDeclaration] (Maybe [[TypeVarDeclaration]]) |
|
28 | PointerTo TypeDecl |
|
29 | String Integer |
|
30 | Set TypeDecl |
|
31 | FunctionType TypeDecl [TypeVarDeclaration] |
|
32 | UnknownType |
|
33 deriving Show |
|
34 data Range = Range Identifier |
|
35 | RangeFromTo InitExpression InitExpression |
|
36 deriving Show |
|
37 data Initialize = Initialize String |
|
38 deriving Show |
|
39 data Finalize = Finalize String |
|
40 deriving Show |
|
41 data Uses = Uses [Identifier] |
|
42 deriving Show |
|
43 data Phrase = ProcCall Reference [Expression] |
|
44 | IfThenElse Expression Phrase (Maybe Phrase) |
|
45 | WhileCycle Expression Phrase |
|
46 | RepeatCycle Expression [Phrase] |
|
47 | ForCycle Identifier Expression Expression Phrase |
|
48 | WithBlock Reference Phrase |
|
49 | Phrases [Phrase] |
|
50 | SwitchCase Expression [([InitExpression], Phrase)] (Maybe [Phrase]) |
|
51 | Assignment Reference Expression |
|
52 | NOP |
|
53 deriving Show |
|
54 data Expression = Expression String |
|
55 | BuiltInFunCall [Expression] Reference |
|
56 | PrefixOp String Expression |
|
57 | PostfixOp String Expression |
|
58 | BinOp String Expression Expression |
|
59 | StringLiteral String |
|
60 | CharCode String |
|
61 | HexCharCode String |
|
62 | NumberLiteral String |
|
63 | FloatLiteral String |
|
64 | HexNumber String |
|
65 | Reference Reference |
|
66 | SetExpression [Identifier] |
|
67 | Null |
|
68 deriving Show |
|
69 data Reference = ArrayElement [Expression] Reference |
|
70 | FunCall [Expression] Reference |
|
71 | TypeCast Identifier Expression |
|
72 | SimpleReference Identifier |
|
73 | Dereference Reference |
|
74 | RecordField Reference Reference |
|
75 | Address Reference |
|
76 | RefExpression Expression |
|
77 deriving Show |
|
78 data InitExpression = InitBinOp String InitExpression InitExpression |
|
79 | InitPrefixOp String InitExpression |
|
80 | InitReference Identifier |
|
81 | InitArray [InitExpression] |
|
82 | InitRecord [(Identifier, InitExpression)] |
|
83 | InitFloat String |
|
84 | InitNumber String |
|
85 | InitHexNumber String |
|
86 | InitString String |
|
87 | InitChar String |
|
88 | BuiltInFunction String [InitExpression] |
|
89 | InitSet [InitExpression] |
|
90 | InitAddress InitExpression |
|
91 | InitNull |
|
92 | InitRange Range |
|
93 | InitTypeCast Identifier InitExpression |
|
94 deriving Show |