]> Nishi Git Mirror - gwion.git/commitdiff
:art: Update grammar
authorfennecdjay <astor.jeremie@wanadoo.fr>
Tue, 25 Dec 2018 20:07:35 +0000 (21:07 +0100)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Tue, 25 Dec 2018 20:07:35 +0000 (21:07 +0100)
37 files changed:
ast
examples/array_lit.gw
examples/binary_tmpl.gw
examples/in_class_class.gw
examples/template.gw
examples/template_guess.gw
examples/template_vararg.gw
src/lib/instr.c
src/parse/check.c
src/parse/scan1.c
src/parse/scan2.c
tests/bug/Tester.gw
tests/bug/template_no_guess.gw
tests/error/cant_find_in_nspc.gw
tests/error/named_union_global_private_static.gw
tests/error/non_function_template.gw
tests/error/template_class_no_type.gw
tests/error/template_enough.gw
tests/error/template_n_mismatch.gw
tests/error/template_no_match.gw
tests/error/template_non_member.gw
tests/error/template_unknown.gw
tests/error/type_not_template.gw
tests/error/type_path_test.gw
tests/error/union_global_private_static.gw
tests/test_plugins/class_template.gw
tests/test_plugins/extend_pair.gw
tests/test_plugins/map2.gw
tests/tree/auto_ptr.gw
tests/tree/class_template.gw
tests/tree/map.gw
tests/tree/named_union_private_static.gw
tests/tree/pair.gw
tests/tree/static_template.gw
tests/tree/template_class_ref.gw
tests/tree/template_ternary.gw
tests/tree/template_typedef.gw

diff --git a/ast b/ast
index 5f6b54084825368096489ced346db65dca4bb15e..ef1917e40d3cae04f108ba71a2f905bb4b714811 160000 (submodule)
--- a/ast
+++ b/ast
@@ -1 +1 @@
-Subproject commit 5f6b54084825368096489ced346db65dca4bb15e
+Subproject commit ef1917e40d3cae04f108ba71a2f905bb4b714811
index 2c18fce61af30428cb5f2fb2f3e31731c1fcaf93..accae62d547d560cb20a204aa262c3482053b940 100644 (file)
@@ -12,7 +12,7 @@ Object t[2][12][3][4][5];
 int k[1][1];
 
 
