Skip to content

Commit

Permalink
Add Crates and Build buttons to README (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirdaki authored Oct 9, 2022
1 parent a147e2a commit b9c3b37
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# [Choice] Debian OS version (use bullseye on local arm64/Apple Silicon): buster, bullseye
ARG VARIANT="buster"
FROM mcr.microsoft.com/vscode/devcontainers/rust:0-${VARIANT}
FROM mcr.microsoft.com/devcontainers/rust:${VARIANT}

# Add LLVM Dependecies
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
Expand Down
86 changes: 62 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ pub enum Node {
Noop,
}

#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum UnaryOperation {
Not,
}

#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum BinaryOperation {
Add,
Subtract,
Expand Down
4 changes: 2 additions & 2 deletions src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,14 +561,14 @@ where
{
match (&state.get_current()?, value) {
(Node::String(string_x), Node::String(string_y)) => {
let new_current = Node::Boolean(bool_operation(&*string_x, &*string_y));
let new_current = Node::Boolean(bool_operation(string_x, string_y));
state.set_current(new_current)?;
Ok(())
}
(Node::String(string_x), Node::Variable(var_name)) => {
let var_value = state.get_variable(var_name)?;
if let Node::String(string_y) = var_value {
let new_current = Node::Boolean(bool_operation(&*string_x, &*string_y));
let new_current = Node::Boolean(bool_operation(string_x, string_y));
state.set_current(new_current)?;
Ok(())
} else {
Expand Down
16 changes: 8 additions & 8 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn build_ast(pair: pest::iterators::Pair<Rule>) -> Node {
Rule::Main => {
let pairs = pair.into_inner();
let mut body = Vec::<Node>::new();
for pair in pairs.into_iter() {
for pair in pairs {
body.push(build_ast(pair));
}
Node::Main(body)
Expand All @@ -51,7 +51,7 @@ fn build_ast(pair: pest::iterators::Pair<Rule>) -> Node {
let identifier = pairs.next().unwrap().as_str();
let value = build_ast(pairs.next().unwrap());
let mut operations = Vec::<Node>::new();
for pair in pairs.into_iter() {
for pair in pairs {
operations.push(build_ast(pair));
}
Node::AssignVariable(identifier.to_string(), Box::new(value), operations)
Expand Down Expand Up @@ -102,7 +102,7 @@ fn build_ast(pair: pest::iterators::Pair<Rule>) -> Node {
let value = build_ast(pairs.next().unwrap());
let identifier = pairs.next().unwrap().as_str();
let mut statements = Vec::<Node>::new();
for pair in pairs.into_iter() {
for pair in pairs {
statements.push(build_ast(pair));
}
Node::For(
Expand All @@ -115,7 +115,7 @@ fn build_ast(pair: pest::iterators::Pair<Rule>) -> Node {
let mut pairs = pair.into_inner();
let value = build_ast(pairs.next().unwrap());
let mut statements = Vec::<Node>::new();
for pair in pairs.into_iter() {
for pair in pairs {
statements.push(build_ast(pair));
}
Node::While(Box::new(value), statements)
Expand All @@ -125,9 +125,9 @@ fn build_ast(pair: pest::iterators::Pair<Rule>) -> Node {
let value = build_ast(pairs.next().unwrap());
let mut if_statements = Vec::<Node>::new();
let mut else_statements = Vec::<Node>::new();
for pair in pairs.into_iter() {
for pair in pairs {
if pair.as_rule() == Rule::ElseClause {
for pair in pair.into_inner().into_iter() {
for pair in pair.into_inner() {
else_statements.push(build_ast(pair));
}
break;
Expand Down Expand Up @@ -227,7 +227,7 @@ fn build_ast(pair: pest::iterators::Pair<Rule>) -> Node {
Rule::String => {
let pairs = pair.into_inner();
let mut string = "".to_string();
for pair in pairs.into_iter() {
for pair in pairs {
string.push_str(build_string(pair).as_str());
}
Node::String(string)
Expand Down Expand Up @@ -263,7 +263,7 @@ fn build_string(pair: pest::iterators::Pair<Rule>) -> String {
Rule::Inner => {
let pairs = pair.into_inner();
let mut string = "".to_string();
for pair in pairs.into_iter() {
for pair in pairs {
string.push_str(build_string(pair).as_str());
}
string
Expand Down

0 comments on commit b9c3b37

Please sign in to comment.