author | sheepluva |
Wed, 27 Apr 2016 18:08:48 +0200 | |
changeset 11747 | 3182ee5be2b0 |
parent 10747 | 07ade56c3b4a |
child 13887 | 5988e73080a3 |
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] |
|
10142 | 8 |
deriving (Show, Eq) |
10015 | 9 |
data Interface = Interface Uses TypesAndVars |
10142 | 10 |
deriving (Show, Eq) |
10015 | 11 |
data Implementation = Implementation Uses TypesAndVars |
10142 | 12 |
deriving (Show, Eq) |
10015 | 13 |
data Identifier = Identifier String BaseType |
10142 | 14 |
deriving (Show, Eq) |
10015 | 15 |
data TypesAndVars = TypesAndVars [TypeVarDeclaration] |
10142 | 16 |
deriving (Show, Eq) |
10015 | 17 |
data TypeVarDeclaration = TypeDeclaration Identifier TypeDecl |
18 |
| VarDeclaration Bool Bool ([Identifier], TypeDecl) (Maybe InitExpression) |
|
10129
cd2a64a1f4aa
- Pas2C: make use of 'external' function decorator
unc0rr
parents:
10120
diff
changeset
|
19 |
| FunctionDeclaration Identifier Bool Bool Bool TypeDecl [TypeVarDeclaration] (Maybe (TypesAndVars, Phrase)) |
10015 | 20 |
| OperatorDeclaration String Identifier Bool TypeDecl [TypeVarDeclaration] (Maybe (TypesAndVars, Phrase)) |
10142 | 21 |
deriving (Show, Eq) |
10015 | 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 |
|
10142 | 35 |
deriving (Show, Eq) |
10015 | 36 |
data Range = Range Identifier |
37 |
| RangeFromTo InitExpression InitExpression |
|
38 |
| RangeInfinite |
|
10142 | 39 |
deriving (Show, Eq) |
10015 | 40 |
data Initialize = Initialize String |
10142 | 41 |
deriving (Show, Eq) |
10015 | 42 |
data Finalize = Finalize String |
10142 | 43 |
deriving (Show, Eq) |
10015 | 44 |
data Uses = Uses [Identifier] |
10142 | 45 |
deriving (Show, Eq) |
10015 | 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 |
|
10142 | 57 |
deriving (Show, Eq) |
10015 | 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 |
|
10142 | 73 |
deriving (Show, Eq) |
10015 | 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 |
|
10142 | 82 |
deriving (Show, Eq) |
10015 | 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 |
|
10747
07ade56c3b4a
backporting some build system fixes and pas2c tweaks
sheepluva
parents:
10142
diff
changeset
|
92 |
| InitPChar String |
10015 | 93 |
| InitChar String |
94 |
| BuiltInFunction String [InitExpression] |
|
95 |
| InitSet [InitExpression] |
|
96 |
| InitAddress InitExpression |
|
97 |
| InitNull |
|
98 |
| InitRange Range |
|
99 |
| InitTypeCast Identifier InitExpression |
|
10142 | 100 |
deriving (Show, Eq) |
10015 | 101 |
|
102 |
data BaseType = BTUnknown |
|
103 |
| BTChar |
|
104 |
| BTString |
|
10120 | 105 |
| BTAString |
10015 | 106 |
| BTInt Bool -- second param indicates whether signed or not |
107 |
| BTBool |
|
108 |
| BTFloat |
|
109 |
| BTRecord String [(String, BaseType)] |
|
110 |
| BTArray Range BaseType BaseType |
|
10129
cd2a64a1f4aa
- Pas2C: make use of 'external' function decorator
unc0rr
parents:
10120
diff
changeset
|
111 |
| BTFunction Bool Bool [(Bool, BaseType)] BaseType -- in (Bool, BaseType), Bool indiciates whether var or not |
10015 | 112 |
| BTPointerTo BaseType |
113 |
| BTUnresolved String |
|
114 |
| BTSet BaseType |
|
115 |
| BTEnum [String] |
|
116 |
| BTVoid |
|
117 |
| BTUnit |
|
118 |
| BTVarParam BaseType |
|
10142 | 119 |
deriving (Show, Eq) |