2799e0e73876f1ef8f70d6263342046647716984
[sod] / test / bad.sod
1 /* -*-sod-*-
2 *
3 * A file full of terribleness, to check error reporting and recovery.
4 *
5 * (c) 2019 Straylight/Edgeware
6 */
7
8 /* The reference file for this test isn't intended to be normative: it's fine
9 * if things are reordered, or messages are rephrased. But it's good to know
10 * when these things change, and besides this approach is way easier than the
11 * alternatives.
12 */
13
14 typename Bad;
15
16 import "chimaera";
17
18 lisp ;this is actually a comment
19 (format t ";; Hello from Lisp!~%")
20 /* and this is the statement terminator */;
21
22 lisp
23 (define-pluggable-parser module test (scanner pset)
24 ;; `demo' string `;'
25 (declare (ignore pset))
26 (with-parser-context (token-scanner-context :scanner scanner)
27 (parse (seq ("demo" (string (must :string)) (nil (must #\;)))
28 (format t ";; DEMO ~S~%" string)))));
29 demo "foo";
30
31 code c: user ( not like this '' 'xyz' );
32
33 class {
34 }
35
36 class Wrong {
37 void frob() { ... }
38 void wrong.frob() { ... }
39
40 int x = 2;
41 wrong.x = 7;
42 int x;
43 wrong.x = 3;
44 const char *x = "hello";
45 int x, y(), .z[45], q;
46 int wrong.fizzbuzz(int n) extern;
47 wtf.y = 19, wrong.z = 69, x.= r;
48 int (*bogon)(const char *) { return strlen(p); }
49 }
50
51 class Fail: SodObject { void badkw(?int x) extern; void ebw(?) extern; }
52 class Unlikely: Fail { void fail.badkw(?double y) extern; }
53 class Whoops: Fail { void fail.badkw(?int y) extern; }
54 class Arrgh: Unlikely, Whoops {
55 void fail.badkw(?double x) extern;
56 void fail.ebw(?) extern;
57 }
58
59 [nick = join] class JSuper: SodObject { }
60 [nick = sub] class LSub: JSuper { }
61 [nick = sub] class RSub: JSuper { }
62 [nick = join] class BadNicks: LSub, RSub { }
63 class Super: SodObject { }
64 class Left: Super { }
65 class Right: Super { }
66 class Join: Left, Right { }
67 class Nioj: Right, Left { }
68 class Splinch: Join, SodObject, Nioj { }
69 [link = Super] class Hopeless: Wrong { }
70
71 [link = SodClass]
72 class MyClass: SodClass {
73 int foo = 1;
74 int bar = 2;
75 }
76
77 class MyOtherClass: SodClass { }
78
79 [metaclass = MyClass, link = SodObject]
80 class MyObject: SodObject {
81 class myclass.foo = 42;
82 }
83
84 [metaclass = MyOtherClass] class MyOtherObject: SodObject { }
85 class WhichMetaClass: MyObject, MyOtherObject { }
86
87 class dismissed;
88
89 class hopeful: dismissed
90 ;