Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > PL/I can parse strings (was: )
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 2nd May 11:48
robin
External User
 
Posts: 1
Default PL/I can parse strings (was: )



From: "David Frank" <dave_frank@hotmail.com>, RoadRunner - Central Florida
Date: Mon, 24 Nov 2003 16:03:05 GMT


PL/I's string handling is VASTLY SUPERIOR to Fortran's.
It has many more functions, and better ones, than those in Fortran.


This is the same heap of rubbish that you were peddling
several months ago in comp.lang.fortran and here,
for which you received a lot of flak from Forran gurus.

This Fortran program relies on a bug in your compiler that allows
it to be deceived into accepting a function reference
having one argument, when the actual function has two
dummy arguments. It's not Fortran, and it won't work
on other Fortran compilers, and won't work with
the next upgrade of your compiler. Have you submitted
a bug report?

In other words, it's garbage.

It has no place in the programming arena.

! !-----------------
! program parse_text
! character(50) :: line = 'remove blanks, reverse string using array syntax'
! call parse(line)
! write (*,*) line ! " xatnysyarragnisugnirtsesrever,sknalbevomer"
! end program

! ! --------------------------------
! subroutine parse(string) ! strip blanks and reverse string
! character(*) :: string ! via char array pack function
! character,pointer :: a(
! integer :: n
! interface
! function S2P(s) result(p)
! character(*),target :: s

INCONSISTENCY BETWEEN s AND ITS DECLARATION IN THE FUNCTION.

! character,pointer :: p(
! end function
! end interface
! a => S2P(string) ! equate array to string

FUNCTION REFERENCE HAS ONE ARGUMENT.

! n = len_trim(string) ! #chars in string
! a(n:1:-1) = PACK( a(1:n), a(1:n) /= ' ', SPREAD(' ',1,n) )
! end subroutine
! ! -----------------------------
! function S2P(s,n) result(p)

FUNCTION HAS TWO DUMMY ARGUMENTS.

! integer :: n
! character,target :: s(n)
! character,pointer :: p(
! p => s
! end function
  Reply With Quote


  sponsored links


2 2nd May 11:48
david frank
External User
 
Posts: 1
Default PL/I can parse strings (was: )



Robin sputters:


prove it by posting a PL/I version of below simple fortran
WITHOUT use of loops,
(invoke those VASTLY SUPERIOR parsing functions you claim exist)


! ---------------------------------
program parse4 ! strip blanks, reverse text from text file
integer :: n
character(50) :: s
character :: a(50) ; equivalence (a,s)

open (1,file='parse4.txt')
do
read (1,'(a)',end=101) s
n = len_trim(s)
a(n:1:-1) = pack( a, a /= ' ', spread(' ',1,n) )
write (*,*) s(1:n) ! blanks stripped, text reversed
end do
101 stop
end program
  Reply With Quote
3 2nd May 11:48
robin
External User
 
Posts: 1
Default PL/I can parse strings


"David Frank" <dave_frank@hotmail.com> writes: >


I see three loops in that Fortran code.
  Reply With Quote
4 2nd May 11:48
robin
External User
 
Posts: 1
Default PL/I can parse strings


From: "David Frank" <dave_frank@hotmail.com>, RoadRunner - Central Florida
Date: Tue, 25 Nov 2003 15:55:16 GMT


..

..
parse4: proc options (main); /* strip blanks, reverse text from text file */
dcl t char(32767) var init (''), c char (1);
on endfile (sysin) put (t);
do forever;
get edit (c) (a(1));
if c ^= ' ' then t = c || t;
end;
end parse4;
..
  Reply With Quote
5 2nd May 11:48
david frank
External User
 
Posts: 1
Default PL/I can parse strings


Some inadequacies of your translation..

1. NO open to parse4.txt file shown, because it reveals the
inadequacy of PL/I support for user file opens to ANY file
with no prerequisite declarations.

2. NO processing record-by-record which results in t array overflow
for anything other than small text files.

3. NO parsing function that returns an array result seems to be
available from the VASTLY SUPERIOR PL/I repetoire of functions.

4. Horrific reversing text method moves 32767 chars to insert 1 char
  Reply With Quote
6 2nd May 11:48
david frank
External User
 
Posts: 1
Default PL/I can parse strings


Since you dropped down to char-by-char instead of record
processing using a buffer limited to small files,
I will show you my Fortran equivalent showing how your
code shud have been written...


! ----------------
program parse5 ! strip blanks, reverse text from text file
integer :: i
character :: ch, line(80)

open (1,file='parse5.f90',form='binary')
i = 0
do
read (1,end=101) ch ! input chars until eof
if (ch == ' ') cycle ! strip blank
i = i+1 ; line(i) = ch ! ac*** line buf
if (ch == char(10)) then ! lf = eol
write (*,'(80a)') line(i-2:1:-1) ! output reversed (-cr)
i = 0 ! reset line buffer
end if
end do
101 stop
end program
  Reply With Quote
7 2nd May 11:48
robin
External User
 
Posts: 1
Default PL/I can parse strings


parse4: proc options (main); /* strip blanks, reverse text from text file */
dcl t char(32767) var init (''), c char (1);
on endfile (sysin) put skip list (t);
do forever;
get edit (c) (a(1));
if c = '0d'x then do; put skip list (t); t = ''; end;
else if c = '0a'x then ;
else if c ^= ' ' then t = c || t;
end;
end parse4;
  Reply With Quote
8 2nd May 11:48
robin
External User
 
Posts: 1
Default PL/I can parse strings


"David Frank" <dave_frank@hotmail.com> writes: >

No it doesn't. 't' is a VARYING string. Initially has NO characters.

It has one loop.
Your Fortran code has at least 4 loops.
  Reply With Quote


  sponsored links


9 2nd May 11:48
david frank
External User
 
Posts: 1
Default PL/I can parse strings


You never show a open to actual file being used because it means
you have to expose the short-comings of PL/I syntax that requires unit numbers/etc declarations..


Your reply in another message hasnt improved this situation, why not?


You avoid answering the question, does PL/I have ANY parsing functions
that return an array result?

No varying string is needed if you recode your example
as a fixed line buffer and to get rid of the fault generated
when you process a file thats > 32767 chars.
  Reply With Quote
10 2nd May 11:48
david frank
External User
 
Posts: 1
Default PL/I can parse strings


Nit-pick of your try to match my example...

1. No declarations supporting open to parse5.txt file

2. No open file statement

3. on endfile says to me that program cant continue?
fortran allows processing to continue anywhere user chooses
via eof=***

4. resetting t = '' takes time vs. simple index reset i = 0

5. else if c = '0a'x then ;
nada

hard to read obfuscating logic that covers up lack of fortran's
easy to read if (...) cycle

I see now your correction allowing any size text file to be
processed, so I retract that complaint..
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666