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