summaryrefslogtreecommitdiff
path: root/grammar/c++/input.cc
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2019-12-01 09:38:20 -0800
committerAdrian Thurston <thurston@colm.net>2019-12-01 09:38:20 -0800
commitd71253d7fdb59464e5c094b5b091c87aa2a189d5 (patch)
tree90f71fa6cd6f3ad6d21bf56d47e077fb5b6f4516 /grammar/c++/input.cc
parent5a4407de2c4c03083f1c25b5c7fdb849cdc08a12 (diff)
downloadcolm-d71253d7fdb59464e5c094b5b091c87aa2a189d5.tar.gz
added C++ and Python grammars, taken from test suite
These both need to be updated and tested for code in the wild. They were originally developed to showcase colm features.
Diffstat (limited to 'grammar/c++/input.cc')
-rw-r--r--grammar/c++/input.cc153
1 files changed, 153 insertions, 0 deletions
diff --git a/grammar/c++/input.cc b/grammar/c++/input.cc
new file mode 100644
index 00000000..83d51071
--- /dev/null
+++ b/grammar/c++/input.cc
@@ -0,0 +1,153 @@
+namespace ns1
+{
+ namespace sub1 { class A {}; }
+ namespace sub2 { class B {}; }
+}
+
+namespace ns2
+{
+ int i = b;
+ class C
+ {
+ };
+
+ using namespace ns1;
+}
+
+ns2::sub1::A a;
+
+struct A
+{
+ struct B {};
+};
+
+struct C
+{
+ struct D : virtual public A {};
+};
+
+C::D::A d;
+
+C c;
+
+struct C
+{
+
+};
+
+enum E
+{
+ C,
+ b
+};
+
+E e;
+
+enum E
+{
+ C,
+ b
+};
+
+
+int i;
+class C
+{
+ int j;
+};
+
+class D
+{
+ int ~D();
+};
+
+int C::k;
+int C::~C;
+
+typedef int Int;
+
+class C {};
+void ~C( );
+void C::operator +( int i );
+
+int i;
+
+//void operator C( void k );
+
+class C
+{
+
+};
+
+int C::f( int i, int j( void v ) );
+class C
+{
+ class D {};
+
+ typedef C I;
+
+ I::D i;
+};
+
+C c;
+
+void function( int i, int j )
+{
+ function();
+}
+
+
+
+class B { class Find {}; };
+
+typedef B T;
+
+class C : public T
+{
+ Find find;
+};
+
+
+template <class X> struct Y
+{
+ X t;
+ void f();
+};
+
+template <class X> void Y<X>::f();
+template <class X> struct Y
+{
+ class Z {};
+};
+
+class Y<int>
+{
+ int i;
+};
+
+//void f( class C<int> i, int j );
+
+int f( int (*) [](), void );
+void f();
+class C
+{
+ class D {};
+ void g();
+};
+
+//typename C c;
+
+class C
+{
+ class D {};
+ int f();
+};
+
+int f()
+{
+}
+
+int C::f()
+{
+ D d;
+}