-<<<i, j, o, p, r, q, s, t, k>>>;
+<<<i, j, o, p, r, s, t, k>>>;
 
 [ 1.0, 2, 3, 4, 5 ];
 [ #(0.0, 0.0) ];
index 8b030938570b688bc6b57d2ee4e3dbcb331812fe..71a1ae83bc978207f3f459183bf2f1f9682c5a27 100644 (file)
@@ -1,4 +1,4 @@
-template“A” fun void test(A a) { <<<a>>>; }
+template<A> fun void test(A a) { <<<a>>>; }
 1 => test;
 1.3 => test;
 test(1);
index 734d74061b890776f55d7e8c29b740e4d3b15d19..e0ec4e4a27507a8e54699dcad99f81182ab793a8 100644 (file)
@@ -1,12 +1,12 @@
 class C
 {
-       template“a”
+       template<a>
        function void test(a var){ <<<var>>>; }
        class D { int i;}
 }
 
 C c;
-<C.D> d;
-<C.D> @d_ref;
+C->D d;
+C->D @d_ref;
 
 <<< c, " ", d, d_ref >>>;
index 9261b4608c13b5d7351194ede3d419489d050e31..401d0c5d9310e82d3e212af8e5b2dc132265fc32 100644 (file)
@@ -1,13 +1,13 @@
-template “a”
+template <a>
 function void test (a var){ <<< var>>>; }
-template “a, b”
+template <a, b>
 function void test (a var, b var2){ <<< var>>>; }
 //function void test (){ }
 
-test“int”(1);
-//test“float”(1.4);
-//test“int”(3, 1.4);
-//test“float”(3);
+test<int>(1);
+//test<float>(1.4);
+//test<int>(3, 1.4);
+//test<float>(3);
 //test(3, 1.4);
-test“float, float”(3, 1.4);
-//test“float, float, int”(3, 1.4);
+test<float, float>(3, 1.4);
+//test<float, float, int>(3, 1.4);
index 886891f2f7d8ff23a660d751ad6ee92a69009920..dcb87d0fc4d2a8a59f25ab6738419d5ae16767a4 100644 (file)
@@ -1,4 +1,4 @@
-template “A, B”
+template <A, B>
 function void test(A a, B b){<<<a, ", ", b>>>;}
 test(1, 2.1);
 test(1.1, 2.1);
index d860966f59ce21e2e77e4fb05c4ea7f8ea28261f..79cddc89ad9734b472c225244effcb8e8061e63c 100644 (file)
@@ -1,8 +1,8 @@
-template “a”
+template <a>
 fun void test(...) {
   vararg.start;
   <<<vararg.i>>>;
   vararg.end;
 }
-test“int”(1, 2);
-test“float”(1, 2, 3);
+test<int>(1, 2);
+test<float>(1, 2, 3);
index 496c31ca91f47aba8353707f1036b1083e2ed5ce..f70ffbb329707f4aeff8ed574d85818b6b5d28c2 100644 (file)
@@ -430,7 +430,7 @@ INSTR(AllocMember4) { GWDEBUG_EXE
 INSTR(DotStatic) { GWDEBUG_EXE
   const Type t = *(Type*)REG(-SZ_INT);
   m_uint *const data = (m_uint*)(t->nspc->class_data + instr->m_val);
-  *(m_uint*)REG(-SZ_INT) = *data;
+  *(m_uint*)REG(-SZ_INT) = data ? *data : 0;
 }
 
 INSTR(DotStatic2) { GWDEBUG_EXE
index f46e93b2c46d61a8bc561e1b0fdc2d1bbd3fbe10..da48ad874125a57a70dde1c826c137da4b9d615f 100644 (file)
@@ -64,15 +64,15 @@ ANN static m_bool check_fptr_decl(const Env env, const Var_Decl var) {
       return GW_OK;
     ERR_B(var->pos, "can't use non public typedef at global scope.")
   }
-  if(isa(type, env->class_def) < 0)
-    ERR_B(var->pos, "can't use static variables for member function.")
+  if(isa(type, env->class_def) < 0 && !GET_FLAG(func, global))
+    ERR_B(var->pos, "can't use non global fptr of other class.")
   if(GET_FLAG(func, member)) {
     if(GET_FLAG(v, static))
       ERR_B(var->pos, "can't use static variables for member function.")
     if(!GET_FLAG(v, member))
       ERR_B(var->pos, "can't use member variables for static function.")
-  } else if(GET_FLAG(v, member))
-    ERR_B(var->pos, "can't use member variables for static function.")
+  } //else if(GET_FLAG(v, member))
+    //ERR_B(var->pos, "can't use member variables for static function.")
   return GW_OK;
 }
 
index 24ddf79e6597f8e9462fc66556c9faf0acf7c013..be8576cb2c30ac5bfd48e05dbe677455b0dd45dd 100644 (file)
@@ -52,7 +52,7 @@ ANN static Type scan1_exp_decl_type(const Env env, const Exp_Decl* decl) {
       if(!GET_FLAG(decl->td, ref) && t == env->class_def)
         ERR_O(decl->self->pos, "...(note: object of type '%s' declared inside itself)", t->name)
     }
-    if(GET_FLAG(decl->td, global) && env->class_def)
+    if(GET_FLAG(decl->td, global) && env->class_def) // forbid this ?
       UNSET_FLAG(decl->td, global);
   }
   if(GET_FLAG(t, template))
@@ -200,6 +200,8 @@ ANN m_bool scan1_stmt_enum(const Env env, const Stmt_Enum stmt) { GWDEBUG_EXE
       SET_FLAG(v, static);
       if(GET_FLAG(stmt, private))
         SET_FLAG(v, private);
+      else if(GET_FLAG(stmt, protect))
+        SET_FLAG(v, protect);
     }
     SET_FLAG(v, const | ae_flag_enum | ae_flag_checked);
     nspc_add_value(stmt->t->owner, list->xid, v);
