PascalSyntax.wiki
author Wuzzy
Wed, 19 Apr 2017 15:44:20 +0100
changeset 979 1455b4ad1ec3
parent 977 2269c95056fe
child 980 dc250fc5bc24
permissions -rw-r--r--
PascalSyntax: Fix syntax
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
979
1455b4ad1ec3 PascalSyntax: Fix syntax
Wuzzy
parents: 977
diff changeset
     1
#summary Hedgewars-specific Pascal syntax rules
1455b4ad1ec3 PascalSyntax: Fix syntax
Wuzzy
parents: 977
diff changeset
     2
1455b4ad1ec3 PascalSyntax: Fix syntax
Wuzzy
parents: 977
diff changeset
     3
= Hedgewars-specific Pascal syntax rules =
977
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
     4
979
1455b4ad1ec3 PascalSyntax: Fix syntax
Wuzzy
parents: 977
diff changeset
     5
When programming in Pascal for Hedgewars, we have two rules which must be always obeyed. This is because of our tool `pas2c` which doesn't fully understand Pascal yet. If these rules are broken, `pas2c` will fail to operate.
977
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
     6
979
1455b4ad1ec3 PascalSyntax: Fix syntax
Wuzzy
parents: 977
diff changeset
     7
== Pascal rules for `pas2c` ==
977
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
     8
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
     9
 # Never use `not` without brackets
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    10
 # Never use `in` with numerals
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    11
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    12
=== Examples ===
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    13
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    14
Forbidden:
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    15
979
1455b4ad1ec3 PascalSyntax: Fix syntax
Wuzzy
parents: 977
diff changeset
    16
 `if a in [1, 2] then`
977
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    17
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    18
Allowed:
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    19
979
1455b4ad1ec3 PascalSyntax: Fix syntax
Wuzzy
parents: 977
diff changeset
    20
 `if a in [sprBubble, sprAmGirder] then`
977
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    21
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    22
Forbidden:
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    23
979
1455b4ad1ec3 PascalSyntax: Fix syntax
Wuzzy
parents: 977
diff changeset
    24
 `if not isExploded then`
977
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    25
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    26
Allowed:
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    27
979
1455b4ad1ec3 PascalSyntax: Fix syntax
Wuzzy
parents: 977
diff changeset
    28
 `if not (isExploded) then`
977
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    29
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    30
Allowed
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    31
979
1455b4ad1ec3 PascalSyntax: Fix syntax
Wuzzy
parents: 977
diff changeset
    32
 `if isExploded <> true then`