# README
Lazo: A Smart Contract Language for the Bazo Blockchain
Lazo is a statically typed, imperative and non-turing complete programming language. Please refer to lazo-specification for the complete language features.
Background
The Bazo Blockchain is a research blockchain to test different mechanisms and algorithms. In the current version, there is a virtual machine available to interpret and execute IL codes on the Bazo Blockchain.
The goal of this bachelor thesis is to build a compiler, which compiles the smart contracts written in the Lazo language into the Bazo Byte Code for the Bazo Virtual Machine.
Lazo Source Code
|
V
+---------------+
| Lexer |
+---------------+
|
V
+---------------+
| Parser |
+---------------+
|
V
+---------------+
| Checker |
+---------------+
|
V
+---------------+
| Generator |
+---------------+
|
V
Bazo Byte Code
Result
- Link to technical documentation (Bachelor Thesis 2019)
- Complete Language Specification v1.0 (Term Project 2018)
Lazo Example
Note: Lazo is still under development. The example below contains only the currently available features. Please see lazo-specification/examples for real smart contract use cases.
contract SimpleContract {
Map<int, int> balances
constructor() {
balances[0x01] = 10
balances[0x02] = 2
pay(0x01, 0x02, 5)
}
function void pay(int from, int to, int amount) {
if (amount > 0 && balances[from] >= amount){
balances[from] -= amount
balances[to] += amount
}
}
}
Usage
The Lazo tool works with the CLI commands.
Run lazo
to see all the available commands and their usages.
$ lazo
Lazo is a tool for managing Lazo source code on the Bazo Blockchain
Usage:
lazo [flags]
lazo [command]
Available Commands:
compile Compile the Lazo source code
help Help about any command
run Compile and run the lazo source code on Bazo VM
version Print the version number of Lazo
Flags:
-h, --help help for lazo
Use "lazo [command] --help" for more information about a command.
Example:
lazo compile program.lazo
: Compile the source file program.lazo through all stages into Bazo byte code.lazo compile program.lazo --stage=p
: Compile the source code only until the parser stage.lazo run program.lazo
: Compile the source file and execute generated byte code on Bazo VM
Development
Run ./scripts/set-hooks.sh
to setup git hooks.
Dependency Management
Packages are managed by Go Modules.
Set the environment variable GO111MODULE=on
and run go mod vendor
to install all the dependencies into the local vendor directory.
Run Compiler from Source
go run main.go compile program.lazo
It will compile the given source code file "program.lazo".
Run Unit Tests
go test ./...
It will run all tests in the current directory and all of its subdirectories.
To see the test coverage, run ./scripts/test.sh
and then open the coverage.html file.
Run Lints
./scripts/lint.sh
It will run golint on all packages except the vendor directory.
Build Compiler
go build
It will create an executable for the current operating system (e.g. lazo.exe
in Windows).
Install Compiler
go install
It will build an executable and place it in the $GOPATH/bin
directory.
Thus, lazo
command will be available in the terminal from anywhere.