Open GoogleCodeExporter opened 9 years ago
I agree with the objective of such applications.
However, while fparser preserves all Fortran constructs,
it does not preserve the use of white space. This has
historical and practical reasons: according to Fortran
standard, white space is insignificant within Fortran
statements. Also, the original documents are always
available (the span of Line instance corresponds to
the original code). In addition, people write their
code with very different styles and to reproduce
exactly the sources, fparser would need to keep
every use of white space (original intent, line continuation);
this is not possible with the current implementation of
fparser -- much of its simplicity comes from the assumption
that white space can be ignored.
Btw, fparser already reproduces the original code in the
sense that the compiler will produce the same object
code for both the original source and fparser generated source.
At least that is the aim of fparser.
So, could you be more specific what exact behavior you
are looking for. An example would be nice to demonstrate your wish.
Original comment by pearu.peterson
on 25 Mar 2010 at 11:26
People may use "space" with some mean to read codes.
So I want to reproduce, this type of example.
----------------------------
program test2
real(8):: switch1, ! some long document with lines for switch1
! ...
! ... end of document for switch1
& switch2 ! some long document with lines for switch2
! ...
! ... end of document for switch2
end
----------------------------
How to do this? Current fparser gives
----------------------
BeginSource
blocktype='beginsource'
name="<open file 'test2.F', mode 'r' at 0x7f8ea196b3e8> mode=fix90"
content:
Program
blocktype='program'
name='test2'
item=Line('program test2',(1, 1),None,None,<reader>)
a=AttributeHolder:
variables=<dict with keys ['switch2', 'switch1']>
variable_names=<2-list>
content:
Real
selector=('', '8')
entity_decls=['switch1', 'switch2']
item=Line('real(8):: switch1, switch2,',(2,
5),None,None,<reader>)
Comment
item=Comment('! some long document with lines for switch1',(2, 2))
Comment
item=Comment(' ! ...',(3, 3))
Comment
item=Comment(' ! ... end of document for
switch1',(4, 4))
Comment
item=Comment('! some long document with lines for switch2',(5, 5))
Comment
item=Comment(' ! ...',(6, 6))
Comment
item=Comment(' ! ... end of document for
switch2',(7, 7))
EndProgram
blocktype='program'
name='test2'
item=Line('end',(8, 8),None,None,<reader>)
------------------------------------------------------
How to reproduce original code from this?
1.item=Line('real(8):: switch1, switch2',(2, 5),None,None,<reader>)
should contain information about how the line is divided into 3 lines, and
the starting column in these lines. Maybe a list
[' real(8):: switch1','',' switch2'] or something makes things easier.
(To reproduce 'real(8):: switch1, switch2' is easy from them).
In cases, characters in continuation column (6th column) are used as a memo.
So it is better to keep them also in item.
2. item=Comment('! some long document with lines for switch1',(2, 2))
should give starting column.
=====================================================
This is my request.
However, I have little idea about how expensive to modify fparser.
So I don't know wether it is worth to do now or not.
Original comment by TakaoKot...@gmail.com
on 27 Mar 2010 at 12:46
Original issue reported on code.google.com by
TakaoKot...@gmail.com
on 25 Mar 2010 at 10:33