-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this is basically the [chapter 2 of _Writing An Interpreter In Go_](https://interpreterbook.com/)
- Loading branch information
Showing
5 changed files
with
1,016 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use crate::token::Token; | ||
|
||
#[derive(Clone, Debug, PartialEq, Default)] | ||
pub(crate) enum Expression { | ||
Identifier(String), | ||
IntegerLitteral(u32), | ||
Prefix(Token, Box<Self>), | ||
Infix(Box<Self>, Token, Box<Self>), | ||
Boolean(bool), | ||
If(Box<Self>, Vec<Statement>, Vec<Statement>), | ||
Function(Vec<String>, Vec<Statement>), | ||
Call(Box<Expression>, Vec<Expression>), | ||
#[default] | ||
Dummy, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq)] | ||
pub(crate) enum Statement { | ||
Let(String, Expression), | ||
Return(Expression), | ||
Expression(Expression), | ||
} | ||
|
||
#[derive(Default, Debug, PartialEq)] | ||
pub(crate) struct Program { | ||
pub statements: Vec<Statement>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.