@@ -242,8 +244,10 @@ ANN static inline m_bool scan1_stmt_union_array(const Array_Sub array) { GWDEBUG
 ANN m_bool scan1_stmt_union(const Env env, const Stmt_Union stmt) { GWDEBUG_EXE
   Decl_List l = stmt->l;
   const m_uint scope = union_push(env, stmt);
-  if(stmt->xid || stmt->type_xid)
+  if(stmt->xid || stmt->type_xid) {
     UNSET_FLAG(stmt, private);
+    UNSET_FLAG(stmt, protect);
+  }
   do {
     const Exp_Decl decl = l->self->d.exp_decl;
     Var_Decl_List list = decl.list;
index 99a1139cee43167f406251ae8f070b243974e5d3..2f31ed8346a9b28271e4f98992372b9a1abb54a5 100644 (file)
@@ -84,6 +84,8 @@ ANN static Value scan2_func_assign(const Env env, const Func_Def d,
     else SET_FLAG(v, static);
     if(GET_FLAG(d, private))
       SET_FLAG(v, private);
+    else if(GET_FLAG(d, protect))
+      SET_FLAG(v, protect);
   }
   d->func = v->d.func_ref = f;
   return f->value_ref = v;
@@ -462,7 +464,7 @@ ANN m_bool scan2_func_def(const Env env, const Func_Def f) { GWDEBUG_EXE
     m_uint scope = env->scope;
     if(GET_FLAG(f, global))
       scope = env_push_global(env);
-      CHECK_OB((value = func_create(env, f, overload, func_name)))
+    CHECK_OB((value = func_create(env, f, overload, func_name)))
     if(GET_FLAG(f, global))
       env_pop(env, scope);
   } else
index b078f8660d3e282acb166d207555f15061f457e7..baa73dcf447b4a2786c2474fbd3ec36e9414e8af 100644 (file)
@@ -1,8 +1,8 @@
 class Tester
 {
-       template“A”
+       template<A>
        function int assert_equal(string description, A a, A b){ if(a == b) return 0; return 1; }
-       template“A”
+       template<A>
        function int assert_not_equal(string description, A a, A b){ if(a != b) return 0; return 1; }
 }
 
index 2bdf20ea2ca9d215920d41960138f26809bf8ab7..aaa3b36fc3a7336151a3db62603c2ff9eadbb207 100644 (file)
@@ -1,4 +1,4 @@
-//template “a”
+//template <a>
 function void test(){}
 //function void test(int i[]){<<<i>>>;}
 //function void test(Object o){}
index fede3edb7ad36573dfa3e0d8662a487888dea176..cbab52eb290032b4c166cebc723af84cb777430b 100644 (file)
@@ -6,9 +6,9 @@ class C {
 }
 
 class E extends C {
-  <C.D> d;
+  C->D d;
 }
 
 class F {
-  <F.D> d;
+  F->D d;
 }
index 657baba5446da55d83dac6a918fde1d2f890953d..b202b70e18925d13ed605b8070745ef87b897a77 100644 (file)
@@ -1,2 +1,2 @@
 // [contains] can only be used at class scope.
-union private static { int i; } u;
+union static private { int i; } u;
index d650d2e673f3b0e13b22d4fba7b1685e6e4521cf..795346a0e06ae99c685afeb4dd4cd633877f7f45 100644 (file)
@@ -1,3 +1,3 @@
 // [contains] template call of non-function value
 int test;
-test“int”();
+test<int>();
index 0939e71f5edccdac6aa9880764c9e92aaef4b306..27e0162170bf00c5f06ccd48017c66f3abd1eb1f 100644 (file)
@@ -1,5 +1,5 @@
 // [contains] you must provide template types
-template“A”
+template<A>
 class C {
   A a;
 }
index fa3481c8d92e8c92c1a6296118668ab5d3f2d5ce..1acbf217a231df359bd25f8b0007f5053969f553 100644 (file)
@@ -1,4 +1,4 @@
 // [contains] 
- template“a, b”
+ template<a, b>
 function void test(){}
 test();
index 6fe668b0f2b1022b8be95814e474e401418967e6..97dc0cf1bbc1773416d7365e16ece2f978f190c1 100644 (file)
@@ -1,8 +1,8 @@
 // [contains] arguments do not match for template call
-template “i”
+template <i>
 function void test(){ <<<"func">>>;}
-template “i”
+template <i>
 function void test(int i){<<<"other func">>>;}
 
-test“int, float, int”();
-//test“int”();
+test<int, float, int>();
+//test<int>();
index 068541393c2d62455e25cc432457e3eaf4f490a2..e95d70c0f6a792fccdddf630b747a1869520c17b 100644 (file)
@@ -1,12 +1,12 @@
 // [contains] arguments do not match for template call
 class C
 {
-       template “a”
+       template <a>
        function void test(float f) {}
-       template “a”
+       template <a>
        function void test() {}
 }
 C c;
-//c.test“int”();
-c.test“int”(2.3);
-c.test“int”(2.3, 2.3);
+//c.test<int>();
+c.test<int>(2.3);
+c.test<int>(2.3, 2.3);
index a46622555a9034f732635de46fb3cc53ee7f2362..f25211d43a1e05dfa19038cf34d45db6517fc9cc 100644 (file)
@@ -1,2 +1,2 @@
 // [contains] 
- Math.rand“int”();
+ Math.rand<int>();
index fe8629d0d544c76015f9a438ed2d4d9ba13ffda3..b380cc811b46446f0f1af005be9902cd9191f061 100644 (file)
@@ -1,5 +1,5 @@
 // [contains] unknown type
- template“my_type”
+ template<my_type>
 function void my_function() { <<<"test">>>; }
 
-my_function“unknown_type”();
+my_function<unknown_type>();
index 5832bdc0a7f8240a505d92e6e346951ae80c5dcb..b9f747d87d17e1b5d06a3bafae6a2f93506e04b2 100644 (file)
@@ -1,2 +1,2 @@
 // [contains] is not template
-“int”Object o;
+<int>Object o;
index b62aa0b5a9a5ce874d23d657b7425c5ecd1685b8..c604e5d773bdc1be381bc2f101001fd1ec63b2e9 100644 (file)
@@ -1,2 +1,2 @@
 // [contains] unknown type
-function void test(<B.C> a){}
+function void test(B->C a){}
index 6b4100441fa2224c6068400f1991d9367f8db9a3..2564afc9d97fb42ff72eec7328692a98aa7d5bfc 100644 (file)
@@ -1,2 +1,2 @@
 // [contains] can only be used at class scope.
-union private static  { int i; };
+union static private  { int i; };
index a090ee930c3cfe9edaf6578181d83c674c269190..f72be7aa51e6c2499ad0b316ee84ae6c2430af79 100644 (file)
@@ -1,15 +1,15 @@
 //class child {}
-//template“A, B”
+//template<A, B>
 //class C{ A key; B value; }
-//“int, int”C c1;
-//“float, float”C c2;
+//<int, int>C c1;
+//<float, float>C c2;
 //<<<c1>>>;
 //<<<c2>>>;
 //<<<c2.value>>>;
 
-“int, int”ClassTemplate ct;
+<int, int>ClassTemplate ct;
 <<<ct.key>>>;
-//“float, float”ClassTemplate ct2;
+//<float, float>ClassTemplate ct2;
 //<<<ct2.key>>>;
-//“child, float”ClassTemplate ct3;
+//<child, float>ClassTemplate ct3;
 //<<<ct3.key>>>;
index 7676cc9b3860da9a987bea131dc7fa6906308a9e..48354420ad4f28387bdd993bf57085b2bed30b86 100644 (file)
@@ -1,4 +1,4 @@
-“int, int”PairExt p;
+<int, int>PairExt p;
 <<<p>>>;
 <<<p.key>>>;
 <<<p.val>>>;
index b590df3a3ca80f4fe5d0196915b06d4c9989a38d..9d804604e7557e05391f72e9244d5f9b8105ae4a 100644 (file)
@@ -1,4 +1,4 @@
-“int, float”Map pp;
+<int, float>Map pp;
 <<<pp>>>;
 <<<pp.size()>>>;
 <<<pp.set(1, 2)>>>;
index b94cf26184029bdd2dcd1de706f741072773f530..a4e81bae7f4fd7f5812aa0a4c8d986c04bfce098 100644 (file)
@@ -1,4 +1,4 @@
-“int”Ptr ptr;
+<int>Ptr ptr;
 int i[4];
 for(auto@ a : i)
   <<<*a>>>;
index bc9fccf96e34320cea2352fdae795c3390437055..8f44fb1a47261225cc74e83b9d3c4771634c97f5 100644 (file)
@@ -1,22 +1,22 @@
-template“A, B”
+template<A, B>
 class C {
   A a;
   B b; 
   fun A test() {
     <<<"lol">>>;
   }
-  template“C”
+  template<C>
   fun void test2(C c) {
     <<<c>>>;
   }
 }
 
 //<<<C>>>;
-“int, int”C c;
-“float, int”C d;
-“polar, int”C e;
-“Vec3, int”C f;
-“Object, int”C g;
+<int, int>C c;
+<float, int>C d;
+<polar, int>C e;
+<Vec3, int>C f;
+<Object, int>C g;
 //C c;
 <<<c.a>>>;
 <<<d.a>>>;
index 23c2c002bf5b4db565546c9cc85f9916bfe30ef5..339e5f1efbb7aff3ebbf075efc4bb4ba7a9528c2 100644 (file)
@@ -1,4 +1,4 @@
-“int, int”Map pp;
+<int, int>Map pp;
 <<<pp>>>;
 <<<pp.size()>>>;
 <<<pp.set(1, 2)>>>;
index 8787d183fc00c6b4ba24a53bc26683574a0376bf..e5db91c964b3c625f5e31f8973651d011bb16c6b 100644 (file)
@@ -1,4 +1,4 @@
-class C { union private static { int i; } u;<<<this, " ", u, " ", this.u.i>>>;  
+class C { union static private { int i; } u;<<<this, " ", u, " ", this.u.i>>>;  
 }
 C c;
 <<<c>>>;
index f301b97587e585aacf3a19d04699b57e226b55df..1ce7df8825c51c57860b5b0409b0e1185ed9eb9d 100644 (file)
@@ -1,4 +1,4 @@
-“float, int”Pair p;
+<float, int>Pair p;
 <<<p>>>;
 1 => p.key;
 2 => p.val;
index 7bf83126eeb3839416ba663c5137e7c9dbe1876a..83275c5865ecbd3323e8060cc56c130344f019e2 100644 (file)
@@ -1,10 +1,10 @@
-template “A”
+template <A>
 class C {
   A a;
 }
 
 class D {
-  static “int”C c;
+  static <int>C c;
 }
 
 D d;
index 683bda0102dca931e5946a57abca118bb98fa3c6..c8742fbc97d228f57edc6eae225a9cfce7b3f82b 100644 (file)
@@ -1,5 +1,5 @@
-template“A”
+template<A>
 class C {}
 
-“int”C ref;
+<int>C ref;
 <<<ref>>>;
index 018faa2408c55d76d278112a0de67789d2ec164c..56e4f518fefbbade7c341246cab1045ca5f1e302 100644 (file)
@@ -1,4 +1,4 @@
-template“A”
+template<A>
 function void test(A a){}
 
 (maybe ? test : test)(1);
index 539d694e60981e8c9f860468ff56e73db9ead8f1..68c113967f47b7650c47f3e4d732414f4962f9a8 100644 (file)
@@ -1,16 +1,16 @@
-“int, int”Pair p;
-typedef “int, int”Pair lol;
+<int, int>Pair p;
+typedef <int, int>Pair lol;
 lol t;
 <<<t>>>;
 <<<t.key>>>;
 class C extends lol { int i;}
 C c;
 <<<c.i>>>;
-template “A” class D {
+template <A> class D {
   <<<"lol">>>;
   int i;
 }
-typedef “int”D Lol;
+typedef <int>D Lol;
 class E extends Lol {
   float f;
 }