PascalSyntax.wiki
author Wuzzy
Fri, 19 Apr 2019 16:07:50 +0100
changeset 1831 365c30b4c669
parent 981 a18f350d00ff
child 2016 3e426e5979ec
permissions -rw-r--r--
LuaGears: Add temporary mistake to test documentation script
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
= Hedgewars-specific Pascal syntax rules =
977
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
     3
979
1455b4ad1ec3 PascalSyntax: Fix syntax
Wuzzy
parents: 977
diff changeset
     4
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
     5
979
1455b4ad1ec3 PascalSyntax: Fix syntax
Wuzzy
parents: 977
diff changeset
     6
== Pascal rules for `pas2c` ==
977
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
     7
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
     8
 # Never use `not` without brackets
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
     9
 # Never use `in` with numerals
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    10
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    11
=== Examples ===
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    12
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    13
Forbidden:
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    14
979
1455b4ad1ec3 PascalSyntax: Fix syntax
Wuzzy
parents: 977
diff changeset
    15
 `if a in [1, 2] then`
977
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    16
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    17
Allowed:
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    18
979
1455b4ad1ec3 PascalSyntax: Fix syntax
Wuzzy
parents: 977
diff changeset
    19
 `if a in [sprBubble, sprAmGirder] then`
977
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    20
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    21
Forbidden:
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    22
979
1455b4ad1ec3 PascalSyntax: Fix syntax
Wuzzy
parents: 977
diff changeset
    23
 `if not isExploded then`
977
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    24
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    25
Allowed:
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    26
981
a18f350d00ff PascalSyntax: fix `if not (isExploded) then`
Wuzzy
parents: 980
diff changeset
    27
 `if (not isExploded) then`
977
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    28
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    29
Allowed
2269c95056fe Add HW-specific rules for Pascal code
Wuzzy <almikes@aol.com>
parents:
diff changeset
    30
979
1455b4ad1ec3 PascalSyntax: Fix syntax
Wuzzy
parents: 977
diff changeset
    31
 `if isExploded <> true then`