Skip to content

Commit

Permalink
[create-pull-request] automated change
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMcCulloh authored and github-actions[bot] committed May 20, 2024
1 parent bd1d35c commit edfd624
Show file tree
Hide file tree
Showing 12 changed files with 38,054 additions and 28,937 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "tree-sitter-wing"
description = "Wing grammar for tree-sitter"
version = "0.71.0"
version = "0.74.1"
license = "MIT"
readme = "README.md"
keywords = ["incremental", "parsing", "tree-sitter", "wing"]
Expand Down
2 changes: 1 addition & 1 deletion Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 51 additions & 12 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ const PREC = {
UNARY: 120,
OPTIONAL_TEST: 130,
POWER: 140,
MEMBER: 150,
CALL: 160,
OPTIONAL_UNWRAP: 170,
STRUCTURED_ACCESS: 150, // x[y]
MEMBER: 160,
CALL: 170,
OPTIONAL_UNWRAP: 180,
};

module.exports = grammar({
name: "wing",

extras: ($) => [$.comment, /[\s\p{Zs}\uFEFF\u2060\u200B]/],
extras: ($) => [$.comment, $.doc, /[\s\p{Zs}\uFEFF\u2060\u200B]/],

word: ($) => $.identifier,

Expand All @@ -32,6 +33,7 @@ module.exports = grammar({
// In this case tree-sitter doesn't know if it's a set or a map literal so just assume its a map
[$.json_map_literal, $.map_literal, $.array_literal],
[$.json_literal, $.structured_access_expression],
[$.intrinsic, $.call],
],

conflicts: ($) => [
Expand All @@ -53,9 +55,10 @@ module.exports = grammar({
choice(braced(optional(repeat($._statement))), $.AUTOMATIC_BLOCK),
_semicolon: ($) => choice(";", $.AUTOMATIC_SEMICOLON),
comment: ($) =>
token(
choice(seq("//", /.*/), seq("/*", /[^*]*\*+([^/*][^*]*\*+)*/, "/"))
),
token(choice(seq(/\/\/[^\/]/, /.*/), seq("/*", /[^*]*\*+([^/*][^*]*\*+)*/, "/"))),

doc: ($) => seq("///", field("content", $.doc_content)),
doc_content: ($) => /.*/,

// Identifiers
reference: ($) =>
Expand Down Expand Up @@ -123,7 +126,8 @@ module.exports = grammar({
$.try_catch_statement,
$.compiler_dbg_env,
$.super_constructor_statement,
$.throw_statement
$.throw_statement,
$.lift_statement,
),

import_statement: ($) =>
Expand Down Expand Up @@ -159,6 +163,13 @@ module.exports = grammar({
throw_statement: ($) =>
seq("throw", optional(field("expression", $.expression)), $._semicolon),

lift_statement: ($) =>
seq("lift", field("lift_qualifications", $.lift_qualifications), field("block", $.block)),

lift_qualifications: ($) => seq("{", field("qualification", commaSep1($.lift_qualification)), "}"),

lift_qualification: ($) => seq(field("obj", $.expression), ":", choice(field("ops", $.identifier), field("ops", seq("[", commaSep1($.identifier), "]")))),

assignment_operator: ($) => choice("=", "+=", "-="),

variable_assignment_statement: ($) =>
Expand Down Expand Up @@ -348,12 +359,29 @@ module.exports = grammar({
$.struct_literal,
$.optional_test,
$.compiler_dbg_panic,
$.optional_unwrap
$.optional_unwrap,
$.intrinsic
),

intrinsic: ($) =>
prec.right(
seq(
field("name", $.intrinsic_identifier),
optional(field("args", $.argument_list))
)
),
intrinsic_identifier: ($) => /@[A-Za-z_$0-9]*/,

// Primitives
_literal: ($) =>
choice($.string, $.number, $.bool, $.duration, $.nil_value),
choice(
$.string,
$.non_interpolated_string,
$.number,
$.bool,
$.duration,
$.nil_value
),

number: ($) => choice($._integer, $._decimal),
_integer: ($) => /\d[\d_]*/,
Expand All @@ -379,6 +407,12 @@ module.exports = grammar({
months: ($) => seq(field("value", $.number), "mo"),
years: ($) => seq(field("value", $.number), "y"),
nil_value: ($) => "nil",
non_interpolated_string: ($) =>
seq(
'#"',
repeat(choice($._non_interpolated_string_fragment, $._escape_sequence)),
'"'
),
string: ($) =>
seq(
'"',
Expand All @@ -393,6 +427,8 @@ module.exports = grammar({
),
template_substitution: ($) => seq("{", $.expression, "}"),
_string_fragment: ($) => token.immediate(prec(1, /[^{"\\]+/)),
_non_interpolated_string_fragment: ($) =>
token.immediate(prec(1, /[^"\\]+/)),
_escape_sequence: ($) =>
token.immediate(
seq(
Expand Down Expand Up @@ -488,7 +524,7 @@ module.exports = grammar({
initializer: ($) =>
seq(
optional(field("inflight", $.inflight_specifier)),
"new",
field("ctor_name", "new"),
field("parameter_list", $.parameter_list),
field("block", $.block)
),
Expand Down Expand Up @@ -674,7 +710,10 @@ module.exports = grammar({
map_literal_member: ($) => seq($.expression, "=>", $.expression),
struct_literal_member: ($) => seq($.identifier, ":", $.expression),
structured_access_expression: ($) =>
prec.right(seq($.expression, "[", $.expression, "]")),
prec.right(
PREC.STRUCTURED_ACCESS,
seq($.expression, "[", $.expression, "]")
),

json_literal: ($) =>
choice(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@winglang/tree-sitter-wing",
"version": "0.71.0",
"version": "0.74.1",
"description": "winglang grammar for tree-sitter",
"main": "bindings/node",
"types": "bindings/node",
Expand Down
46 changes: 10 additions & 36 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "tree-sitter-wing"
description = "Wing grammar for tree-sitter"
version = "0.71.0"
version = "0.74.1"
keywords = ["incremental", "parsing", "tree-sitter", "wing"]
classifiers = [
"Intended Audience :: Developers",
Expand Down
Loading

0 comments on commit edfd624

Please sign in to comment.