Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove LFortran's AST to ASR and associated tests #258

Merged
merged 4 commits into from
Mar 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove LFortran tests
  • Loading branch information
certik committed Mar 19, 2022
commit de9c5e01590ec081fce08a77f57c20ee1772516a
1 change: 0 additions & 1 deletion src/bin/lpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <lpython/parser/parser.h>
#include <lpython/parser/preprocessor.h>
#include <lpython/pickle.h>
#include <lpython/semantics/ast_to_asr.h>
#include <lpython/semantics/python_ast_to_asr.h>
#include <lpython/mod_to_asr.h>
#include <libasr/codegen/asr_to_llvm.h>
Expand Down
12 changes: 1 addition & 11 deletions src/lpython/fortran_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <libasr/exception.h>
#include <lpython/ast.h>
#include <libasr/asr.h>
#include <lpython/semantics/ast_to_asr.h>
#include <lpython/parser/parser.h>
#include <lpython/parser/preprocessor.h>
#include <lpython/pickle.h>
Expand Down Expand Up @@ -225,7 +224,7 @@ Result<ASR::TranslationUnit_t*> FortranEvaluator::get_asr2(
}

Result<ASR::TranslationUnit_t*> FortranEvaluator::get_asr3(
AST::TranslationUnit_t &ast, diag::Diagnostics &diagnostics)
AST::TranslationUnit_t &/*ast*/, diag::Diagnostics &/*diagnostics*/)
{
ASR::TranslationUnit_t* asr;
// AST -> ASR
Expand All @@ -236,15 +235,6 @@ Result<ASR::TranslationUnit_t*> FortranEvaluator::get_asr3(
}
symbol_table->mark_all_variables_external(al);
}
auto res = ast_to_asr(al, ast, diagnostics, symbol_table,
compiler_options.symtab_only);
if (res.ok) {
asr = res.result;
} else {
LFORTRAN_ASSERT(diagnostics.has_error())
return res.error;
}
if (!symbol_table) symbol_table = asr->m_global_scope;

return asr;
}
Expand Down
31 changes: 0 additions & 31 deletions src/lpython/tests/test_ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <lpython/ast.h>
#include <libasr/asr.h>
#include <lpython/parser/parser.h>
#include <lpython/semantics/ast_to_asr.h>
#include <libasr/asr_verify.h>

namespace LFortran {
Expand All @@ -25,35 +24,5 @@ TEST_CASE("Test types") {

}

TEST_CASE("ASR Verify") {
Allocator al(4*1024);

std::string src = R"""(
program expr2
implicit none
integer :: x
x = (2+3)*5
print *, x
end program
)""";

LFortran::diag::Diagnostics diagnostics;
AST::TranslationUnit_t* ast = TRY(LFortran::parse(al, src, diagnostics));
ASR::TranslationUnit_t* asr = TRY(LFortran::ast_to_asr(al, *ast,
diagnostics));

CHECK(asr_verify(*asr)); // Passes

// Extract the variable "x" from the "x = (2+3)*5" line:
ASR::Program_t *prog = ASR::down_cast<ASR::Program_t>(asr->m_global_scope->scope["expr2"]);
ASR::Assignment_t *a = ASR::down_cast<ASR::Assignment_t>(prog->m_body[0]);
ASR::Var_t *v = ASR::down_cast<ASR::Var_t>(a->m_target);

v->m_v = &(prog->base); // Assign the wrong symbol to Var_t::m_v

// This will be caught by the verifier
CHECK_THROWS_AS(asr_verify(*asr), LFortranException);
}


} // namespace LFortran
Loading