From aaf6455762704fe2648a8db64bc34cc511b9a7e3 Mon Sep 17 00:00:00 2001 From: Tony Bark <35226681+tonytins@users.noreply.github.com> Date: Sun, 9 May 2021 15:03:45 -0400 Subject: [PATCH] An update! Just minor tweaks and slight updates. --- README.md | 26 ++++++-------------------- docs/README.md | 18 +----------------- src/assembler.rs | 1 + src/assembler/opcode_parser.rs | 26 +++++++++++++------------- 4 files changed, 21 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 3228f7f..e54b0d5 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,13 @@ # Corten -Corten is a RISC virtual machine written in Rust as a hobby and based on Fletcher Haynes's [So you want to build a language VM](https://blog.subnetzero.io/post/building-language-vm-part-01/) tutorial. +Corten is a RISC-V virtual machine written in Rust as a hobby and based on Fletcher Haynes's [So you want to build a language VM](https://blog.subnetzero.io/post/building-language-vm-part-01/) tutorial. ## Build Status -| Service | Status | -| --------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -| Github | ![Rust](https://github.com/tonytins/corten/workflows/Rust/badge.svg) | -| Travis CI | [![Build Status](https://travis-ci.org/tonytins/corten.svg?branch=master)](https://travis-ci.org/tonytins/corten) | -| AppVeyor | [![Build status](https://ci.appveyor.com/api/projects/status/ffru6ik26j2b87ko?svg=true)](https://ci.appveyor.com/project/tonytins/corten) | +| Service | Status | +| --------- | ----------------------------------------------------------------------------------------------------------------- | +| Github | ![Rust](https://github.com/tonytins/corten/workflows/Rust/badge.svg) | +| Travis CI | [![Build Status](https://travis-ci.org/tonytins/corten.svg?branch=master)](https://travis-ci.org/tonytins/corten) | ## Specifications @@ -21,20 +20,7 @@ See [specifications](docs/spec.md) page. - Rust 1.41+ - Recommended IDEs - Visual Studio Code - - Jetbrains IntelliJ - -### Supported Platforms - -- Ubuntu 18.04+ -- Windows 10 v1809+ -- macOS 10.15+ - -## Authors - -- **Anthony Foxclaw** - *Initial work* - [tonytins](https://github.com/tonytins) -- **Fletcher Haynes** - *Tutorial* - [fletchercp](https://gitlab.com/fletchercp) - -See also the list of [contributors](https://github.com/tonytins/simtactics/contributors) who participated in this project. + - Jetbrains IntelliJ or CLion ## License diff --git a/docs/README.md b/docs/README.md index 2a558a4..bdfbebb 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,27 +1,11 @@ # Welcome -Corten is a RISC virtual machine written in Rust as a hobby and based on Fletcher Haynes's [So you want to build a language VM](https://blog.subnetzero.io/post/building-language-vm-part-01/) tutorial. +Corten is a RISC-V virtual machine written in Rust as a hobby and based on Fletcher Haynes's [So you want to build a language VM](https://blog.subnetzero.io/post/building-language-vm-part-01/) tutorial. ## Specifications See [specifications](spec.md) page. -## Build Status - -| Service | Status | -| --------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -| Github | ![Rust](https://github.com/tonytins/corten/workflows/Rust/badge.svg) | -| Travis CI | [![Build Status](https://travis-ci.org/tonytins/corten.svg?branch=master)](https://travis-ci.org/tonytins/corten) | -| AppVeyor | [![Build status](https://ci.appveyor.com/api/projects/status/ffru6ik26j2b87ko?svg=true)](https://ci.appveyor.com/project/tonytins/corten) | - -## Requirements - -### Supported Platforms - -- Ubuntu 18.04+ -- Windows 10 v1809+ -- macOS 10.15+ - ## License This project is licensed under the MPL 2.0 license - see the [LICENSE](LICENSE) file for details. \ No newline at end of file diff --git a/src/assembler.rs b/src/assembler.rs index fd0a75d..32dfe6d 100644 --- a/src/assembler.rs +++ b/src/assembler.rs @@ -15,6 +15,7 @@ pub enum Token { Number { value: i32 }, } +// RISC-V opcodes #[derive(Debug, PartialEq, Clone)] pub enum Opcode { HLT, diff --git a/src/assembler/opcode_parser.rs b/src/assembler/opcode_parser.rs index f19e178..ceb5ce2 100644 --- a/src/assembler/opcode_parser.rs +++ b/src/assembler/opcode_parser.rs @@ -17,18 +17,18 @@ named!(pub opcode, #[cfg(test)] mod opcode_parser_test { - use super::*; + use super::*; - #[test] - fn test_parser_op_load() { - // Test that opcode is dected and parsed correctly - let result = opcode(CompleteStr("load")); - assert_eq!(result.is_ok(), true); - let (rest, token) = result.unwrap(); - assert_eq!(token, Token::Opcode { code: Opcode::LOAD }); - assert_eq!(rest, CompleteStr("")); - let result = opcode(CompleteStr("alod")); - let (_, token) = result.unwrap(); - assert_eq!(token, Token::Opcode { code: Opcode::IGL }); - } + #[test] + fn test_parser_op_load() { + // Test that opcode is detected and parsed correctly + let result = opcode(CompleteStr("load")); + assert_eq!(result.is_ok(), true); + let (rest, token) = result.unwrap(); + assert_eq!(token, Token::Opcode { code: Opcode::LOAD }); + assert_eq!(rest, CompleteStr("")); + let result = opcode(CompleteStr("alod")); + let (_, token) = result.unwrap(); + assert_eq!(token, Token::Opcode { code: Opcode::IGL }); + } }