Updated to use the Rust 2018 changes and to use the Weave library.

This commit is contained in:
Myrddin Dundragon 2020-07-07 03:17:31 -04:00
parent 280c6605ff
commit 1985e8c1f8
9 changed files with 90 additions and 42 deletions

54
Cargo.lock generated
View File

@ -1,18 +1,60 @@
[root] # This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "binding"
version = "0.1.0"
source = "git+ssh://git@gitlab.com/CyberMages/Core/binding.git#51a8a23a65e5c31355dcd6ab353f30b32489b74a"
dependencies = [
"scribe 0.5.0 (git+ssh://git@gitlab.com/CyberMages/Core/scribe.git)",
"weave 0.1.0 (git+ssh://git@gitlab.com/CyberMages/Core/weave.git)",
]
[[package]]
name = "draconic" name = "draconic"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"scribe 0.1.0 (git+https://gitlab.com/CyberMages/scribe.git)", "scribe 0.5.0 (git+ssh://git@gitlab.com/CyberMages/Core/scribe.git)",
"spellbook 0.1.0 (git+https://gitlab.com/CyberMages/spellbook.git)", "spellbook 0.1.0 (git+ssh://git@gitlab.com/CyberMages/Core/spellbook.git)",
"weave 0.1.0 (git+ssh://git@gitlab.com/CyberMages/Core/weave.git)",
]
[[package]]
name = "pact"
version = "0.1.0"
source = "git+ssh://git@gitlab.com/CyberMages/Core/pact.git#16878ec911b09926db16bb11d504a30b21c06fb2"
dependencies = [
"binding 0.1.0 (git+ssh://git@gitlab.com/CyberMages/Core/binding.git)",
"scribe 0.5.0 (git+ssh://git@gitlab.com/CyberMages/Core/scribe.git)",
"weave 0.1.0 (git+ssh://git@gitlab.com/CyberMages/Core/weave.git)",
] ]
[[package]] [[package]]
name = "scribe" name = "scribe"
version = "0.1.0" version = "0.5.0"
source = "git+https://gitlab.com/CyberMages/scribe.git#c655eca358577795d818bdd07cb71864c0c9b9f2" source = "git+ssh://git@gitlab.com/CyberMages/Core/scribe.git#a1ebb45e35cf05692eaa2e13b602d33fde255710"
[[package]] [[package]]
name = "spellbook" name = "spellbook"
version = "0.1.0" version = "0.1.0"
source = "git+https://gitlab.com/CyberMages/spellbook.git#0059c4a676ef2243d982ec1ad471a03fc5c79e01" source = "git+ssh://git@gitlab.com/CyberMages/Core/spellbook.git#6ebdfae92c40c37bc92ba0571ce20ca331fc78bd"
dependencies = [
"binding 0.1.0 (git+ssh://git@gitlab.com/CyberMages/Core/binding.git)",
"pact 0.1.0 (git+ssh://git@gitlab.com/CyberMages/Core/pact.git)",
"scribe 0.5.0 (git+ssh://git@gitlab.com/CyberMages/Core/scribe.git)",
"weave 0.1.0 (git+ssh://git@gitlab.com/CyberMages/Core/weave.git)",
]
[[package]]
name = "weave"
version = "0.1.0"
source = "git+ssh://git@gitlab.com/CyberMages/Core/weave.git#44fe5ddade94651cfdb7b8d3fad2e6addd309975"
dependencies = [
"scribe 0.5.0 (git+ssh://git@gitlab.com/CyberMages/Core/scribe.git)",
]
[metadata]
"checksum binding 0.1.0 (git+ssh://git@gitlab.com/CyberMages/Core/binding.git)" = "<none>"
"checksum pact 0.1.0 (git+ssh://git@gitlab.com/CyberMages/Core/pact.git)" = "<none>"
"checksum scribe 0.5.0 (git+ssh://git@gitlab.com/CyberMages/Core/scribe.git)" = "<none>"
"checksum spellbook 0.1.0 (git+ssh://git@gitlab.com/CyberMages/Core/spellbook.git)" = "<none>"
"checksum weave 0.1.0 (git+ssh://git@gitlab.com/CyberMages/Core/weave.git)" = "<none>"

View File

