Skip to content

Commit

Permalink
fix: ci
Browse files Browse the repository at this point in the history
  • Loading branch information
rvcas committed Jun 19, 2024
1 parent 17a0b8e commit 1f4af8d
Show file tree
Hide file tree
Showing 7 changed files with 1,792 additions and 918 deletions.
22 changes: 18 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,25 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 📥 Checkout repository
uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
- name: 📦 Setup pnpm
uses: pnpm/action-setup@v3
with:
version: latest
run_install: true

- run: pnpm test
- name: 📦 Setup Node.js
uses: actions/setup-node@v4
with:
cache: "pnpm"
node-version: "latest"

- name: 🛠️ Install dependencies
run: pnpm install --frozen-lockfile

- name: 🧪 Run fmt check
run: pnpm prettier --check .

- name: 🧪 Run test
run: pnpm test
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pnpm-lock.yaml
bindings/
src/
91 changes: 48 additions & 43 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,13 @@
module.exports = grammar({
name: "aiken",
rules: {
source_file: ($) => repeat(choice(
$._definition,
$.module_comment,
$.definition_comment,
$.comment,
)),
extras: ($) => choice(
$.type_struct_inner
),
_definition: ($) => choice(
$.import,
$.type_alias,
$.type_struct,
$.type_enum,
$.constant,
),
source_file: ($) =>
repeat(
choice($._definition, $.module_comment, $.definition_comment, $.comment)
),
extras: ($) => choice($.type_struct_inner),
_definition: ($) =>
choice($.import, $.type_alias, $.type_struct, $.type_enum, $.constant),

// Handles import definitions
// use foo
Expand Down Expand Up @@ -47,42 +38,56 @@ module.exports = grammar({
),

// Handles type aliasing definitions
type_alias: ($) =>
seq("type", $.type_definition, "=", $.type_definition),
type_alias: ($) => seq("type", $.type_definition, "=", $.type_definition),

// Handle enum type definitions
type_enum: ($) => seq("type", $.type_definition, block(repeat1(
$.type_enum_variant,
))),
type_enum_variant: ($) => choice(
// Foo
$.type_identifier,
// Foo(Foo)
// Foo(a, b)
seq($.type_identifier, seq("(", repeat_separated_by($.type_argument, ","), ")")),
// Foo { bar: Baz }
$.type_struct_inner
),
type_enum: ($) =>
seq("type", $.type_definition, block(repeat1($.type_enum_variant))),
type_enum_variant: ($) =>
choice(
// Foo
$.type_identifier,
// Foo(Foo)
// Foo(a, b)
seq(
$.type_identifier,
seq("(", repeat_separated_by($.type_argument, ","), ")")
),
// Foo { bar: Baz }
$.type_struct_inner
),

// Handle struct type definitions (syntax sugar for enumerations with only one element)
type_struct: ($) =>
seq("type", $.type_struct_inner),
type_struct_inner: ($) => seq($.type_definition, block($.type_struct_fields)),
type_struct: ($) => seq("type", $.type_struct_inner),
type_struct_inner: ($) =>
seq($.type_definition, block($.type_struct_fields)),
type_struct_fields: ($) => repeat1($.type_struct_field),
type_struct_field: ($) => seq($.identifier, ":", $.type_argument),

type_definition: ($) =>
seq($.type_identifier, optional(seq("<", repeat_separated_by($.type_argument, ","), ">"))),
type_argument: ($) => field("type_argument", choice($.identifier, $.type_definition)),
seq(
$.type_identifier,
optional(seq("<", repeat_separated_by($.type_argument, ","), ">"))
),
type_argument: ($) =>
field("type_argument", choice($.identifier, $.type_definition)),

// Constants
constant: ($) => seq("const", $.identifier, optional(seq(":", $.type_definition)), "=", $.constant_value),
constant_value: ($) => choice(
$.int,
$.string,
$.bytes,
// $.curvepoint - Should this be here?
),
constant: ($) =>
seq(
"const",
$.identifier,
optional(seq(":", $.type_definition)),
"=",
$.constant_value
),
constant_value: ($) =>
choice(
$.int,
$.string,
$.bytes
// $.curvepoint - Should this be here?
),

base10: (_$) => token(/[0-9]+/),
base10_underscore: (_$) => token(/[0-9]+(_[0-9]+)+/),
Expand Down Expand Up @@ -126,5 +131,5 @@ function repeat_separated_by(
}

function block(rule, start_sep = "{", end_sep = "}") {
return seq(start_sep, rule, end_sep)
return seq(start_sep, rule, end_sep);
}
44 changes: 25 additions & 19 deletions pnpm-lock.yaml

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

Loading

0 comments on commit 1f4af8d

Please sign in to comment.