author | unc0rr |
Fri, 07 Feb 2014 00:46:49 +0400 | |
changeset 10113 | b26c2772e754 |
parent 10111 | 459bc720cea1 |
child 10120 | b7f632c12784 |
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 |
10015 | 29 |
| Set TypeDecl |
30 |
| FunctionType TypeDecl [TypeVarDeclaration] |
|
31 |
| DeriveType InitExpression |
|
32 |
| VoidType |
|
33 |
| VarParamType TypeDecl -- this is a hack |
|
34 |
deriving Show |
|
35 |
data Range = Range Identifier |
|
36 |
| RangeFromTo InitExpression InitExpression |
|
37 |
| RangeInfinite |
|
38 |
deriving Show |
|
39 |
data Initialize = Initialize String |
|
40 |
deriving Show |
|
41 |
data Finalize = Finalize String |
|
42 |
deriving Show |
|
43 |
data Uses = Uses [Identifier] |
|
44 |
deriving Show |
|
45 |
data Phrase = ProcCall Reference [Expression] |
|
46 |
| IfThenElse Expression Phrase (Maybe Phrase) |
|
47 |
| WhileCycle Expression Phrase |
|
48 |
| RepeatCycle Expression [Phrase] |
|
49 |
| ForCycle Identifier Expression Expression Phrase Bool -- The last Boolean indicates wether it's up or down counting |
|
50 |
| WithBlock Reference Phrase |
|
51 |
| Phrases [Phrase] |
|
52 |
| SwitchCase Expression [([InitExpression], Phrase)] (Maybe [Phrase]) |
|
53 |
| Assignment Reference Expression |
|
54 |
| BuiltInFunctionCall [Expression] Reference |
|
55 |
| NOP |
|
56 |
deriving Show |
|
57 |
data Expression = Expression String |
|
58 |
| BuiltInFunCall [Expression] Reference |
|
59 |
| PrefixOp String Expression |
|
60 |
| PostfixOp String Expression |
|
61 |
| BinOp String Expression Expression |
|
62 |
| StringLiteral String |
|
63 |
| PCharLiteral String |
|
64 |
| CharCode String |
|
65 |
| HexCharCode String |
|
66 |
| NumberLiteral String |
|
67 |
| FloatLiteral String |
|
68 |
| HexNumber String |
|
69 |
| Reference Reference |
|
70 |
| SetExpression [Identifier] |
|
71 |
| Null |
|
72 |
deriving Show |
|
73 |
data Reference = ArrayElement [Expression] Reference |
|
74 |
| FunCall [Expression] Reference |
|
75 |
| TypeCast Identifier Expression |
|
76 |
| SimpleReference Identifier |
|
77 |
| Dereference Reference |
|
78 |
| RecordField Reference Reference |
|
79 |
| Address Reference |
|
80 |
| RefExpression Expression |
|
81 |
deriving Show |
|
82 |
data InitExpression = InitBinOp String InitExpression InitExpression |
|
83 |
| InitPrefixOp String InitExpression |
|
84 |
| InitReference Identifier |
|
85 |
| InitArray [InitExpression] |
|
86 |
| InitRecord [(Identifier, InitExpression)] |
|
87 |
| InitFloat String |
|
88 |
| InitNumber String |
|
89 |
| InitHexNumber String |
|
90 |
| InitString String |
|
91 |
| InitChar String |
|
92 |
| BuiltInFunction String [InitExpression] |
|
93 |
| InitSet [InitExpression] |
|
94 |
| InitAddress InitExpression |
|
95 |
| InitNull |
|
96 |
| InitRange Range |
|
97 |
| InitTypeCast Identifier InitExpression |
|
98 |
deriving Show |
|
99 |
||
100 |
data BaseType = BTUnknown |
|
101 |
| BTChar |
|
102 |
| BTString |
|
103 |
| BTInt Bool -- second param indicates whether signed or not |
|
104 |
| BTBool |
|
105 |
| BTFloat |
|
106 |
| BTRecord String [(String, BaseType)] |
|
107 |
| BTArray Range BaseType BaseType |
|
108 |
| BTFunction Bool [(Bool, BaseType)] BaseType -- (Bool, BaseType), Bool indiciates whether var or not |
|
109 |
| BTPointerTo BaseType |
|
110 |
| BTUnresolved String |
|
111 |
| BTSet BaseType |
|
112 |
| BTEnum [String] |
|
113 |
| BTVoid |
|
114 |
| BTUnit |
|
115 |
| BTVarParam BaseType |
|
116 |
deriving Show |