2 Commits 2dd01f06a4 ... 6bc87decd6

Author SHA1 Message Date
  mizusato 6bc87decd6 bump version 2 years ago
  mizusato bac0efc9ea field and branch ref 2 years ago
5 changed files with 5920 additions and 5564 deletions
  1. 10 3
      grammar.js
  2. 1 1
      package.json
  3. 64 6
      src/grammar.json
  4. 38 0
      src/node-types.json
  5. 5807 5554
      src/parser.c

+ 10 - 3
grammar.js

@@ -70,16 +70,23 @@ module.exports = grammar({
         const_value: $ => seq(':=', choice($.native, $.expr)),
         expr: $ => seq($.term, optional($.pipeline)),
           pipeline: $ => seq($.pipe, optional($.pipeline)),
-            pipe: $ => choice($.pipe_func, $.pipe_get, $.pipe_cast, $.pipe_switch),
+            pipe: $ => choice (
+              $.pipe_func, $.pipe_cast,
+              $.pipe_get, $.pipe_field_ref,
+              $.pipe_switch, $.pipe_branch_ref
+            ),
               pipe_func: $ => seq('.', '{', $.callee, optional($.expr), '}'),
                 callee: $ => seq($.expr),
-              pipe_get: $ => seq('.', $.name),
               pipe_cast: $ => seq('.', '[', $.type, ']'),
+              pipe_get: $ => seq('.', $.name),
+              pipe_field_ref: $ => seq('.', '&', $.name),
               pipe_switch: $ => seq('.', '(', $.type_ref, ')'),
+              pipe_branch_ref: $ => seq('.', '&', '(', $.type_ref, ')'),
         term: $ => choice (
           $.call, $.lambda, $.multi_switch, $.switch, $.if,
           $.block, $.cps, $.bundle, $.tuple, $.inline_ref,
-          $.array, $.int, $.float, $.formatter, $.string, $.char),
+          $.array, $.int, $.float, $.formatter, $.string, $.char
+        ),
           call: $ => choice($.call_prefix, $.call_infix),
             call_prefix: $ => seq('{', $.callee, $.expr, '}'),
             call_infix: $ => seq('(', $.infix_left, $.operator, $.infix_right, ')'),

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "tree-sitter-kumachan",
-  "version": "0.0.21",
+  "version": "0.0.22",
   "description": "Grammar definition of the KumaChan programming language",
   "main": "index.js",
   "author": "mizusato",

+ 64 - 6
src/grammar.json

@@ -1231,15 +1231,23 @@
           },
           {
             "type": "SYMBOL",
+            "name": "pipe_cast"
+          },
+          {
+            "type": "SYMBOL",
             "name": "pipe_get"
           },
           {
             "type": "SYMBOL",
-            "name": "pipe_cast"
+            "name": "pipe_field_ref"
           },
           {
             "type": "SYMBOL",
             "name": "pipe_switch"
+          },
+          {
+            "type": "SYMBOL",
+            "name": "pipe_branch_ref"
           }
         ]
       }
@@ -1294,6 +1302,31 @@
         ]
       }
     },
+    "pipe_cast": {
+      "type": "PREC_RIGHT",
+      "value": 0,
+      "content": {
+        "type": "SEQ",
+        "members": [
+          {
+            "type": "STRING",
+            "value": "."
+          },
+          {
+            "type": "STRING",
+            "value": "["
+          },
+          {
+            "type": "SYMBOL",
+            "name": "type"
+          },
+          {
+            "type": "STRING",
+            "value": "]"
+          }
+        ]
+      }
+    },
     "pipe_get": {
       "type": "PREC_RIGHT",
       "value": 0,
@@ -1311,7 +1344,7 @@
         ]
       }
     },
-    "pipe_cast": {
+    "pipe_field_ref": {
       "type": "PREC_RIGHT",
       "value": 0,
       "content": {
@@ -1323,20 +1356,41 @@
           },
           {
             "type": "STRING",
-            "value": "["
+            "value": "&"
           },
           {
             "type": "SYMBOL",
-            "name": "type"
+            "name": "name"
+          }
+        ]
+      }
+    },
+    "pipe_switch": {
+      "type": "PREC_RIGHT",
+      "value": 0,
+      "content": {
+        "type": "SEQ",
+        "members": [
+          {
+            "type": "STRING",
+            "value": "."
           },
           {
             "type": "STRING",
-            "value": "]"
+            "value": "("
+          },
+          {
+            "type": "SYMBOL",
+            "name": "type_ref"
+          },
+          {
+            "type": "STRING",
+            "value": ")"
           }
         ]
       }
     },
-    "pipe_switch": {
+    "pipe_branch_ref": {
       "type": "PREC_RIGHT",
       "value": 0,
       "content": {
@@ -1348,6 +1402,10 @@
           },
           {
             "type": "STRING",
+            "value": "&"
+          },
+          {
+            "type": "STRING",
             "value": "("
           },
           {

+ 38 - 0
src/node-types.json

@@ -1069,10 +1069,18 @@
       "required": true,
       "types": [
         {
+          "type": "pipe_branch_ref",
+          "named": true
+        },
+        {
           "type": "pipe_cast",
           "named": true
         },
         {
+          "type": "pipe_field_ref",
+          "named": true
+        },
+        {
           "type": "pipe_func",
           "named": true
         },
@@ -1088,6 +1096,21 @@
     }
   },
   {
+    "type": "pipe_branch_ref",
+    "named": true,
+    "fields": {},
+    "children": {
+      "multiple": false,
+      "required": true,
+      "types": [
+        {
+          "type": "type_ref",
+          "named": true
+        }
+      ]
+    }
+  },
+  {
     "type": "pipe_cast",
     "named": true,
     "fields": {},
@@ -1103,6 +1126,21 @@
     }
   },
   {
+    "type": "pipe_field_ref",
+    "named": true,
+    "fields": {},
+    "children": {
+      "multiple": false,
+      "required": true,
+      "types": [
+        {
+          "type": "name",
+          "named": true
+        }
+      ]
+    }
+  },
+  {
     "type": "pipe_func",
     "named": true,
     "fields": {},

File diff suppressed because it is too large
+ 5807 - 5554
src/parser.c