Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fa245c1056 | |||
| f866b602ad | |||
| 7cc1401d36 |
129
README.md
129
README.md
@@ -1,18 +1,125 @@
|
||||
# Violet
|
||||
<div align="center">
|
||||
|
||||
## Stack Guide
|
||||
<h1 style="color:#967bb6;font-size:3rem;">Violet</h1>
|
||||
|
||||
### Install Dependencies
|
||||
An expressive, type-safe programming language
|
||||
|
||||
1. `stack.yaml`: add `package-name-version` to `extra-deps`
|
||||
2. `package.yaml`: add `package-name` to `dependencies`
|
||||
3. run `stack build`
|
||||
[![Release v0.1.0][release-badge]](https://github.com/zyrrus/violet/releases)
|
||||
[![Haskell][haskell-badge]](https://www.haskell.org/)
|
||||
|
||||
### Run GHCI
|
||||
[release-badge]: https://img.shields.io/badge/v0.1.0-996677?colorA=151515&style=for-the-badge
|
||||
[haskell-badge]: https://img.shields.io/badge/Haskell-5e5086?logo=haskell&logoColor=white&style=for-the-badge
|
||||
|
||||
1. run `stack ghci`
|
||||
2. run `:set -XOverloadedStrings` in GHCI
|
||||
</div>
|
||||
|
||||
## References
|
||||
<!-- TABLE OF CONTENTS -->
|
||||
<details>
|
||||
<summary>Table of Contents</summary>
|
||||
<ol>
|
||||
<li>
|
||||
<a href="#about-the-project">About the Project</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#getting-started">Getting Started</a>
|
||||
<ul>
|
||||
<li><a href="#prerequisites">Prerequisites</a></li>
|
||||
<li><a href="#installation">Installation</a></li>
|
||||
<li><a href="#development-guides">Development Guides</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#usage">Usage</a></li>
|
||||
<li><a href="#roadmap">Roadmap</a></li>
|
||||
</ol>
|
||||
</details>
|
||||
|
||||
[Megaparsec guide](https://markkarpov.com/tutorial/megaparsec.html#parsect-and-parsec-monads)
|
||||
## About the Project
|
||||
|
||||
The Violet programming language draws inspiration from Python's expressiveness, Rust's syntax clarity, and TypeScript's type system. The goal is to create a versatile tool for developers that is easy to learn and doesn't sacrifice performance or type-safety.
|
||||
|
||||
## Getting Started
|
||||
|
||||
Follow these steps to set up a development environment.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
You'll need to have Haskell and Stack set up on your system. I advise installing [GHCup](https://haskell.org/ghcup/install) to manage your Haskell environment.
|
||||
|
||||
These are the versions I had installed while developing Violet.
|
||||
|
||||
| | Version |
|
||||
| ----- | -------: |
|
||||
| GHCup | 0.1.20.0 |
|
||||
| GHC | 9.4.8 |
|
||||
| Stack | 2.13.1 |
|
||||
| Cabal | 3.10.2.1 |
|
||||
| HLS | 2.5.0.0 |
|
||||
|
||||
### Installation
|
||||
|
||||
1. Clone the repo
|
||||
```sh
|
||||
git clone https://github.com/zyrrus/violet.git
|
||||
```
|
||||
2. Build the project
|
||||
```sh
|
||||
stack build
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Development Guides
|
||||
|
||||
This section contains small, miscellaneous guides for anything I find helpful that is not specifically tied to setting up the environment for this project.
|
||||
|
||||
#### Installing Dependencies
|
||||
|
||||
1. In `stack.yaml`, add `package-name-version` to `extra-deps`
|
||||
2. In `package.yaml`, add `package-name` to `dependencies`
|
||||
3. Build the project again
|
||||
```sh
|
||||
stack build
|
||||
```
|
||||
|
||||
#### Running GHCI
|
||||
|
||||
1. Run the interpreter
|
||||
```sh
|
||||
stack ghci
|
||||
```
|
||||
2. Run `:set -XOverloadedStrings` in GHCI
|
||||
|
||||
## Usage
|
||||
|
||||
> **⚠️ Warning:**\
|
||||
> Violet is a hobby project that is still under development.
|
||||
|
||||
### Release v0.1.0 (Parser executable)
|
||||
|
||||
This release contains an executable, `violet.exe`, that just parses a file and prints the program in the form of a list of `Statements`
|
||||
|
||||
The program expects a single file path argument (demonstrated below).
|
||||
|
||||
```sh
|
||||
./violet.exe path/to/file.vi
|
||||
```
|
||||
|
||||
## Roadmap
|
||||
|
||||
- [x] Basic lexer/parser
|
||||
- [x] Comments (block + single-line)
|
||||
- [x] Imports
|
||||
- [x] Function definitions
|
||||
- [x] Variable declaration + assignment
|
||||
- [x] Conditionals
|
||||
- [x] Expressions
|
||||
- [ ] Full lexer/parser
|
||||
- [ ] Type system (definitions + operations)
|
||||
- [ ] Lists
|
||||
- [ ] List comprehensions
|
||||
- [ ] Ternary operations
|
||||
- [ ] Bit-wise operations
|
||||
- [ ] Syntactic sugar (`elif`, compound assignment operators like `x += 4`)
|
||||
- [ ] Semantic analysis
|
||||
- [ ] Compiler
|
||||
|
||||
---
|
||||
|
||||
28
docs/samples/test.vi.ast
Normal file
28
docs/samples/test.vi.ast
Normal file
@@ -0,0 +1,28 @@
|
||||
Program {
|
||||
statements = [
|
||||
Comment "Here is a brief sample of the\nlanguage and its syntax",
|
||||
Comment "Import statements",
|
||||
Import ["std", "collections"] ["Heap", "HashMap"],
|
||||
Comment "Function declaration with types",
|
||||
Function (IdentifierWithType "fizz-buzz" (Just "Str")) [IdentifierWithType "i" (Just "Num")] [
|
||||
Comment "This is technically a legal comment",
|
||||
Let (IdentifierWithType "fb" Nothing) (LiteralString ""),
|
||||
Conditional (BinaryOperation Equal (BinaryOperation Modulus (Variable "i") (LiteralInt 3)) (LiteralInt 0)) [
|
||||
Assignment "fb" (BinaryOperation Concat (Variable "fb") (LiteralString "fizz"))
|
||||
] Nothing,
|
||||
Conditional (BinaryOperation Equal (BinaryOperation Modulus (Variable "i") (LiteralInt 5)) (LiteralInt 0)) [
|
||||
Assignment "fb" (BinaryOperation Concat (Variable "fb") (LiteralString "buzz"))
|
||||
] Nothing,
|
||||
Conditional (FunctionCall "is-empty" [Variable "fb"]) [
|
||||
Return (Variable "i")
|
||||
] (Just [
|
||||
Return (Variable "fb")
|
||||
])
|
||||
],
|
||||
Comment "Function declaration without types",
|
||||
Function (IdentifierWithType "main" Nothing) [] [
|
||||
Const (IdentifierWithType "fb" (Just "Str")) (FunctionCall "fizz-buzz" []),
|
||||
Expr (FunctionCall "print" [Variable "fb"])
|
||||
]
|
||||
]
|
||||
}
|
||||
@@ -77,6 +77,8 @@ data BinaryOperator
|
||||
-- | BitOr
|
||||
-- | ...
|
||||
-- | x in list
|
||||
-- | x is type
|
||||
-- | x is not type
|
||||
deriving (Show)
|
||||
|
||||
data UnaryOperator
|
||||
|
||||
Reference in New Issue
Block a user