z_mirror/luapls

git clone https://git.raiguard.me/z_mirror/luapls

Caleb HeuerFix testsa9d7242

main
10.7 KiB431 linesraw
1[
2  {
3    "Label": "equal",
4    "Input": "a = b == 5",
5    "AST": {
6      "Type": "Block",
7      "Range": {
8        "Start": 0,
9        "End": 10
10      },
11      "Stmts": [
12        {
13          "Type": "AssignmentStatement",
14          "Range": {
15            "Start": 0,
16            "End": 10
17          },
18          "Vars": [
19            {
20              "Type": "Identifier",
21              "Range": {
22                "Start": 0,
23                "End": 1
24              },
25              "Literal": "a"
26            }
27          ],
28          "Exps": [
29            {
30              "Type": "InfixExpression",
31              "Range": {
32                "Start": 4,
33                "End": 10
34              },
35              "Left": {
36                "Type": "Identifier",
37                "Range": {
38                  "Start": 4,
39                  "End": 5
40                },
41                "Literal": "b"
42              },
43              "Operator": "equal",
44              "Right": {
45                "Type": "NumberLiteral",
46                "Range": {
47                  "Start": 9,
48                  "End": 10
49                },
50                "Literal": "5",
51                "Value": 5
52              }
53            }
54          ]
55        }
56      ]
57    }
58  },
59  {
60    "Label": "addition",
61    "Input": "a = b + 5",
62    "AST": {
63      "Type": "Block",
64      "Range": {
65        "Start": 0,
66        "End": 9
67      },
68      "Stmts": [
69        {
70          "Type": "AssignmentStatement",
71          "Range": {
72            "Start": 0,
73            "End": 9
74          },
75          "Vars": [
76            {
77              "Type": "Identifier",
78              "Range": {
79                "Start": 0,
80                "End": 1
81              },
82              "Literal": "a"
83            }
84          ],
85          "Exps": [
86            {
87              "Type": "InfixExpression",
88              "Range": {
89                "Start": 4,
90                "End": 9
91              },
92              "Left": {
93                "Type": "Identifier",
94                "Range": {
95                  "Start": 4,
96                  "End": 5
97                },
98                "Literal": "b"
99              },
100              "Operator": "plus",
101              "Right": {
102                "Type": "NumberLiteral",
103                "Range": {
104                  "Start": 8,
105                  "End": 9
106                },
107                "Literal": "5",
108                "Value": 5
109              }
110            }
111          ]
112        }
113      ]
114    }
115  },
116  {
117    "Label": "left_associative",
118    "Input": "a = 2 + 2 + 2",
119    "AST": {
120      "Type": "Block",
121      "Range": {
122        "Start": 0,
123        "End": 13
124      },
125      "Stmts": [
126        {
127          "Type": "AssignmentStatement",
128          "Range": {
129            "Start": 0,
130            "End": 13
131          },
132          "Vars": [
133            {
134              "Type": "Identifier",
135              "Range": {
136                "Start": 0,
137                "End": 1
138              },
139              "Literal": "a"
140            }
141          ],
142          "Exps": [
143            {
144              "Type": "InfixExpression",
145              "Range": {
146                "Start": 4,
147                "End": 13
148              },
149              "Left": {
150                "Type": "InfixExpression",
151                "Range": {
152                  "Start": 4,
153                  "End": 9
154                },
155                "Left": {
156                  "Type": "NumberLiteral",
157                  "Range": {
158                    "Start": 4,
159                    "End": 5
160                  },
161                  "Literal": "2",
162                  "Value": 2
163                },
164                "Operator": "plus",
165                "Right": {
166                  "Type": "NumberLiteral",
167                  "Range": {
168                    "Start": 8,
169                    "End": 9
170                  },
171                  "Literal": "2",
172                  "Value": 2
173                }
174              },
175              "Operator": "plus",
176              "Right": {
177                "Type": "NumberLiteral",
178                "Range": {
179                  "Start": 12,
180                  "End": 13
181                },
182                "Literal": "2",
183                "Value": 2
184              }
185            }
186          ]
187        }
188      ]
189    }
190  },
191  {
192    "Label": "right_associative",
193    "Input": "a = 'foo'..'bar'..'baz'",
194    "AST": {
195      "Type": "Block",
196      "Range": {
197        "Start": 0,
198        "End": 23
199      },
200      "Stmts": [
201        {
202          "Type": "AssignmentStatement",
203          "Range": {
204            "Start": 0,
205            "End": 23
206          },
207          "Vars": [
208            {
209              "Type": "Identifier",
210              "Range": {
211                "Start": 0,
212                "End": 1
213              },
214              "Literal": "a"
215            }
216          ],
217          "Exps": [
218            {
219              "Type": "InfixExpression",
220              "Range": {
221                "Start": 4,
222                "End": 23
223              },
224              "Left": {
225                "Type": "StringLiteral",
226                "Range": {
227                  "Start": 4,
228                  "End": 9
229                },
230                "Literal": "'foo'"
231              },
232              "Operator": "concat",
233              "Right": {
234                "Type": "InfixExpression",
235                "Range": {
236                  "Start": 11,
237                  "End": 23
238                },
239                "Left": {
240                  "Type": "StringLiteral",
241                  "Range": {
242                    "Start": 11,
243                    "End": 16
244                  },
245                  "Literal": "'bar'"
246                },
247                "Operator": "concat",
248                "Right": {
249                  "Type": "StringLiteral",
250                  "Range": {
251                    "Start": 18,
252                    "End": 23
253                  },
254                  "Literal": "'baz'"
255                }
256              }
257            }
258          ]
259        }
260      ]
261    }
262  },
263  {
264    "Label": "all_precedences",
265    "Input": "a = 1 + 2 - 3 * -4 / 5 % 6 ^ 7 .. 8",
266    "AST": {
267      "Type": "Block",
268      "Range": {
269        "Start": 0,
270        "End": 35
271      },
272      "Stmts": [
273        {
274          "Type": "AssignmentStatement",
275          "Range": {
276            "Start": 0,
277            "End": 35
278          },
279          "Vars": [
280            {
281              "Type": "Identifier",
282              "Range": {
283                "Start": 0,
284                "End": 1
285              },
286              "Literal": "a"
287            }
288          ],
289          "Exps": [
290            {
291              "Type": "InfixExpression",
292              "Range": {
293                "Start": 4,
294                "End": 35
295              },
296              "Left": {
297                "Type": "InfixExpression",
298                "Range": {
299                  "Start": 4,
300                  "End": 30
301                },
302                "Left": {
303                  "Type": "InfixExpression",
304                  "Range": {
305                    "Start": 4,
306                    "End": 9
307                  },
308                  "Left": {
309                    "Type": "NumberLiteral",
310                    "Range": {
311                      "Start": 4,
312                      "End": 5
313                    },
314                    "Literal": "1",
315                    "Value": 1
316                  },
317                  "Operator": "plus",
318                  "Right": {
319                    "Type": "NumberLiteral",
320                    "Range": {
321                      "Start": 8,
322                      "End": 9
323                    },
324                    "Literal": "2",
325                    "Value": 2
326                  }
327                },
328                "Operator": "minus",
329                "Right": {
330                  "Type": "InfixExpression",
331                  "Range": {
332                    "Start": 12,
333                    "End": 30
334                  },
335                  "Left": {
336                    "Type": "InfixExpression",
337                    "Range": {
338                      "Start": 12,
339                      "End": 22
340                    },
341                    "Left": {
342                      "Type": "InfixExpression",
343                      "Range": {
344                        "Start": 12,
345                        "End": 18
346                      },
347                      "Left": {
348                        "Type": "NumberLiteral",
349                        "Range": {
350                          "Start": 12,
351                          "End": 13
352                        },
353                        "Literal": "3",
354                        "Value": 3
355                      },
356                      "Operator": "mul",
357                      "Right": {
358                        "Type": "PrefixExpression",
359                        "Range": {
360                          "Start": 16,
361                          "End": 18
362                        },
363                        "Operator": "minus",
364                        "Right": {
365                          "Type": "NumberLiteral",
366                          "Range": {
367                            "Start": 17,
368                            "End": 18
369                          },
370                          "Literal": "4",
371                          "Value": 4
372                        }
373                      }
374                    },
375                    "Operator": "slash",
376                    "Right": {
377                      "Type": "NumberLiteral",
378                      "Range": {
379                        "Start": 21,
380                        "End": 22
381                      },
382                      "Literal": "5",
383                      "Value": 5
384                    }
385                  },
386                  "Operator": "mod",
387                  "Right": {
388                    "Type": "InfixExpression",
389                    "Range": {
390                      "Start": 25,
391                      "End": 30
392                    },
393                    "Left": {
394                      "Type": "NumberLiteral",
395                      "Range": {
396                        "Start": 25,
397                        "End": 26
398                      },
399                      "Literal": "6",
400                      "Value": 6
401                    },
402                    "Operator": "pow",
403                    "Right": {
404                      "Type": "NumberLiteral",
405                      "Range": {
406                        "Start": 29,
407                        "End": 30
408                      },
409                      "Literal": "7",
410                      "Value": 7
411                    }
412                  }
413                }
414              },
415              "Operator": "concat",
416              "Right": {
417                "Type": "NumberLiteral",
418                "Range": {
419                  "Start": 34,
420                  "End": 35
421                },
422                "Literal": "8",
423                "Value": 8
424              }
425            }
426          ]
427        }
428      ]
429    }
430  }
431]