Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. pub enum StatementNode {
  2. Function(Function),
  3. WhileLoop(WhileLoop),
  4. Constant(Constant),
  5. }
  6.  
  7. pub enum ExpressionNode {
  8. BinOp((Box<ExpressionNode>, BinOp, Box<ExpressionNode>)),
  9. Constant(Constant),
  10. }
  11.  
  12. pub enum BinOp {
  13. Add,
  14. Sub,
  15. Div,
  16. Mul,
  17. }
  18.  
  19. pub struct WhileLoop {
  20. pub condition: ExpressionNode,
  21. pub body: Vec<StatementNode>,
  22. }
  23.  
  24. pub enum Constant {
  25. Int(i32),
  26. Str(String),
  27. Bool(bool),
  28. }
  29.  
  30. pub enum VarType {
  31. Int,
  32. Str,
  33. Bool,
  34. }
  35.  
  36. pub struct Function {
  37. pub ident: String,
  38. pub params: Vec<Parameter>,
  39. pub body: Vec<StatementNode>,
  40. }
  41.  
  42. pub struct Parameter {
  43. pub ident: String,
  44. pub ty: VarType,
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement