Skip to content

Commit

Permalink
Add basic help menu
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeRoggenbuck committed Sep 24, 2024
1 parent acbb619 commit 9c9f2b0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub enum TokenType {
Tag,
Reference,
Question,
DoubleQuestion,
At,
Percent,
Bang,
Expand Down Expand Up @@ -213,7 +214,7 @@ impl TokenTrait for Token {
let token_str = tokens.as_str();
let mut token = Token::default();

if tokens.len() == 1 {
if tokens.len() < 3 {
let token_type = match token_str {
"{" => TokenType::LeftBrace,
"}" => TokenType::RightBrace,
Expand All @@ -240,6 +241,7 @@ impl TokenTrait for Token {
"#" => TokenType::Tag,
"&" => TokenType::Reference,
"?" => TokenType::Question,
"??" => TokenType::DoubleQuestion,
"@" => TokenType::At,
"%" => TokenType::Percent,
"!" => TokenType::Bang,
Expand Down
19 changes: 19 additions & 0 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,25 @@ impl Parser for ParserState {
self.stack.push(token);
}

TokenType::DoubleQuestion => {
println!("Guide: ");
println!("------------------------------------------------------");
println!("Component uses Postfix Notation.");
println!(
"Postfix Notion has the arguments first, and then the function or operation."
);
println!(
"In the below example, we are adding 1 and 2 with the + operator to get 3."
);
println!("Try typing the following into the interactive prompt:");
println!("\n\t{}", bold!("1 2 +"));
println!("\nComponent has a lot of the operators you would expect in math.");
println!("Addition with {}", bold!("+"));
println!("Subtraction with {}", bold!("-"));
println!("Multiplication with {}", bold!("*"));
println!("Division with {}", bold!("/"));
}

TokenType::BoolLiteral => match token.value.as_str() {
"true" => self.stack.push(Token {
token_type: TokenType::BoolLiteral,
Expand Down

0 comments on commit 9c9f2b0

Please sign in to comment.