Skip to content

Commit

Permalink
Absolute module imports and roots #7
Browse files Browse the repository at this point in the history
  • Loading branch information
vknabel committed Sep 16, 2021
1 parent c603a4c commit 7d155d2
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 187 deletions.
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ archives:
windows: Windows
386: i386
amd64: x86_64
files:
- stdlib/**/*.lithia
checksum:
name_template: 'checksums.txt'
snapshot:
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

## 0.0.1
## v0.0.2

- Absolute modules and multiple roots #7

## v0.0.1

- Proof of concept
- Most basic stdlib
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ No. Unless you want to play around with new language concepts for some local non

> Currently Lithia is just an early proof of concept. Most basic language features exist, but the current tooling and standard libraries are far from being feature complete or stable.
## Installation

If you want to give Lithia a try, the easiest way to get started is using Homebrew. By default Lithia is now ready to go.

```bash
$ brew install vknabel/lithia/lithia
```

To get syntax highlighting, download and install the latest version of [Syntax Highlighter with Lithia](https://github.com/vknabel/syntax-highlighter/releases) for VS Code.

## Which features does Lithia provide?

Lithia is built around the belief, that a language is not only defined by its features, but also by the features it lacks, how it instead approaches these cases and by its ecosystem. And that every feature comes with its own tradeoffs.
Expand Down Expand Up @@ -46,7 +56,7 @@ func greet { person =>

### Enum Types

in Lithia are a little bit different than you might know them from other languages.
in Lithia are a little bit different than you might know them from other languages.
Some languages define enums just as a list of constant values. Others allow associated values for each named case.
Though in Lithia, an enum is an enumeration of types.

Expand All @@ -62,8 +72,8 @@ enum JuristicPerson {
}
```

Instead of a classic switch-case statement, there is a `type`-expression instead.
It requires you to list all types of the enum type. It returns a function which takes a valid enum type.
Instead of a classic switch-case statement, there is a `type`-expression instead.
It requires you to list all types of the enum type. It returns a function which takes a valid enum type.

```
import strings
Expand Down
36 changes: 18 additions & 18 deletions interpreter/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,41 @@ import (
)

type SyntaxError struct {
Message string
Node *sitter.Node
Source []byte
ModuleFile ModuleFile
Message string
Node *sitter.Node
Source []byte
File string
}

func (ex *EvaluationContext) SyntaxErrorf(format string, args ...interface{}) SyntaxError {
return SyntaxError{
Message: fmt.Sprintf(format, args...),
Node: ex.node,
Source: ex.source,
ModuleFile: ex.moduleFile,
Message: fmt.Sprintf(format, args...),
Node: ex.node,
Source: ex.source,
File: ex.file,
}
}

func (e SyntaxError) Error() string {
return FormatNodeErrorMessage("syntax error", e.Message, e.ModuleFile.name, e.Node, string(e.Source))
return FormatNodeErrorMessage("syntax error", e.Message, e.File, e.Node, string(e.Source))
}

type RuntimeError struct {
Message string
Node *sitter.Node
Source []byte
ModuleFile ModuleFile
Message string
Node *sitter.Node
Source []byte
File string
}

func (ex *EvaluationContext) RuntimeErrorf(format string, args ...interface{}) RuntimeError {
return RuntimeError{
Message: fmt.Sprintf(format, args...),
Node: ex.node,
Source: ex.source,
ModuleFile: ex.moduleFile,
Message: fmt.Sprintf(format, args...),
Node: ex.node,
Source: ex.source,
File: ex.file,
}
}

func (e RuntimeError) Error() string {
return FormatNodeErrorMessage("runtime error", e.Message, e.ModuleFile.name, e.Node, string(e.Source))
return FormatNodeErrorMessage("runtime error", e.Message, e.File, e.Node, string(e.Source))
}
Loading

0 comments on commit 7d155d2

Please sign in to comment.