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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
Long comments / Ignore blocks
=============================
Rationale
---------
Long comments are very useful for disabling some code during development.
This is used quite a lot, so it's useful to have it in the compiler.
It needs to be nestable, and it should be removed before the tokenization
phase. So it has to either:
* Appear at the start of the line, as in SLUL-try1
- If it uses keywords, then neither keyword can appear elsewhere.
* Use some special character(s) that don't appear else.
* Use some special sequences, e.g. /* */ and disallow those sequences in
strings, comments, etc.
Nice to haves:
* Avoid introducing new special characters (e.g. `{` `[` `%` etc)
* Avoid overloading special characters (e.g. `!`)
* It should be intuitive to readers
* It's good if it's possible to guess the syntax when writing code.
* There should not be any confusion with other language elements.
* If overloading # comment syntax, it must not be something that could:
- appear in a comment
- appear in code that might be commented out with #
- appear immediately before a comment, e.g. `end` vs `end#`
* It should not be something that appears in diffs or similar, e.g. +++ ---
* It should not conflict with other tools (e.g. documentation tools,
preprocessors, etc.)
* It should be reasonably short (max 10 charactersS?)
Most obvious solution: Start and end markers
--------------------------------------------
I decided to go with the solution under the section "Alternative solution"
at the end, instead of this.
Syntax:
#{{
#}}
#ignore
#endignore
#ignore abc123 start
#ignore abc123 end
#[[
#]]
#((
#))
%ignore
%end
#[[
#]]
long#
end#
start#
end#
(#
)#
=ignore
=endignore
(*
*)
Alternative solution: Have only a start marker
----------------------------------------------
# Ignore something until next non-indented end
ignore
func xxx
...
end
# Nested ignores:
ignore
func xxx
...
ignore
...
end
...
end
# Multiple things can be ignored
# Not sure if this is good idea?
ignore
ignore
func xxx
...
end
func yyy
...
end
# Maybe a more powerful variant, that can stretch
# across multiple functions:
# ignorestart ... ignoreend
# TODO actually implement this. not sure if it is needed?
ignorestart
func aaa
...
func bbb
...
ignoreend
# Ignore stops here
func ccc
Implementation ideas: There are basically three paths here:
* Rely on indentation <-- Chosen solution
- skip to (and including `end`) at the same indentation level
* Rely on start tokens
- skip to one of some specific start token
(e.g. `func` `type` etc.)
* Rely on textual search
- skip to some arbitrary sequence of (text) bytes
(e.g. "func xyz")
|