Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions AGENT.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
# ScoreLang Agent Guidelines

## Development

The development instance of the website is running at http://localhost:5173/

## Commands
- Run tests: `bun test`
- Run specific test: `bun test src/lexer.test.ts`
- Build project: `bun build ./src/index.ts --compile --outfile scorelang`

## Code Style Guidelines

- **Imports**: Use named imports for specific components, default exports for main classes
- **Types**: Use TypeScript with explicit type annotations, const assertions when appropriate
- **Error handling**: Use console.log for errors, return null/ILLEGAL tokens for invalid inputs
- **Naming conventions**:
- **Naming conventions**:
- Classes: PascalCase (e.g., Lexer)
- Methods/variables: camelCase
- Constants: UPPER_SNAKE_CASE for token types
- **Formatting**: 2-space indentation, semicolons at end of statements
- **Class structure**: Private methods prefixed with 'private', constructor parameters prefixed with 'private' when appropriate
- **Class structure**: Private methods prefixed with 'private', constructor parameters prefixed with 'private' when appropriate
66 changes: 15 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,27 @@
# scorelang
# ScoreLang: Football Tournament DSL

A DSL to run Football tournaments.
ScoreLang is a domain-specific language (DSL) for tracking and calculating football (soccer) tournament scores and standings.

# Build
## Project Structure

```bash
bun run build
```

`scorelang` binary should be ready to use now.
This repository is organized as a monorepo with the following packages:

# Usage
- [`packages/lang`](./packages/lang): Core language implementation, parser, and CLI tool
- [`packages/web`](./packages/web): Web interface for ScoreLang

- Record the scores of the tournament in text form (save as `tournament.sl`). Separated by semi-colon;

```
TeamA 2-0 TeamB;
TeamA 3-0 TeamC;
TeamB 0-1 TeamC;
TeamA 0-0 TeamB;
TeamA 1-5 TeamC;
TeamB 0-1 TeamC;
TeamA 2-2 TeamB;
TeamA 4-0 TeamC;
TeamB 1-0 TeamC;
TeamA 0-2 TeamB;
TeamA 1-0 TeamC;
TeamB 0-1 TeamC;
TeamA 1-4 TeamB;
TeamA 1-3 TeamC;
TeamB 3-1 TeamC;
TeamA 0-3 TeamB;
TeamA 0-2 TeamC;
TeamB 1-1 TeamC;
```
## Getting Started

- pipe it into the scorelang binary
This project uses [Bun](https://bun.sh/) as its package manager and runtime.

```bash
cat tournaments.sl | ./scorelang
```

or execute the file
# Install dependencies
bun install

```bash
./scorelang src/tournamet.sl
# Build all packages
bun run build
```

- It prints the points table
See the individual package READMEs for more detailed usage instructions:

```
./scorelang src/tournament.sl 20:01:32
┌───────┬──────┬────────┬───────┬────────┐
│ Team │ Wins │ Losses │ Draws │ Points │
├───────┼──────┼────────┼───────┼────────┤
│ TeamC │ 6 │ 5 │ 1 │ 19 │
├───────┼──────┼────────┼───────┼────────┤
│ TeamB │ 5 │ 4 │ 3 │ 18 │
├───────┼──────┼────────┼───────┼────────┤
│ TeamA │ 4 │ 6 │ 2 │ 14 │
└───────┴──────┴────────┴───────┴────────┘
```
- [Language Package README](./packages/lang/README.md)
- [Web Interface README](./packages/web/README.md)
632 changes: 630 additions & 2 deletions bun.lock

Large diffs are not rendered by default.

20 changes: 6 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
{
"name": "scorelang",
"module": "index.ts",
"type": "module",
"private": true,
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5"
},
"dependencies": {
"cli-table3": "^0.6.5",
"tiny-invariant": "^1.3.3",
"ts-pattern": "^5.7.0"
},
"workspaces": [
"packages/*"
],
"scripts": {
"build": "bun build ./src/index.ts --compile --outfile scorelang"
"build": "bun run --filter=* build",
"tsc": "bun run --filter=* tsc",
"lint": "bun run --filter=* lint"
}
}
63 changes: 63 additions & 0 deletions packages/lang/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# scorelang

A DSL to run Football tournaments.

# Build

```bash
bun run build
```

`scorelang` binary should be ready to use now.

# Usage

- Record the scores of the tournament in text form (save as `tournament.sl`). Separated by semi-colon;

```
TeamA 2-0 TeamB;
TeamA 3-0 TeamC;
TeamB 0-1 TeamC;
TeamA 0-0 TeamB;
TeamA 1-5 TeamC;
TeamB 0-1 TeamC;
TeamA 2-2 TeamB;
TeamA 4-0 TeamC;
TeamB 1-0 TeamC;
TeamA 0-2 TeamB;
TeamA 1-0 TeamC;
TeamB 0-1 TeamC;
TeamA 1-4 TeamB;
TeamA 1-3 TeamC;
TeamB 3-1 TeamC;
TeamA 0-3 TeamB;
TeamA 0-2 TeamC;
TeamB 1-1 TeamC;
```

- pipe it into the scorelang binary

```bash
cat tournaments.sl | ./scorelang
```

or execute the file

```bash
./scorelang src/tournament.sl
```

- It prints the points table

```
./scorelang src/tournament.sl 20:01:32
┌───────┬──────┬────────┬───────┬────────┐
│ Team │ Wins │ Losses │ Draws │ Points │
├───────┼──────┼────────┼───────┼────────┤
│ TeamC │ 6 │ 5 │ 1 │ 19 │
├───────┼──────┼────────┼───────┼────────┤
│ TeamB │ 5 │ 4 │ 3 │ 18 │
├───────┼──────┼────────┼───────┼────────┤
│ TeamA │ 4 │ 6 │ 2 │ 14 │
└───────┴──────┴────────┴───────┴────────┘
```
25 changes: 25 additions & 0 deletions packages/lang/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@scorelang/lang",
"module": "index.ts",
"type": "module",
"private": true,
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5"
},
"dependencies": {
"cli-table3": "^0.6.5",
"tiny-invariant": "^1.3.3",
"ts-pattern": "^5.7.0"
},
"workspaces": [
"packages/*"
],
"scripts": {
"build": "bun build ./src/index.ts --compile --outfile scorelang",
"tsc": "tsc --noEmit",
"lint": "eslint ."
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions packages/web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
3 changes: 3 additions & 0 deletions packages/web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Scorelang UI

UI to manage Football tournaments via `scorelang`
Loading