author | unc0rr |
Mon, 10 Feb 2014 00:43:03 +0400 | |
changeset 10127 | 7f29a65aa1e4 |
parent 10120 | b7f632c12784 |
child 10129 | cd2a64a1f4aa |
permissions | -rw-r--r-- |
10015 | 1 |
module PascalUnitSyntaxTree where |
2 |
||
3 |
data PascalUnit = |
|
4 |
Program Identifier Implementation Phrase |
|
5 |
| Unit Identifier Interface Implementation (Maybe Initialize) (Maybe Finalize) |
|
6 |
| System [TypeVarDeclaration] |
|
7 |
| Redo [TypeVarDeclaration] |
|
8 |
deriving Show |
|
9 |
data Interface = Interface Uses TypesAndVars |
|
10 |
deriving Show |
|
11 |
data Implementation = Implementation Uses TypesAndVars |
|
12 |
deriving Show |
|
13 |
data Identifier = Identifier String BaseType |
|
14 |
deriving Show |
|
15 |
data TypesAndVars = TypesAndVars [TypeVarDeclaration] |
|
16 |
deriving Show |
|
17 |
data TypeVarDeclaration = TypeDeclaration Identifier TypeDecl |
|
18 |
| VarDeclaration Bool Bool ([Identifier], TypeDecl) (Maybe InitExpression) |
|
19 |
| FunctionDeclaration Identifier Bool Bool TypeDecl [TypeVarDeclaration] (Maybe (TypesAndVars, Phrase)) |
|
20 |
| OperatorDeclaration String Identifier Bool TypeDecl [TypeVarDeclaration] (Maybe (TypesAndVars, Phrase)) |
|
21 |
deriving Show |
|
22 |
data TypeDecl = SimpleType Identifier |
|
23 |
| RangeType Range |
|
24 |
| Sequence [Identifier] |
|
25 |
| ArrayDecl (Maybe Range) TypeDecl |
|
26 |
| RecordType [TypeVarDeclaration] (Maybe [[TypeVarDeclaration]]) |
|
27 |
| PointerTo TypeDecl |
|
10111
459bc720cea1
Drop support for other string types than string255
unc0rr
parents:
10015
diff
changeset
|
28 |
| String |
10120 | 29 |
| AString |
10015 | 30 |
| Set TypeDecl |
31 |
| FunctionType TypeDecl [TypeVarDeclaration] |
|
32 |
| DeriveType InitExpression |
|
33 |
| VoidType |
|
34 |
| VarParamType TypeDecl -- this is a hack |
|
35 |
deriving Show |
|
36 |
data Range = Range Identifier |
|
37 |
| RangeFromTo InitExpression InitExpression |
|
38 |
| RangeInfinite |
|
39 |
deriving Show |
|
40 |
data Initialize = Initialize String |
|
41 |
deriving Show |
|
42 |
data Finalize = Finalize String |
|
43 |
deriving Show |
|
44 |
data Uses = Uses [Identifier] |
|
45 |
deriving Show |
|
46 |
data Phrase = ProcCall Reference [Expression] |
|
47 |
| IfThenElse Expression Phrase (Maybe Phrase) |
|
48 |
| WhileCycle Expression Phrase |
|
49 |
| RepeatCycle Expression [Phrase] |
|
50 |
| ForCycle Identifier Expression Expression Phrase Bool -- The last Boolean indicates wether it's up or down counting |
|
51 |
| WithBlock Reference Phrase |
|
52 |
| Phrases [Phrase] |
|
53 |
| SwitchCase Expression [([InitExpression], Phrase)] (Maybe [Phrase]) |
|
54 |
| Assignment Reference Expression |
|
55 |
| BuiltInFunctionCall [Expression] Reference |
|
56 |
| NOP |
|
57 |
deriving Show |
|
58 |
data Expression = Expression String |
|
59 |
| BuiltInFunCall [Expression] Reference |
|
60 |
| PrefixOp String Expression |
|
61 |
| PostfixOp String Expression |
|
62 |
| BinOp String Expression Expression |
|
63 |
| StringLiteral String |
|
64 |
| PCharLiteral String |
|
65 |
| CharCode String |
|
66 |
| HexCharCode String |
|
67 |
| NumberLiteral String |
|
68 |
| FloatLiteral String |
|
69 |
| HexNumber String |
|
70 |
| Reference Reference |
|
71 |
| SetExpression [Identifier] |
|
72 |
| Null |
|
73 |
deriving Show |
|
74 |
data Reference = ArrayElement [Expression] Reference |
|
75 |
| FunCall [Expression] Reference |
|
76 |
| TypeCast Identifier Expression |
|
77 |
| SimpleReference Identifier |
|
78 |
| Dereference Reference |
|
79 |
| RecordField Reference Reference |
|
80 |
| Address Reference |
|
81 |
| RefExpression Expression |
|
82 |
deriving Show |
|
83 |
data InitExpression = InitBinOp String InitExpression InitExpression |
|
84 |
| InitPrefixOp String InitExpression |
|
85 |
| InitReference Identifier |
|
86 |
| InitArray [InitExpression] |
|
87 |
| InitRecord [(Identifier, InitExpression)] |
|
88 |
| InitFloat String |
|
89 |
| InitNumber String |
|
90 |
| InitHexNumber String |
|
91 |
| InitString String |
|
92 |
| InitChar String |
|
93 |
| BuiltInFunction String [InitExpression] |
|
94 |
| InitSet [InitExpression] |
|
95 |
| InitAddress InitExpression |
|
96 |
| InitNull |
|
97 |
| InitRange Range |
|
98 |
| InitTypeCast Identifier InitExpression |
|
99 |
deriving Show |
|
100 |
||
101 |
data BaseType = BTUnknown |
|
102 |
| BTChar |
|
103 |
| BTString |
|
10120 | 104 |
| BTAString |
10015 | 105 |
| BTInt Bool -- second param indicates whether signed or not |
106 |
| BTBool |
|
107 |
| BTFloat |
|
108 |
| BTRecord String [(String, BaseType)] |
|
109 |
| BTArray Range BaseType BaseType |
|
110 |
| BTFunction Bool [(Bool, BaseType)] BaseType -- (Bool, BaseType), Bool indiciates whether var or not |
|
111 |
| BTPointerTo BaseType |
|
112 |
| BTUnresolved String |
|
113 |
| BTSet BaseType |
|
114 |
| BTEnum [String] |
|
115 |
| BTVoid |
|
116 |
| BTUnit |
|
117 |
| BTVarParam BaseType |
|
118 |
deriving Show |