blob: 2bb919f5eb7d50446b1c839d4838643b3418b036 (
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
|
-----------------------------
# 0: Basic DSL Rules.
-----------------------------
## Comments and Pragmas
- **Comments**: Lines starting with `#` followed by text are treated as comments or pragmas
```lcp
# This is a comment
```
- **Pragma directives**: Lines starting with `# --` are pragma directives
```lcp
# --pragma-test # Marks file as test
# --test-list-apps # Defines a test case
# --test-start # Defines a start test case
```
## Iteration
- **For loops**: Iterate over collections using begin/end iterator pairs
```lcp
for <iterator>: (<begin>, <end>) {
<body>
}
```
Example:
```lcp
for it: (apps.begin, apps.end) {
it.print();
}
```
- **Iterator methods**: Iterators support method calls using dot notation
```lcp
it.print(); # Call print method on iterator
```
## Event Handlers
- **When statements**: Define event handlers triggered by specific events
```lcp
when <event>: (<arguments>) {
<body>
}
```
Example:
```lcp
when start: (apps) {
it (apps);
}
```
## Collections
- **Collection access**: Collections provide `.begin` and `.end` properties for iteration
```lcp
apps.begin # Start iterator
apps.end # End iterator
```
## Syntax Rules
- **Whitespace**: Indentation is used for readability but not syntactically significant
- **Blocks**: Code blocks are delimited by curly braces `{ }`
- **Statements**: End with semicolon `;` or newline
- **Parentheses**: Used for grouping arguments and parameters
- **Colon**: Separates declaration from parameters in control structures
## Identifiers
- **Naming**: Identifiers can contain letters, numbers, and underscores
- **Case sensitivity**: Identifiers are case-sensitive
- **Reserved keywords**: `for`, `when`, `it`
## Types
- **Collections**: `apps` (application collection)
- **Iterators**: Created via `for` loops or explicit `it()` constructor
- **Events**: `start` (startup event)
|