Skip to content

Commit

Permalink
prettry print symbol table nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Glyphack committed Oct 29, 2023
1 parent f4f18ef commit 190b316
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
12 changes: 6 additions & 6 deletions typechecker/src/symbol_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,12 @@ impl std::fmt::Display for SymbolTableScope {
impl std::fmt::Display for Declaration {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Declaration::Variable(v) => write!(f, "{:?}", v),
Declaration::Function(fun) => write!(f, "{:?}", fun),
Declaration::Class(c) => write!(f, "{:?}", c),
Declaration::Parameter(p) => write!(f, "{:?}", p),
Declaration::Alias(a) => write!(f, "{:?}", a),
Declaration::TypeParameter(t) => write!(f, "{:?}", t),
Declaration::Variable(v) => write!(f, "{:#?}", v),
Declaration::Function(fun) => write!(f, "{:#?}", fun),
Declaration::Class(c) => write!(f, "{:#?}", c),
Declaration::Parameter(p) => write!(f, "{:#?}", p),
Declaration::Alias(a) => write!(f, "{:#?}", a),
Declaration::TypeParameter(t) => write!(f, "{:#?}", t),
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ self
Symbols:
__init__
- Declarations:
<<<<<<< HEAD
--: Function {
declaration_path: DeclarationPath {
module_name: [REDACTED]",
Expand Down Expand Up @@ -144,16 +143,14 @@ __init__
decorator_list: [],
returns: None,
type_comment: None,
type_params: [],
},
is_method: true,
is_generator: false,
return_statements: [],
yeild_statements: [],
raise_statements: [],
}
=======
--: Function { declaration_path: DeclarationPath { module_name: ".Users.glyphack.Programming.enderpy.typechecker.test_data.inputs.symbol_table.class_definition.py", node: Node { start: 13, end: 47 } }, function_node: FunctionDef { node: Node { start: 13, end: 47 }, name: "__init__", args: Arguments { node: Node { start: 26, end: 30 }, posonlyargs: [], args: [Arg { node: Node { start: 26, end: 30 }, arg: "self", annotation: None }], vararg: None, kwonlyargs: [], kw_defaults: [], kwarg: None, defaults: [] }, body: [AssignStatement(Assign { node: Node { start: 41, end: 46 }, targets: [Name(Name { node: Node { start: 41, end: 42 }, id: "a" })], value: Constant(Constant { node: Node { start: 45, end: 46 }, value: 1 }) })], decorator_list: [], returns: None, type_comment: None, type_params: [] }, is_method: true, is_generator: false, return_statements: [], yeild_statements: [], raise_statements: [] }
>>>>>>> d6d917b (Check for type alias in ast visitors)

-------------------

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ global scope:
Symbols:
func
- Declarations:
<<<<<<< HEAD
--: Function {
declaration_path: DeclarationPath {
module_name: [REDACTED]",
Expand Down Expand Up @@ -95,16 +94,14 @@ func
decorator_list: [],
returns: None,
type_comment: None,
type_params: [],
},
is_method: false,
is_generator: false,
return_statements: [],
yeild_statements: [],
raise_statements: [],
}
=======
--: Function { declaration_path: DeclarationPath { module_name: ".Users.glyphack.Programming.enderpy.typechecker.test_data.inputs.symbol_table.function_definition.py", node: Node { start: 0, end: 37 } }, function_node: FunctionDef { node: Node { start: 0, end: 37 }, name: "func", args: Arguments { node: Node { start: 9, end: 29 }, posonlyargs: [Arg { node: Node { start: 9, end: 10 }, arg: "a", annotation: None }, Arg { node: Node { start: 12, end: 13 }, arg: "b", annotation: None }], args: [Arg { node: Node { start: 19, end: 24 }, arg: "c", annotation: None }], vararg: None, kwonlyargs: [], kw_defaults: [], kwarg: Some(Arg { node: Node { start: 28, end: 29 }, arg: "e", annotation: None }), defaults: [Constant(Constant { node: Node { start: 23, end: 24 }, value: 2 })] }, body: [Pass(Pass { node: Node { start: 32, end: 36 } })], decorator_list: [], returns: None, type_comment: None, type_params: [] }, is_method: false, is_generator: false, return_statements: [], yeild_statements: [], raise_statements: [] }
>>>>>>> d6d917b (Check for type alias in ast visitors)

all scopes:
Symbols:
Expand Down

0 comments on commit 190b316

Please sign in to comment.