Fixed warnings
This commit is contained in:
parent
6f4be5a929
commit
081930e6f5
|
|
@ -0,0 +1,5 @@
|
|||
use crate::interpreter::InterpreterState;
|
||||
|
||||
pub fn load_builtins(_state: &mut InterpreterState) -> bool {
|
||||
false
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ pub fn exec_file(interpreter: &mut InterpreterState, filename: &str) -> bool {
|
|||
}
|
||||
};
|
||||
|
||||
let mut lexer_info = LexerInfo::new(filename.clone(), source.clone());
|
||||
let mut lexer_info = LexerInfo::new(filename, source.clone());
|
||||
|
||||
let result = lexical_analysis(&mut lexer_info);
|
||||
|
||||
|
|
@ -40,6 +40,9 @@ pub fn run_file(filename: &str) -> i32 {
|
|||
println!("Executing file: {}", filename);
|
||||
|
||||
let mut interpreter = InterpreterState::new();
|
||||
if !interpreter.init() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if exec_file(&mut interpreter, filename) {
|
||||
0
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use crate::lexer::*; // Identifier, Token, TokenString, etc.
|
||||
use crate::builtin::load_builtins;
|
||||
|
||||
pub type BuiltinFn = fn(&mut InterpreterState) -> bool;
|
||||
|
||||
|
|
@ -49,6 +50,10 @@ impl InterpreterState {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn init(&mut self) -> bool {
|
||||
load_builtins(self)
|
||||
}
|
||||
|
||||
pub fn push_token(&mut self, token: Token) -> bool {
|
||||
let value = match token {
|
||||
Token::Eof => return true,
|
||||
|
|
@ -127,15 +132,3 @@ impl InterpreterState {
|
|||
self.stack.get(self.stack.len() - 1)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn interpreter_create(load_builtins: fn(&mut InterpreterState) -> bool)
|
||||
-> Option<InterpreterState>
|
||||
{
|
||||
let mut state = InterpreterState::new();
|
||||
|
||||
if !load_builtins(&mut state) {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(state)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,29 +68,29 @@ pub struct Identifier {
|
|||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ArrayLiteral {
|
||||
Identifiers(Vec<Identifier>),
|
||||
I64(Vec<i64>),
|
||||
I32(Vec<i32>),
|
||||
I16(Vec<i16>),
|
||||
I8(Vec<i8>),
|
||||
U64(Vec<u64>),
|
||||
U32(Vec<u32>),
|
||||
U16(Vec<u16>),
|
||||
U8(Vec<u8>),
|
||||
Float(Vec<f32>),
|
||||
Double(Vec<f64>),
|
||||
Character(Vec<u8>),
|
||||
Strings(Vec<String>),
|
||||
Boolean(Vec<bool>),
|
||||
TokenStrings(Vec<TokenString>),
|
||||
TypeTuples(Vec<TypeTuple>),
|
||||
StructInline(StructInline),
|
||||
_Identifiers(Vec<Identifier>),
|
||||
_I64(Vec<i64>),
|
||||
_I32(Vec<i32>),
|
||||
_I16(Vec<i16>),
|
||||
_I8(Vec<i8>),
|
||||
_U64(Vec<u64>),
|
||||
_U32(Vec<u32>),
|
||||
_U16(Vec<u16>),
|
||||
_U8(Vec<u8>),
|
||||
_Float(Vec<f32>),
|
||||
_Double(Vec<f64>),
|
||||
_Character(Vec<u8>),
|
||||
_Strings(Vec<String>),
|
||||
_Boolean(Vec<bool>),
|
||||
_TokenStrings(Vec<TokenString>),
|
||||
_TypeTuples(Vec<TypeTuple>),
|
||||
_StructInline(StructInline),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ShapedArray {
|
||||
pub array: ArrayLiteral,
|
||||
pub shape: Vec<usize>,
|
||||
pub _array: ArrayLiteral,
|
||||
pub _shape: Vec<usize>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -100,25 +100,25 @@ pub struct TokenString {
|
|||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TypeTuple {
|
||||
pub inputs: Vec<Identifier>,
|
||||
pub outputs: Vec<Identifier>,
|
||||
pub _inputs: Vec<Identifier>,
|
||||
pub _outputs: Vec<Identifier>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct StructInline {
|
||||
pub name: String,
|
||||
pub values: Vec<StructValue>,
|
||||
pub _name: String,
|
||||
pub _values: Vec<StructValue>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum StructValue {
|
||||
Integer(i64),
|
||||
Float(f32),
|
||||
Double(f64),
|
||||
Boolean(bool),
|
||||
Character(u8),
|
||||
String(String),
|
||||
Token(Token),
|
||||
_Integer(i64),
|
||||
_Float(f32),
|
||||
_Double(f64),
|
||||
_Boolean(bool),
|
||||
_Character(u8),
|
||||
_String(String),
|
||||
_Token(Token),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -190,7 +190,7 @@ impl LexerInfo {
|
|||
!c.is_ascii_digit() && self.is_identifier_continue(c)
|
||||
}
|
||||
|
||||
fn parse_identifiers_and_booleans(&mut self, start: usize, start_line: usize, start_col: usize) -> LexResult<Token> {
|
||||
fn parse_identifiers_and_booleans(&mut self, _start: usize, start_line: usize, start_col: usize) -> LexResult<Token> {
|
||||
let mut c = self.peek();
|
||||
let mut literal = false;
|
||||
|
||||
|
|
@ -259,7 +259,7 @@ impl LexerInfo {
|
|||
Ok(Token::Character(value))
|
||||
}
|
||||
|
||||
fn parse_token_string(&mut self, start: usize, start_line: usize, start_col: usize) -> LexResult<Token> {
|
||||
fn parse_token_string(&mut self, _start: usize, start_line: usize, start_col: usize) -> LexResult<Token> {
|
||||
let mut tokens = Vec::new();
|
||||
self.advance(); // skip '{'
|
||||
|
||||
|
|
@ -399,7 +399,7 @@ impl LexerInfo {
|
|||
|
||||
let mut is_float = false;
|
||||
let mut is_unsigned = false;
|
||||
let mut bit_size = 64; // default
|
||||
let bit_size: u32;
|
||||
|
||||
if c == 'f' {
|
||||
is_float = true;
|
||||
|
|
|
|||
|
|
@ -14,11 +14,6 @@ use repl::repl;
|
|||
const SLS_NAME: &str = "SLS_RUST";
|
||||
const SLS_VER: &str = "a.0.0";
|
||||
|
||||
// Environment variables set via build.rs for commit hash / compiler.
|
||||
const GIT_COMMIT_HASH: &str = env!("GIT_COMMIT_HASH", "UNKNOWN");
|
||||
const COMPILER_NAME: &str = env!("COMPILER_NAME", "Unknown");
|
||||
const COMPILER_VER: &str = env!("COMPILER_VER", "0");
|
||||
|
||||
pub fn print_version() {
|
||||
let git_hash = option_env!("GIT_COMMIT_HASH").unwrap_or("unknown");
|
||||
let compiler = option_env!("COMPILER_NAME").unwrap_or("rustc");
|
||||
|
|
@ -26,7 +21,7 @@ pub fn print_version() {
|
|||
let build_date = std::env::var("BUILD_DATE").unwrap_or_else(|_| "unknown".into());
|
||||
let build_time = std::env::var("BUILD_TIME").unwrap_or_else(|_| "unknown".into());
|
||||
|
||||
println!("YREA SLS (SLS_RUST) a.0.0 ({git_hash})");
|
||||
println!("YREA SLS ({SLS_NAME}) {SLS_VER} ({git_hash})");
|
||||
println!("Compiled with {compiler} {compiler_ver} at {build_date} {build_time}");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@ pub fn repl() -> i32 {
|
|||
io::stdout().flush().unwrap();
|
||||
|
||||
let mut interpreter = InterpreterState::new();
|
||||
if !interpreter.init() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
let stdin = io::stdin();
|
||||
let mut buf = String::new();
|
||||
|
|
|
|||
Loading…
Reference in New Issue