]> Nishi Git Mirror - gwion.git/commitdiff
:art: signature parser
authorJérémie Astor <fennecdjay@gmail.com>
Tue, 17 May 2022 13:13:28 +0000 (15:13 +0200)
committerJérémie Astor <fennecdjay@gmail.com>
Tue, 17 May 2022 13:13:28 +0000 (15:13 +0200)
.all-contributorsrc [deleted file]
src/import/import_checker.c

diff --git a/.all-contributorsrc b/.all-contributorsrc
deleted file mode 100644 (file)
index 3243955..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-{
-  "files": [
-    "README.md"
-  ],
-  "imageSize": 100,
-  "commit": false,
-  "contributors": [
-    {
-      "login": "PaulBatchelor",
-      "name": "Paul Batchelor",
-      "avatar_url": "https://avatars3.githubusercontent.com/u/8139389?v=4",
-      "profile": "http://paulbatchelor.github.io",
-      "contributions": [
-        "question",
-        "bug",
-        "code",
-        "ideas"
-      ]
-    },
-    {
-      "login": "originalsouth",
-      "name": "Benny",
-      "avatar_url": "https://avatars1.githubusercontent.com/u/5300799?v=4",
-      "profile": "https://github.com/originalsouth",
-      "contributions": [
-        "question",
-        "bug",
-        "code"
-      ]
-    },
-    {
-      "login": "scalarwaves",
-      "name": "Andrew Prentice",
-      "avatar_url": "https://avatars1.githubusercontent.com/u/4212896?v=4",
-      "profile": "https://github.com/scalarwaves",
-      "contributions": [
-        "question",
-        "bug",
-        "code",
-        "ideas"
-      ]
-    },
-    {
-      "login": "Aleserche",
-      "name": "aleserche",
-      "avatar_url": "https://avatars3.githubusercontent.com/u/2920837?v=4",
-      "profile": "https://github.com/Aleserche",
-      "contributions": [
-        "code"
-      ]
-    },
-    {
-      "login": "Pranav2612000",
-      "name": "Pranav Joglekar",
-      "avatar_url": "https://avatars3.githubusercontent.com/u/20909078?v=4",
-      "profile": "https://github.com/Pranav2612000",
-      "contributions": [
-        "userTesting",
-        "doc"
-      ]
-    },
-    {
-      "login": "amberisvibin",
-      "name": "Amber",
-      "avatar_url": "https://avatars3.githubusercontent.com/u/63863236?v=4",
-      "profile": "http://dev.to/amberisvibin",
-      "contributions": [
-        "question",
-        "doc",
-        "ideas"
-      ]
-    },
-    {
-      "login": "TotallyNotChase",
-      "name": "Chase",
-      "avatar_url": "https://avatars0.githubusercontent.com/u/44284917?v=4",
-      "profile": "https://github.com/TotallyNotChase",
-      "contributions": [
-        "code"
-      ]
-    },
-    {
-      "login": "nithin-pankaj",
-      "name": "Nithin Pankaj",
-      "avatar_url": "https://avatars2.githubusercontent.com/u/15152472?v=4",
-      "profile": "https://github.com/nithin-pankaj",
-      "contributions": [
-        "code"
-      ]
-    },
-    {
-      "login": "evayde",
-      "name": "Enrico Gruner",
-      "avatar_url": "https://avatars1.githubusercontent.com/u/25255815?v=4",
-      "profile": "https://github.com/evayde",
-      "contributions": [
-        "code"
-      ]
-    },
-    {
-      "login": "umer2001",
-      "name": "Muhammad Umer Farooq",
-      "avatar_url": "https://avatars2.githubusercontent.com/u/35496058?v=4",
-      "profile": "https://github.com/umer2001",
-      "contributions": [
-        "code"
-      ]
-    },
-    {
-      "login": "a",
-      "name": "Shuvalov Anton",
-      "avatar_url": "https://avatars2.githubusercontent.com/u/1410106?v=4",
-      "profile": "http://shuvalov.info",
-      "contributions": [
-        "doc"
-      ]
-    },
-    {
-      "login": "ry-v1",
-      "name": "ry-v1",
-      "avatar_url": "https://avatars1.githubusercontent.com/u/72290009?v=4",
-      "profile": "https://github.com/ry-v1",
-      "contributions": [
-        "doc"
-      ]
-    },
-    {
-      "login": "deekts",
-      "name": "deekts",
-      "avatar_url": "https://avatars0.githubusercontent.com/u/51462833?v=4",
-      "profile": "https://github.com/deekts",
-      "contributions": [
-        "code"
-      ]
-    },
-    {
-      "login": "forrcaho",
-      "name": "Forrest Cahoon",
-      "avatar_url": "https://avatars3.githubusercontent.com/u/492742?v=4",
-      "profile": "https://github.com/forrcaho",
-      "contributions": [
-        "ideas"
-      ]
-    },
-    {
-      "login": "SenorGrande",
-      "name": "Connor Hewett",
-      "avatar_url": "https://avatars2.githubusercontent.com/u/22025776?v=4",
-      "profile": "https://github.com/SenorGrande",
-      "contributions": [
-        "code"
-      ]
-    }
-    {
-      "login": "euppal",
-      "name": "Ethan Uppal",
-      "avatar_url": "https://avatars2.githubusercontent.com/u/?v=67026187?v=4",
-      "profile": "https://github.com/euppal",
-      "contributions": [
-        "ideas"
-      ]
-    }
-  ],
-  "contributorsPerLine": 7,
-  "badgeTemplate": "[![All Contributors](https://img.shields.io/badge/all_contributors-<%= contributors.length %>-orange.svg)](#contributors)",
-  "projectName": "Gwion",
-  "projectOwner": "fennecdjay",
-  "repoType": "github",
-  "repoHost": "https://github.com",
-  "skipCi": true
-}
index 14e615ebf3e97f70fa84085f29fac73126c7a06f..d2c47714c2236f498497aaa1518dc1204f83c779 100644 (file)
@@ -167,8 +167,67 @@ ANN static inline uint get_n(struct td_checker *tdc, const char c) {
   return n;
 }
 
