chiark / gitweb /
src/parser/parser-proto.lisp: Muffle a `&optional ... &key ...' warning.
[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   wrong.x = 3;
43   int filler, y(), .z[45], q;
44   int wrong.fizzbuzz(int n) extern;
45   wtf.y = 19, wrong.z = 69, x.= r;
46   int (*bogon)(const char *) { return strlen(p); }
47 }
48
49 class Fail: SodObject { void badkw(?int x) extern; void ebw(?) extern; }
50 class Unlikely: Fail { void fail.badkw(?double y) extern; }
51 class Whoops: Fail { void fail.badkw(?int y) extern; }
52 class Arrgh: Unlikely, Whoops {
53   void fail.badkw(?double x) extern;
54   void fail.ebw(?) extern;
55 }
56
57 [nick = join] class JSuper: SodObject { }
58 [nick = sub] class LSub: JSuper { }
59 [nick = sub] class RSub: JSuper { }
60 [nick = join] class BadNicks: LSub, RSub { }
61 class Super: SodObject { }
62 class Left: Super { }
63 class Right: Super { }
64 class Join: Left, Right { }
65 class Nioj: Right, Left { }
66 class Splinch: Join, SodObject, Nioj { }
67 [link = Super] class Hopeless: Wrong { }
68
69 [link = SodClass]
70 class MyClass: SodClass {
71   int foo = 1;
72   int bar = 2;
73 }
74
75 class MyOtherClass: SodClass { }
76
77 [metaclass = MyClass, link = SodObject]
78 class MyObject: SodObject {
79   class myclass.foo = 42;
80 }
81
82 [metaclass = MyOtherClass] class MyOtherObject: SodObject { }
83 class WhichMetaClass: MyObject, MyOtherObject { }
84
85 class dismissed;
86
87 class hopeful: dismissed
88 ;