Skip to content

Commit e402ee0

Browse files
committed
feat: initial commit
0 parents  commit e402ee0

10 files changed

Lines changed: 1639 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version: lts/*
19+
cache: npm
20+
21+
- name: Install dependencies
22+
run: npm install
23+
24+
- name: Build
25+
run: npm run build
26+
27+
release-please:
28+
runs-on: ubuntu-latest
29+
needs: build
30+
if: github.event_name == 'push'
31+
permissions:
32+
contents: write
33+
pull-requests: write
34+
outputs:
35+
release_created: ${{ steps.release.outputs.release_created }}
36+
steps:
37+
- uses: googleapis/release-please-action@v4
38+
id: release
39+
with:
40+
token: ${{ secrets.GITHUB_TOKEN }}
41+
42+
publish:
43+
runs-on: ubuntu-latest
44+
needs: release-please
45+
if: needs.release-please.outputs.release_created == 'true'
46+
permissions:
47+
contents: read
48+
id-token: write
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- uses: actions/setup-node@v4
53+
with:
54+
node-version: lts/*
55+
registry-url: https://registry.npmjs.org
56+
cache: npm
57+
58+
- name: Install dependencies
59+
run: npm install
60+
61+
- name: Build
62+
run: npm run build
63+
64+
- name: Publish to npm
65+
run: npm publish --provenance --access public

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.github/
2+
.release-please-manifest.json
3+
release-please-config.json

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "0.0.1"
3+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Stephan Meijer and Contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# @typespecs/elixir-ast
2+
3+
[TypeSpec](https://typespec.io) definitions for a JSON-friendly Elixir expression AST.
4+
5+
## Installation
6+
7+
```sh
8+
npm install @typespecs/elixir-ast
9+
```
10+
11+
Requires `@typespec/compiler ~1.9.0` as a peer dependency:
12+
13+
```sh
14+
npm install --save-dev @typespec/compiler
15+
```
16+
17+
## Usage
18+
19+
Import the library in your TypeSpec file:
20+
21+
```tsp
22+
import "@typespecs/elixir-ast";
23+
24+
using Elixir.Ast;
25+
```
26+
27+
## Releases
28+
29+
This package uses [release-please](https://github.com/googleapis/release-please) with Conventional Commits.
30+
Use conventional commit messages (for example, `feat: add tuple helpers` or `fix: correct map key typing`) so automated versioning and changelog generation work correctly.
31+
32+
## License
33+
34+
[MIT](./LICENSE)

lib/main.tsp

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
import "@typespec/json-schema";
2+
3+
using TypeSpec.JsonSchema;
4+
5+
@jsonSchema
6+
namespace Elixir.Ast;
7+
8+
/**
9+
* Discriminator enum for all Elixir expression kinds
10+
*/
11+
enum ElixirExpressionKind {
12+
atom,
13+
string,
14+
number,
15+
boolean,
16+
nil,
17+
module_ref,
18+
list,
19+
tuple,
20+
keyword,
21+
call,
22+
}
23+
24+
/**
25+
* A keyword list entry with atom key and expression value
26+
*/
27+
model KeywordEntry {
28+
key: string;
29+
value: ElixirExpression;
30+
}
31+
32+
/**
33+
* Atom expression
34+
*/
35+
@discriminator("kind")
36+
model AtomExpression {
37+
kind: ElixirExpressionKind.atom;
38+
value: string;
39+
}
40+
41+
/**
42+
* String literal expression
43+
*/
44+
@discriminator("kind")
45+
model StringExpression {
46+
kind: ElixirExpressionKind.string;
47+
value: string;
48+
}
49+
50+
/**
51+
* Number literal expression
52+
*/
53+
@discriminator("kind")
54+
model NumberExpression {
55+
kind: ElixirExpressionKind.number;
56+
value: numeric;
57+
}
58+
59+
/**
60+
* Boolean literal expression
61+
*/
62+
@discriminator("kind")
63+
model BooleanExpression {
64+
kind: ElixirExpressionKind.boolean;
65+
value: boolean;
66+
}
67+
68+
/**
69+
* Nil literal expression
70+
*/
71+
@discriminator("kind")
72+
model NilExpression {
73+
kind: ElixirExpressionKind.nil;
74+
}
75+
76+
/**
77+
* Module reference expression
78+
*/
79+
@discriminator("kind")
80+
model ModuleRefExpression {
81+
kind: ElixirExpressionKind.module_ref;
82+
value: string;
83+
}
84+
85+
/**
86+
* List expression
87+
*/
88+
@discriminator("kind")
89+
model ListExpression {
90+
kind: ElixirExpressionKind.list;
91+
items: ElixirExpression[];
92+
}
93+
94+
/**
95+
* Tuple expression
96+
*/
97+
@discriminator("kind")
98+
model TupleExpression {
99+
kind: ElixirExpressionKind.tuple;
100+
items: ElixirExpression[];
101+
}
102+
103+
/**
104+
* Keyword list expression
105+
*/
106+
@discriminator("kind")
107+
model KeywordExpression {
108+
kind: ElixirExpressionKind.keyword;
109+
entries: KeywordEntry[];
110+
}
111+
112+
/**
113+
* Function or macro call expression
114+
*/
115+
@discriminator("kind")
116+
model CallExpression {
117+
kind: ElixirExpressionKind.call;
118+
name: string;
119+
args: ElixirExpression[];
120+
}
121+
122+
/**
123+
* All Elixir expression types
124+
*/
125+
union ElixirExpression {
126+
AtomExpression,
127+
StringExpression,
128+
NumberExpression,
129+
BooleanExpression,
130+
NilExpression,
131+
ModuleRefExpression,
132+
ListExpression,
133+
TupleExpression,
134+
KeywordExpression,
135+
CallExpression,
136+
}

0 commit comments

Comments
 (0)