summaryrefslogtreecommitdiff
path: root/test/test1.lc
blob: 4f2658dd4a7a9359a07f0a260912c4865994a097 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

type A = int
#type A = byte
type B = byte
#type C = B
type D = struct {
    int a
}
type E = struct {
    int x
    int y
}
# FIXME add a proper qualifier for referencing other types
# (perhaps "stack", "data", "include", ...? or simply struct/enum/num/... [bool=enum])
type F = var E
type G = ref []var H
type H = [3]var A
type I = enum {
    a
    b = 19
    c
}
type J = enum byte {
    a
    b = 10
    c = 20
}

func test1() int
func test2(int x) int
func test3(int x, int y) int
func test4(int x, int y) struct { int x }

func testcode1() void
{
}

func testcode2() void
{
    int x
    int y
    {
        int z
    }
}

func testcode3() void
{
    int x
    int y
    int abc
    int b
    int bbb
    int asdf
    int a1
    int a2
    int a3
    int b1
    int z
    int d3
    int d2
    int c1
    int c2
    int d1
}

func testcode4() void
{
    var int r
    int a = 1 + 2
    var bool b

    r = 1+2
    r = 1*2
    r = 1 + 2*3
    r = 1*2 + 3
    r = 1*2 + 3*4
    r = (1+2) * 3
    r = 3 * (1+2_3)

    r = 1
        + 2
    r = 1 +
        2
    r = (1 +
         2)
    r = (1+2) +
        3*4
    (r) = 1
    (r = 1)
    ((r = 2))
    (r = 3)
    r = (((1+2)))

    b = 1==2
    b = not 1==2
    b = 1==1 and 3==4
    b = 1==1 and 2==3 and 3==4
    b = 1==1 or 2==3
    b = 1==1 or 2==3 or 3==4
    #b = 1==2 and 2==3 or 3==4 # not allowed
    b = (1==2 and 2==3) or 3==4
    b = 1==2 and (2==3 or 3==4)
    b = 1==2 and not 2==3
    #b = not 1==2 and 2==3 # not allowed
    b = not (1==2 and 2==3)
    b = (not 1==2) and 2==3

    # it is possible to write confusing code:
    #
    #     very_long_line(blabla(1))       and
    #
    #     check_admin_access()
    #
    # - perhaps we should disallow blank lines inside expression (but we could allow comments still)?
    # - or require a certain indentation scheme?
    # - or both
}