Finish up parser and assembler with more-or-less complete syntax

Major changes inlude:

* Bit the bullet and now instructions have their length hard-coded
* Move from_utf8 object parsing to be done by their objects (instead of
  a Parser god object)
* A list of AST sections are assembled into an Object using the new
  vm::obj::assemble module.
* Changed the object layout some in the spec, and adjusted code to match
  this.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-02-09 13:04:56 -05:00
parent 329e61e087
commit e198da5825
19 changed files with 739 additions and 311 deletions

View File

@@ -5,6 +5,7 @@ mod common;
mod vm;
use std::{
convert::TryFrom,
io::{self, Read},
process,
};
@@ -18,15 +19,16 @@ fn get_input_string() -> io::Result<String> {
}
fn main() -> Result<()> {
use vm::syn::parser::ProgramParser;
use vm::obj::syn::parser::SectionsParser;
let contents = get_input_string()?;
let ast = match ProgramParser::new().parse(&contents) {
let ast = match SectionsParser::new().parse(&contents) {
Ok(ast) => ast,
Err(err) => {
eprintln!("{}", err);
process::exit(1);
},
};
println!("{:#?}", ast);
let obj = vm::obj::obj::Object::try_from(&ast)?;
println!("{:#?}", obj);
Ok(())
}