latest pushes

This commit is contained in:
2024-10-02 15:24:39 -04:00
parent 07469fd003
commit 6f3e00a792
9 changed files with 90 additions and 14 deletions

View File

@@ -6,9 +6,8 @@ mod utilities;
use crate::interpreter::interpreter::Interpreter;
use crate::lexer::lexer::Lexer;
use crate::parser::parser::Parser;
use crate::utilities::Token;
use crate::utilities::utilities::Token;
use glob::glob;
use std::env;
use std::fs::File;
use std::io::{self, BufRead, Write};

0
src/executor/executor.rs Normal file
View File

1
src/executor/mod.rs Normal file
View File

@@ -0,0 +1 @@
pub mod executor;

View File

@@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::utilities::ASTNode;
use crate::utilities::utilities::ASTNode;
use glob::glob;
use std::collections::HashMap;

View File

@@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::utilities::Token;
use crate::utilities::utilities::Token;
pub struct Lexer {
input: Vec<char>,

View File

@@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::utilities::{ASTNode, Token};
use crate::utilities::utilities::{ASTNode, Token};
pub struct Parser {
tokens: Vec<Token>,

1
src/utilities/mod.rs Normal file
View File

@@ -0,0 +1 @@
pub mod utilities;

View File

@@ -0,0 +1,75 @@
// Copyright (C) 2024 Bellande Architecture Mechanism Research Innovation Center, Ronaldson Bellande
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#[derive(Debug, Clone, PartialEq)]
pub enum Token {
Word(String),
Assignment,
Pipe,
Redirect(String),
LeftParen,
RightParen,
Semicolon,
NewLine,
If,
Then,
Else,
Fi,
While,
Do,
Done,
For,
In,
Function,
Ampersand,
}
#[derive(Debug, Clone)]
pub enum ASTNode {
Command {
name: String,
args: Vec<String>,
},
Assignment {
name: String,
value: String,
},
Pipeline(Vec<ASTNode>),
Redirect {
node: Box<ASTNode>,
direction: String,
target: String,
},
Block(Vec<ASTNode>),
If {
condition: Box<ASTNode>,
then_block: Box<ASTNode>,
else_block: Option<Box<ASTNode>>,
},
While {
condition: Box<ASTNode>,
block: Box<ASTNode>,
},
For {
var: String,
list: Vec<String>,
block: Box<ASTNode>,
},
Function {
name: String,
body: Box<ASTNode>,
},
Background(Box<ASTNode>),
}