Skip to content

Commit

Permalink
refactor: split indent into ast_indent and asr_indt,
Browse files Browse the repository at this point in the history
remove extra indent
  • Loading branch information
Thirumalai-Shaktivel committed Apr 11, 2021
1 parent 7e058a8 commit f786b83
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 56 deletions.
5 changes: 4 additions & 1 deletion grammar/asdl_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,10 @@ def visitField(self, field, cons):
self.emit( '}', level)
self.emit(' s.append(a.first + ": ");', level)
self.emit(' this->visit_symbol(*a.second);', level)
self.emit(' if (i < x.m_%s->scope.size()-1) s.append(", ");' % field.name, level)
self.emit(' if (i < x.m_%s->scope.size()-1) { ' % field.name, level)
self.emit(' s.append(", ");', level)
self.emit(' if(indent) dec_indent();', level)
self.emit(' }', level)
self.emit(' i++;', level)
self.emit(' }', level)
self.emit('}', level)
Expand Down
11 changes: 7 additions & 4 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ def main():
continue
tokens = test.get("tokens", False)
ast = test.get("ast", False)
indent = test.get("indent", False)
ast_indent = test.get("ast_indent", False)
ast_f90 = test.get("ast_f90", False)
ast_cpp = test.get("ast_cpp", False)
ast_cpp_hip = test.get("ast_cpp_hip", False)
ast_openmp = test.get("ast_openmp", False)
asr = test.get("asr", False)
asr_indent = test.get("asr_indent", False)
mod_to_asr = test.get("mod_to_asr", False)
llvm = test.get("llvm", False)
cpp = test.get("cpp", False)
Expand All @@ -65,11 +66,9 @@ def main():
if ast:
run_test("ast", "lfortran --show-ast --no-color {infile} -o {outfile}",
filename, update_reference)
if indent:
if ast_indent:
run_test("ast_indent", "lfortran --show-ast --indent --no-color {infile} -o {outfile}",
filename, update_reference)
run_test("asr_indent", "lfortran --show-asr --indent --no-color {infile} -o {outfile}",
filename, update_reference)

if ast_f90:
run_test("ast_f90", "lfortran --show-ast-f90 --no-color {infile}",
Expand All @@ -91,6 +90,10 @@ def main():
run_test("asr", "lfortran --show-asr --no-color {infile} -o {outfile}",
filename, update_reference)

if asr_indent:
run_test("asr_indent", "lfortran --show-asr --indent --no-color {infile} -o {outfile}",
filename, update_reference)

if mod_to_asr:
run_test("mod_to_asr", "lfortran mod --show-asr --no-color {infile}",
filename, update_reference)
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr_indent-subroutine1-5dfc71f.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr_indent-subroutine1-5dfc71f.stdout",
"stdout_hash": "24e2350982c2bc0311d420b6a1a7c942af5a2f0aa26a7aecfcac4a68",
"stdout_hash": "5f2e15cd782595c0787e9c6ad81c51d97b5d36d1b958761cb2db9520",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
98 changes: 49 additions & 49 deletions tests/reference/asr_indent-subroutine1-5dfc71f.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
(Integer 4 [])
Source
Public),
x:
(Variable
2
x
Local ()
Default
(Integer 4 [])
Source
Public)
x:
(Variable
2
x
Local ()
Default
(Integer 4 [])
Source
Public)
})
g [] [
(=
Expand All @@ -44,47 +44,47 @@
(Integer 4 [])))])]
Source
Public),
h:
(Subroutine
(SymbolTable
3
{
i:
(Variable
3
i
Local ()
Default
(Integer 4 [])
Source
Public),
x:
(Variable
3
x
Local ()
Default
(Integer 4 [])
Source
Public)
})
h [] [
h:
(Subroutine
(SymbolTable
3
{
i:
(Variable
3
i
Local ()
Default
(Integer 4 [])
Source
Public),
x:
(Variable
3
x
Local ()
Default
(Integer 4 [])
Source
Public)
})
h [] [
(=
(Var 3 x) (ConstantInteger 1
(Integer 4 [])))
(DoLoop
(
(Var 3 i) (ConstantInteger 1
(Integer 4 [])) (ConstantInteger 10
(Integer 4 [])) ()) [
(=
(Var 3 x) (ConstantInteger 1
(Integer 4 [])))
(DoLoop
(
(Var 3 i) (ConstantInteger 1
(Integer 4 [])) (ConstantInteger 10
(Integer 4 [])) ()) [
(=
(Var 3 x)
(BinOp
(Var 3 i)
Mul
(Var 3 x)
(BinOp
(Var 3 i)
Mul
(Var 3 x)
(Integer 4 [])))])]
Source
Public)
(Integer 4 [])))])]
Source
Public)
})
[])
3 changes: 2 additions & 1 deletion tests/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
[[test]]
filename = "subroutine1.f90"
tokens = true
indent = true
ast_indent = true
asr_indent = true
ast = true

[[test]]
Expand Down

0 comments on commit f786b83

Please sign in to comment.