From 510071f487f2d415e5c657074c13bfc913f67c0b Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 24 Sep 2009 22:44:46 +0200 Subject: [PATCH] Bug in declaration positions Version:1.1.24 --- src/parsed_text.py | 59 ++++++++++++++++++++++++++-------------------- src/version.py | 2 +- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/parsed_text.py b/src/parsed_text.py index ce1be04..8c6302c 100644 --- a/src/parsed_text.py +++ b/src/parsed_text.py @@ -185,6 +185,36 @@ def get_parsed_text(): return main_result parsed_text = get_parsed_text() +###################################################################### +def move_to_top(text,t): + assert isinstance(text,list) + assert t in [ Declaration, Implicit, Use, Cont_provider ] + + inside = False + for i in range(len(text)): + vars, line = text[i] + if type(line) in [ Begin_provider, Subroutine, Function ]: + begin = i + inside = True + elif type(line) in [ End_provider, End ]: + inside = False + elif isinstance(line,t): + if inside: + text.pop(i) + begin += 1 + text.insert(begin,(vars,line)) + + return text + +result = [] +for filename,text in parsed_text: + text = move_to_top(text,Declaration) + text = move_to_top(text,Implicit) + text = move_to_top(text,Use) + text = move_to_top(text,Cont_provider) + result.append ( (filename,text) ) +parsed_text = result + ###################################################################### def move_variables(): @@ -237,9 +267,10 @@ def move_variables(): elif type(line) in [ Begin_provider, Subroutine, Function ]: varlist += vars result.append( (varlist,line) ) - assert old_varlist == [] - assert old_ifvars == [] - assert old_elsevars == [] + if old_varlist != [] \ + or old_ifvars != [] \ + or old_elsevars != []: + error.fail(line,"End if missing") varlist = [] elif isinstance(line,Provide_all): result.append( (vars,line) ) @@ -282,28 +313,6 @@ def move_variables(): parsed_text = move_variables() -###################################################################### -def move_to_top(text,t): - assert isinstance(text,list) - assert t in [ Declaration, Implicit, Use, Cont_provider ] - - inside = False - for i in range(len(text)): - vars, line = text[i] - if type(line) in [ Begin_provider, Subroutine, Function ]: - begin = i - inside = True - elif type(line) in [ End_provider, End ]: - inside = False - elif isinstance(line,t): - if inside: - text.pop(i) - begin += 1 - text.insert(begin,(vars,line)) - - return text - - ###################################################################### def build_needs(): # Needs diff --git a/src/version.py b/src/version.py index 88627ac..bc97a3e 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.1.23" +version = "1.1.24"