Skip to content

Commit

Permalink
feat(manifest, cli): bump compiler version to 0.4.0; rename compiler-…
Browse files Browse the repository at this point in the history
…>neva in manifesto; refactor
  • Loading branch information
emil14 committed Feb 18, 2024
1 parent ac19c83 commit 1a0c743
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 15 deletions.
10 changes: 10 additions & 0 deletions cmd/neva/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package main
import (
"context"
"errors"
"fmt"
"path/filepath"
"strings"

"github.com/nevalang/neva/internal/interpreter"
"github.com/nevalang/neva/pkg"
cli "github.com/urfave/cli/v2"
)

Expand Down Expand Up @@ -46,6 +48,14 @@ func newApp(intr interpreter.Interpreter, wd string) *cli.App {
panic("not implemented")
},
},
{
Name: "version",
Usage: "Get current Nevalang version",
Action: func(cCtx *cli.Context) error {
fmt.Println(pkg.Version)
return nil
},
},
},
}
}
2 changes: 1 addition & 1 deletion examples/neva.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# They not only serve documentation purposes, they are also
# e2e tests that you can manually run to ensure that Nevalang works.

compiler: 0.0.1
neva: 0.4.0

deps:
- path: github.com/nevalang/x
Expand Down
4 changes: 2 additions & 2 deletions internal/compiler/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ func (a Analyzer) AnalyzeBuild(build src.Build) (src.Build, *compiler.Error) {
analyzedMods := make(map[src.ModuleRef]src.Module, len(build.Modules))

for modRef, mod := range build.Modules {
if mod.Manifest.WantCompilerVersion != a.compilerVersion {
if mod.Manifest.LanguageVersion != a.compilerVersion {
return src.Build{}, &compiler.Error{
Err: fmt.Errorf(
"%w: module %v wants %v while current is %v",
ErrCompilerVersion,
modRef, mod.Manifest.WantCompilerVersion, a.compilerVersion,
modRef, mod.Manifest.LanguageVersion, a.compilerVersion,
),
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/compiler/desugarer/desugarer.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func (d Desugarer) desugarModule(build src.Build, modRef src.ModuleRef) (src.Mod

// create manifest copy with std module dependency
desugaredManifest := src.ModuleManifest{
WantCompilerVersion: mod.Manifest.WantCompilerVersion,
Deps: make(map[string]src.ModuleRef, len(mod.Manifest.Deps)+1),
LanguageVersion: mod.Manifest.LanguageVersion,
Deps: make(map[string]src.ModuleRef, len(mod.Manifest.Deps)+1),
}
maps.Copy(desugaredManifest.Deps, mod.Manifest.Deps)
desugaredManifest.Deps["std"] = src.ModuleRef{Path: "std", Version: "0.0.1"} // TODO rethink stdlib
Expand Down
4 changes: 2 additions & 2 deletions internal/compiler/desugarer/desugarer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestDesugarer_Desugar(t *testing.T) {
build: src.Build{
Modules: map[src.ModuleRef]src.Module{
{}: {
Manifest: src.ModuleManifest{WantCompilerVersion: "0.0.1"},
Manifest: src.ModuleManifest{LanguageVersion: "0.0.1"},
Packages: map[string]src.Package{
"main": {
"file": src.File{
Expand Down Expand Up @@ -64,7 +64,7 @@ func TestDesugarer_Desugar(t *testing.T) {
Modules: map[src.ModuleRef]src.Module{
{}: {
Manifest: src.ModuleManifest{
WantCompilerVersion: "0.0.1",
LanguageVersion: "0.0.1",
Deps: map[string]src.ModuleRef{
"std": { // <-- stdlib mod dep added
Path: "std",
Expand Down
4 changes: 2 additions & 2 deletions internal/compiler/parser/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func manifestToSourceCode(manifest Manifest) src.ModuleManifest {
}
}
return src.ModuleManifest{
WantCompilerVersion: manifest.WantCompilerVersion,
Deps: deps,
LanguageVersion: manifest.WantCompilerVersion,
Deps: deps,
}
}
2 changes: 1 addition & 1 deletion internal/pkgmanager/tests/intergration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestPkgManager(t *testing.T) {
mod, ok := build.Modules[build.EntryModRef]
require.True(t, ok)
require.Len(t, mod.Packages, 1)
require.Equal(t, mod.Manifest.WantCompilerVersion, "0.0.1")
require.Equal(t, mod.Manifest.LanguageVersion, "0.0.1")

pkg, ok := mod.Packages["do_nothing"]
require.True(t, ok)
Expand Down
2 changes: 1 addition & 1 deletion internal/pkgmanager/tests/testmod/neva.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
compiler: 0.0.1
neva: 0.4.0
4 changes: 2 additions & 2 deletions pkg/sourcecode/sourcecode.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func (mod Module) Files(f func(file File, pkgName, fileName string)) {
}

type ModuleManifest struct {
WantCompilerVersion string `json:"compiler,omitempty" yaml:"compiler,omitempty"`
Deps map[string]ModuleRef `json:"deps,omitempty" yaml:"deps,omitempty"`
LanguageVersion string `json:"neva,omitempty" yaml:"neva,omitempty"`
Deps map[string]ModuleRef `json:"deps,omitempty" yaml:"deps,omitempty"`
}

type ModuleRef struct {
Expand Down
4 changes: 4 additions & 0 deletions pkg/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package pkg

// Current version of the language
var Version = "0.4.0"
3 changes: 2 additions & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

BIN_URL="https://github.com/nevalang/neva/releases/download/v0.3.0/neva"
LATEST_TAG=$(curl -s https://api.github.com/repos/nevalang/neva/releases/latest | grep "tag_name" | cut -d '"' -f 4)
BIN_URL="https://github.com/nevalang/neva/releases/download/$LATEST_TAG/neva"
INSTALL_DIR="/usr/local/bin"
BIN_NAME="neva"

Expand Down
2 changes: 1 addition & 1 deletion std/neva.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
compiler: 0.0.1
neva: 0.4.0

0 comments on commit 1a0c743

Please sign in to comment.