+ANN static Arg_List fptr_args(const Gwion gwion, struct td_checker *tdc) {
+  if(tdc->str[1] == ')')
+    return NULL;
+  Arg_List args = new_mp_vector(gwion->mp, sizeof(Arg), 0);
+  do {
+    Type_Decl *td = _str2td(gwion, tdc);
+    if(!td) {
+      free_arg_list(gwion->mp, args);
+      return (Arg_List)GW_ERROR;
+    }
+    mp_vector_add(gwion->mp, &args, Arg, (Arg){ .td = td });
+  } while(*tdc->str == ',' && tdc->str++);
+  return args;
+}
+
+ANN static Type_Decl *str2td_fptr(const Gwion gwion, struct td_checker *tdc) {
+  const m_str base = tdc->str;
+  tdc->str++;
+  Type_Decl *const ret_td = _str2td(gwion, tdc);
+  const Type_List tl = td_tmpl(gwion, tdc);
+  if (tl == (Type_List)GW_ERROR) {
+    free_type_decl(gwion->mp, ret_td);
+    return NULL;
+  }
+  const uint option = get_n(tdc, '?');
+  tdc->str++;
+  Arg_List args = fptr_args(gwion, tdc);
+  if (args == (Arg_List)GW_ERROR) {
+    if(tl) free_type_list(gwion->mp, tl);
+    free_type_decl(gwion->mp, ret_td);
+    return NULL;
+  }
+  if(tdc->str[0] != ')' || tdc->str[1] != ')') {
+    if(tl) free_type_list(gwion->mp, tl);
+    if(args) free_arg_list(gwion->mp, args);
+    return NULL;
+  }
+  tdc->str += 2;
+  struct AC ac = {.str = tdc->str, .pos = tdc->pos};
+  if(ac_run(gwion, &ac) < 0 ) {
+    if(tl) free_type_list(gwion->mp, tl);
+    if(args) free_arg_list(gwion->mp, args);
+    return NULL;
+  }
+  Func_Base *fbase = new_func_base(gwion->mp, ret_td, insert_symbol(gwion->st, base), args, ae_flag_none, tdc->pos);
+  const Fptr_Def fptr = new_fptr_def(gwion->mp, fbase);
+  Type_Decl *td = new_type_decl(gwion->mp, insert_symbol(gwion->st, base), tdc->pos);
+  td->fptr = fptr;
+  if (ac.depth) td->array = mk_array(gwion->mp, &ac);
+  tdc->str = ac.str;
+  td->option = option;
+  return td;
+}
+
 ANN static Type_Decl *_str2td(const Gwion gwion, struct td_checker *tdc) {
   const uint ref = get_n(tdc, '&');
+  if(*tdc->str == '(') {
+    Type_Decl *const td = str2td_fptr(gwion, tdc);
+    td->ref = ref;
+    return td;
+  }
   DECL_OO(const Symbol, sym, = __str2sym(gwion, tdc));
   struct AC ac = {.str = tdc->str, .pos = tdc->pos};
   CHECK_BO(ac_run(gwion, &ac));