diff src/python_ast.rs @ 0:211b0df72e64

Hello world!
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 29 May 2016 19:15:02 +0100
parents
children b90e49ab734b
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/src/python_ast.rs
@@ -0,0 +1,39 @@
+#[derive(Clone, Debug)]
+pub struct Module {
+    pub name: String,
+    pub statements: Vec<Statement>,
+}
+
+#[derive(Clone, Debug)]
+pub enum Statement {
+    FunctionDef(Expr, Vec<Expr>, Vec<Statement>),
+    Global(Vec<String>),
+    If(Expr, Vec<Statement>, Vec<Statement>),
+    Assign(Vec<Expr>, Expr),
+    Return(Expr),
+    ImportFrom(String, Vec<Expr>),
+    Expr(Expr),
+    Error,
+}
+
+#[derive(Clone, Debug, PartialEq, Eq, Hash)]
+pub enum Expr {
+    BinOp(Box<Expr>, BinOp, Box<Expr>),
+    Compare(Box<Expr>, Vec<BinOp>, Vec<Expr>),
+    Call(Box<Expr>, Vec<Expr>),
+    Alias(String, String),
+    Name(String),
+    NameConstant(String),
+    Str(String),
+    Num(String),
+    Error
+}
+
+#[derive(Clone, Debug, PartialEq, Eq, Hash)]
+pub enum BinOp {
+    BinAdd,
+    BinMult,
+    BinEq,
+    BinLt,
+    Error,
+}