Add loads of errors, add argh
This commit is contained in:
parent
8028dde855
commit
bc9b755ab9
83
Cargo.lock
generated
83
Cargo.lock
generated
@ -1,6 +1,89 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "argh"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"argh_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"argh_shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "argh_derive"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"argh_shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "argh_shared"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "reid"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"argh 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum argh 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca1877e24cecacd700d469066e0160c4f8497cc5635367163f50c8beec820154"
|
||||
"checksum argh_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e742194e0f43fc932bcb801708c2b279d3ec8f527e3acda05a6a9f342c5ef764"
|
||||
"checksum argh_shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e1ba68f4276a778591e36a0c348a269888f3a177c8d2054969389e3b59611ff5"
|
||||
"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
|
||||
"checksum proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa"
|
||||
"checksum quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
|
||||
"checksum syn 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)" = "e8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cd"
|
||||
"checksum unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0"
|
||||
"checksum unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||
|
@ -11,3 +11,4 @@ keywords = ["compiler", "language", "scripting", "parsing", "virtual machine"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
argh = "0.1.3"
|
@ -3,7 +3,7 @@ use std::num::ParseIntError;
|
||||
|
||||
use super::errors::CompilerError;
|
||||
use super::parser::{Expression, LiteralPattern, ParsedReid, Pattern, Position, Statement};
|
||||
use super::vm::{BuiltinFunctionDef, FunctionDef, FunctionSignature, VariableType};
|
||||
use super::vm::{FunctionSignature, VariableType};
|
||||
|
||||
type Variable = (HeapID, VariableType);
|
||||
pub type FuncID = usize;
|
||||
|
@ -19,6 +19,7 @@ impl From<io::Error> for GenericError {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum SyntaxError {
|
||||
#[allow(dead_code)]
|
||||
Fatal,
|
||||
ExpectedToken(Position, char),
|
||||
ExpectedExpression(Position, Option<Box<SyntaxError>>),
|
||||
@ -61,6 +62,7 @@ impl Display for SyntaxError {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum CompilerError {
|
||||
#[allow(dead_code)]
|
||||
Fatal,
|
||||
VariableExists(Position, String),
|
||||
VariableNotExists(Position, String),
|
||||
@ -71,16 +73,6 @@ pub enum CompilerError {
|
||||
ParseIntError(ParseIntError),
|
||||
}
|
||||
|
||||
impl CompilerError {
|
||||
fn from_opt(from: &Option<Box<SyntaxError>>) -> String {
|
||||
if let Some(err) = from {
|
||||
format!("\n {}", err)
|
||||
} else {
|
||||
String::new()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for CompilerError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let text = match self {
|
||||
@ -129,6 +121,7 @@ impl Display for ParamList {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum RuntimePanic {
|
||||
#[allow(dead_code)]
|
||||
Fatal,
|
||||
InvalidCommandIdx(usize),
|
||||
ScopeStackUnderflow,
|
||||
|
@ -82,8 +82,8 @@ impl Parser {
|
||||
pub fn expect<T: Into<String>>(&mut self, expectable: Expectable<T>) -> Expect {
|
||||
match expectable {
|
||||
Expectable::Static(val) => self.expect_static(val),
|
||||
Ident => self.expect_ident(),
|
||||
StringLit => self.expect_string_lit(),
|
||||
Expectable::Ident => self.expect_ident(),
|
||||
Expectable::StringLit => self.expect_string_lit(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -221,6 +221,7 @@ impl Parser {
|
||||
Position(self.line_number, self.character_number)
|
||||
}
|
||||
|
||||
#[allow(unused_assignments)]
|
||||
fn skip_whitespace_confident(&mut self, confident: bool) {
|
||||
let mut next = ' ';
|
||||
while self.remaining() > 0 && {
|
||||
@ -239,6 +240,7 @@ impl Parser {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub enum Expectable<T: Into<String>> {
|
||||
Static(T),
|
||||
Ident,
|
||||
|
@ -1,8 +1,6 @@
|
||||
pub mod functions;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::fmt::Display;
|
||||
|
||||
use super::compiler::{Command, CompiledReid, HeapID};
|
||||
use super::errors::RuntimePanic;
|
||||
|
Loading…
Reference in New Issue
Block a user