@ -7,6 +7,8 @@ license = ""
repository = "https://gitlab.com/CyberMages/draconic.git" repository = "https://gitlab.com/CyberMages/draconic.git"
documentation = "" documentation = ""
keywords = ["draconic", "parser", "interpreter", "compiler"] keywords = ["draconic", "parser", "interpreter", "compiler"]
edition = "2018"
[[bin]] [[bin]]
name = "draconicpt" name = "draconicpt"
@ -14,7 +16,10 @@ path = "src/pt_compiler.rs"
[dependencies.scribe] [dependencies.scribe]
git = "https://gitlab.com/CyberMages/scribe.git" git = "ssh://git@gitlab.com/CyberMages/Core/scribe.git"
[dependencies.weave]
git = "ssh://git@gitlab.com/CyberMages/Core/weave.git"
[dependencies.spellbook] [dependencies.spellbook]
git = "https://gitlab.com/CyberMages/spellbook.git" git = "ssh://git@gitlab.com/CyberMages/Core/spellbook.git"

View File

@ -2,12 +2,14 @@ use std::fs::File;
use std::io::Write; use std::io::Write;
use std::path::Path; use std::path::Path;
use ::lexer::Lexer; use scribe::{warn, error};
use ::lexer::Token;
use ::lexer::TokenTypes; use crate::lexer::Lexer;
use ::parser::Parser; use crate::lexer::Token;
use ::reader::Reader; use crate::lexer::TokenTypes;
use ::util::Util; use crate::parser::Parser;
use crate::reader::Reader;
use crate::util::Util;

View File

@ -1,6 +1,10 @@
use ::reader::Reader; use scribe::{warn, error};
use ::lexer::token::Token;
use ::lexer::token_types::TokenTypes; use weave::attempt;
use crate::reader::Reader;
use crate::lexer::token::Token;
use crate::lexer::token_types::TokenTypes;
@ -386,7 +390,7 @@ impl Lexer
// Begin turning the input into tokens. // Begin turning the input into tokens.
while reader.is_eob() == false while reader.is_eob() == false
{ {
test_char = try!(reader.get_char()); test_char = attempt!(reader.get_char());
if is_whitespace(test_char) if is_whitespace(test_char)
{ {
// Just skip/remove any whitespace. // Just skip/remove any whitespace.

View File

@ -1,7 +1,9 @@
use std::convert::From; use std::convert::From;
use std::str::FromStr; use std::str::FromStr;
use ::lexer::token_types::TokenTypes; use scribe::warn;
use crate::lexer::token_types::TokenTypes;

View File

@ -1,10 +1,3 @@
#[macro_use]
extern crate scribe;
extern crate spellbook;
mod compiler; mod compiler;
mod lexer; mod lexer;
mod parser; mod parser;

View File

@ -1,10 +1,12 @@
use std::path::PathBuf; use std::path::PathBuf;
use ::compiler::read_file; use scribe::error;
use ::lexer::Token;
use ::lexer::TokenTypes; use crate::compiler::read_file;
use ::reader::Reader; use crate::lexer::Token;
use ::util::Util; use crate::lexer::TokenTypes;
use crate::reader::Reader;
use crate::util::Util;

View File

@ -1,10 +1,3 @@
#[macro_use]
extern crate scribe;
extern crate spellbook;
mod compiler; mod compiler;
mod lexer; mod lexer;
mod parser; mod parser;
@ -15,9 +8,10 @@ mod util;
use std::path::PathBuf; use std::path::PathBuf;
use spellbook::{EMPTY_STRING, ArgParser, ArgOption}; use spellbook::cantrips::{ArgParser, ArgOption};
use spellbook::components::EMPTY_STRING;
use ::compiler::Compiler; use crate::compiler::Compiler;

View File

@ -2,6 +2,10 @@ use std::fs::File;
use std::io::Read; use std::io::Read;
use std::path::Path; use std::path::Path;
use scribe::{info, error};
use weave::attempt;
// TODO: Make this work on only a predetermined size of a buffer. // TODO: Make this work on only a predetermined size of a buffer.
@ -151,7 +155,7 @@ impl Reader
// Get the current character and move the position // Get the current character and move the position
// in the buffer forward. // in the buffer forward.
character = try!(self.get_char()); character = attempt!(self.get_char());
self.position += 1; self.position += 1;
// Return the character that was retrieved. // Return the character that was retrieved.
@ -204,7 +208,7 @@ impl Reader
continue_consuming = true; continue_consuming = true;
while continue_consuming == true while continue_consuming == true
{ {
current_char = try!(self.consume_char()); current_char = attempt!(self.consume_char());
buffer.push(current_char); buffer.push(current_char);
if current_char == '\n' if current_char == '\n'