(
source_file: SourceFile,
mode: Mode,
)
| 310 | } |
| 311 | |
| 312 | pub fn _compile_symtable( |
| 313 | source_file: SourceFile, |
| 314 | mode: Mode, |
| 315 | ) -> Result<symboltable::SymbolTable, CompileError> { |
| 316 | let res = match mode { |
| 317 | Mode::Exec | Mode::Single | Mode::BlockExpr => { |
| 318 | let ast = ruff_python_parser::parse_module(source_file.source_text()) |
| 319 | .map_err(|e| CompileError::from_ruff_parse_error(e, &source_file))?; |
| 320 | symboltable::SymbolTable::scan_program(&ast.into_syntax(), source_file.clone()) |
| 321 | } |
| 322 | Mode::Eval => { |
| 323 | let ast = ruff_python_parser::parse( |
| 324 | source_file.source_text(), |
| 325 | parser::Mode::Expression.into(), |
| 326 | ) |
| 327 | .map_err(|e| CompileError::from_ruff_parse_error(e, &source_file))?; |
| 328 | symboltable::SymbolTable::scan_expr( |
| 329 | &ast.into_syntax().expect_expression(), |
| 330 | source_file.clone(), |
| 331 | ) |
| 332 | } |
| 333 | }; |
| 334 | res.map_err(|e| e.into_codegen_error(source_file.name().to_owned()).into()) |
| 335 | } |
| 336 | |
| 337 | #[test] |
| 338 | fn test_compile() { |
no test coverage detected