Thread View: vmsnet.tpu
4 messages
4 total messages
Started by Mirko Vukovic
Wed, 30 Dec 1992 18:40
Pattern
Author: Mirko Vukovic
Date: Wed, 30 Dec 1992 18:40
Date: Wed, 30 Dec 1992 18:40
40 lines
1555 bytes
1555 bytes
Hello!
I am converting a fortran code from single to double precision on a VAX. I
a TPU routine that searches for constants in the program by using the following
patterns
aaaa.bbbbbX
.bbbbbX
aaaa.X
aaaa any number of digits
bbbb any number of digits
X any character except d,D
and puts the cursor on the end of a line where the pattern was found.
I came up with the following patterns:
predig:=span('0123456789'); <--- for aaaa
posdig:=anchor&span('0123456789'); <--- for bbbb
per:='.'; <--- for .
exp:=anchor&(notany('dD')|line_end); <--- for X
find :=((predig&per&exp)|(per&posdig&exp)|(predig&per&posdig&exp));
However the above does detect numbers like 123.12D00, ie if I have more than one
digit after the period followed by D.
Is that because in posdig anchor forces the span to match only one character?
How do I go around that? The program has 10000 (10^4) lines.
Also, how do I put a cursor on the end of a range?
Thanks.
--
Mirko Vukovic
University of Wisconsin -- Madison
VUKOVIC@UWMFE.NEEP.WISC.EDU
Re: Pattern
Author: August Reinig
Date: Wed, 30 Dec 1992 21:55
Date: Wed, 30 Dec 1992 21:55
30 lines
1553 bytes
1553 bytes
>I came up with the following patterns:
>
>predig:=span('0123456789'); <--- for aaaa
>posdig:=anchor&span('0123456789'); <--- for bbbb
>per:='.'; <--- for .
>exp:=anchor&(notany('dD')|line_end); <--- for X
>
>find :=((predig&per&exp)|(per&posdig&exp)|(predig&per&posdig&exp));
>
>However the above does detect numbers like 123.12D00, ie if I have more than >one digit after the period followed by D.
What version of TPU? I haven't examined this in detail but your patterns look ok. Why not try:
( (span("0123456789") + "." + notany("dD")) ! aa.X
| (span("0123456789") + "." + span("0123456789") + notany("dD")) ! aa.bbX
| ( "." + span("0123456789") + notany("dD")))! .bbX
and report the results.
You can use partial pattern assignment on your patterns to see who is matching what.
----
> how do I put a cursor on the end of a range?
position(end_of(<range>));
August
(former TPU developer, patterns were
my specialty)
Re: Pattern
Author: fairfield
Date: Wed, 30 Dec 1992 23:37
Date: Wed, 30 Dec 1992 23:37
79 lines
3830 bytes
3830 bytes
In article <1hsqeoINNmqe@usenet.INS.CWRU.Edu>, at913@cleveland.Freenet.Edu (Mirko Vukovic) writes:
> I am converting a fortran code from single to double precision on a VAX.
> I a TPU routine that searches for constants in the program by using the
> following patterns
>
> aaaa.bbbbbX
> .bbbbbX
> aaaa.X
>
> aaaa any number of digits
> bbbb any number of digits
> X any character except d,D
>
> and puts the cursor on the end of a line where the pattern was found.
>
> I came up with the following patterns:
>
> predig:=span('0123456789'); <--- for aaaa
> posdig:=anchor&span('0123456789'); <--- for bbbb
> per:='.'; <--- for .
> exp:=anchor&(notany('dD')|line_end); <--- for X
>
> find :=((predig&per&exp)|(per&posdig&exp)|(predig&per&posdig&exp));
>
> However the above does detect numbers like 123.12D00, ie if I have more than
> one digit after the period followed by D.
>
> Is that because in posdig anchor forces the span to match only one character?
No, it's because the first "alternation" in the pattern "find", that is,
"predig&pre&exp" matches the "123.1" in "123.12D00" (the NOTANY('dD') matches
the "1" following the period, see below). Remember, the order of the alternate
subpatterns is important.
Also, I would modify your pattern variables to use concatenation "+"
rather than linkage "&" (see Section 2.7.3.2, p.2-15, in the VAXTPU manual).
This will remove the need for ANCHOR and make it clear (to yourself) what
you're searching for. For example:
digits := span('0123456789');
exp := notany('dD01234567879') +
(span('01234567879') + line_end | line_end);
patt1 := digits + '.' + digits + exp;
patt2 := '.' + digits + exp;
patt3 := digits + '.' + exp;
find := ( patt1 | patt2, | patt3);
A final remark on this pattern: I would think it would be better to use
an ANY('eE') in the "exp" pattern (aren't "E" and "D" the only allowed
exponent characters in VAX Fortran?). My "extension" to the exp pattern
above won't prevent you from matching any arbitrary other character.
Also, do you really need to match the line_end condition? If you do, fine,
but you'd better be sure the files you're editing don't have any trailing
tabs or spaces...
> Also, how do I put a cursor on the end of a range?
SEARCH returns a range, so just POSITION (END_OF (range)). For example,
in testing it's nice to see exactly what range SEARCH returned. You could
do something like this:
r1 := Search_Quietly (find, FORWARD);
If r1 <> 0 Then
Position (End_Of (r1));
r2 := Create_Range (Beginning_Of (r1), Mark (NONE), REVERSE);
Update (CURRENT_WINDOW); ! <- not necessary, but could be useful
Endif;
An earlier remark above implies you'd like to leave the cursor at the end of
the line. In that case, after the Position (r1), or whatever, just do
a Position (LINE_END).
Cheers, Ken
--
Dr. Kenneth H. Fairfield | Internet: Fairfield@Slac.Stanford.Edu
SLAC, P.O.Box 4349, MS 98 | DECnet: 45537::FAIRFIELD (45537=SLACVX)
Stanford, CA 94309 | BITNET Fairfield@Slacvx
----------------------------------------------------------------------------
These opinions are mine, not SLAC's, Stanford's, nor the DOE's...
Re: Pattern
Author: Carl J Lydick
Date: Thu, 31 Dec 1992 17:33
Date: Thu, 31 Dec 1992 17:33
29 lines
1837 bytes
1837 bytes
In article <1hsqeoINNmqe@usenet.INS.CWRU.Edu>, at913@cleveland.Freenet.Edu (Mirko Vukovic) writes:
>predig:=span('0123456789'); <--- for aaaa
>posdig:=anchor&span('0123456789'); <--- for bbbb
>per:='.'; <--- for .
>exp:=anchor&(notany('dD')|line_end); <--- for X
>
>find :=((predig&per&exp)|(per&posdig&exp)|(predig&per&posdig&exp));
>
>However the above does detect numbers like 123.12D00, ie if I have more than one
>digit after the period followed by D.
It also does not detect numbers like 123.12. In particular, it only picks up
the "123.1" part of i.
>Is that because in posdig anchor forces the span to match only one character?
No, it's because the exp picks up only one character.
>Also, how do I put a cursor on the end of a range?
position(end_of(range));
--------------------------------------------------------------------------------
Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL
Disclaimer: Hey, I understand VAXen and VMS. That's what I get paid for. My
understanding of astronomy is purely at the amateur level (or below). So
unless what I'm saying is directly related to VAX/VMS, don't hold me or my
organization responsible for it. If it IS related to VAX/VMS, you can try to
hold me responsible for it, but my organization had nothing to do with it.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads